-2

I need to send an email with an attachment with the standard php mail function. I can't use classes like phpmailer. PHP verison 5.3.

This is working so far.

mail($to,$subject,$content,$headers);

Can you help me out?

1 Answers1

0

Use below code for send mail with attachment

$email = new PHPMailer();
$email->From      = 'you@example.com';
$email->FromName  = 'Your Name';
$email->Subject   = 'Message Subject';
$email->Body      = $bodytext;
$email->AddAddress( 'destinationaddress@example.com' );

$file_to_attach = 'PATH_OF_YOUR_FILE_HERE';

$email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );

return $email->Send();
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Ahmed Ginani
  • 6,522
  • 2
  • 15
  • 33