4

I want to do this:

$mail = new PHPMailer;
$mail->AddAttachment('text in file', 'file.txt');

so the attachment can have dynamic content. I can only use real file as attachment now. Obviously, real file is static, I want to generate some content dynamically and attach it to the mail. There must be some way to do it, I guess it's not that obscure feature. Someone knows how?

3
  • you mean you want to how to create file then insert dynamic content then attach it? Commented May 24, 2013 at 0:46
  • @Aboodred1 I hope there's more elegant solution than putting that content into a file, just for the attachment. See, I don't need the data in file, I just want to send it in a mail as a file, then discard that data. Obviously, I can put it in file, send it and then delete the file, but it just doesn't feel right. Commented May 24, 2013 at 0:49
  • possible duplicate of PHPMailer attachment, doing it without a physical file Commented Oct 11, 2013 at 4:08

1 Answer 1

6
$mail->AddStringAttachment($string,$filename,$encoding,$type);

http://phpmailer.worxware.com/?pg=tutorial#3

Sign up to request clarification or add additional context in comments.

1 Comment

Whoa, didn't see that one. Thanks a lot, that's exactly what I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.