I need to send a pdf with mail, is it possible?
$to = "xxx";
$subject = "Subject" ;
$message = 'Example message with <b>html</b>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: xxx <xxx>' . "\r\n";
mail($to,$subject,$message,$headers);
What am I missing?
I agree with @MihaiIorga in the comments – use the PHPMailer script. You sound like you’re rejecting it because you want the easier option. Trust me, PHPMailer is the easier option by a very large margin compared to trying to do it yourself with PHP’s built-in
mail()function. PHP’smail()function really isn’t very good.To use PHPMailer:
require_once('path/to/file/class.phpmailer.php');Now, sending emails with attachments goes from being insanely difficult to incredibly easy:
It’s just that one line
$email->AddAttachment();— you couldn’t ask for any easier.If you do it with PHP’s
mail()function, you’ll be writing stacks of code, and you’ll probably have lots of really difficult to find bugs.