Search code examples
phpphpmailer

use variable's content as attachment in PHPMailer


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?


Solution

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

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