I need to send a pdf with mail, is it possible?
$to = \"xxx\";
$subject = \"Subject\" ;
$message = \'Example message with html\';
$header
Swiftmailer is another easy-to-use script that automatically protects against email injection and makes attachments a breeze. I also strongly discourage using PHP's built-in mail()
function.
To use:
lib
folder in your projectrequire_once 'lib/swift_required.php';
Now add the code when you need to mail:
// Create the message
$message = Swift_Message::newInstance()
->setSubject('Your subject')
->setFrom(array('webmaster@mysite.com' => 'Web Master'))
->setTo(array('receiver@example.com'))
->setBody('Here is the message itself')
->attach(Swift_Attachment::fromPath('myPDF.pdf'));
//send the message
$mailer->send($message);
More information and options can be found in the Swiftmailer Docs.