带附件的邮件带有标准邮件功能

时间:2017-04-21 07:53:58

标签: php email

我需要发送一封带有标准php邮件功能附件的电子邮件。我不能使用像phpmailer这样的类。 PHP verison 5.3。

到目前为止这是有效的。

mail($to,$subject,$content,$headers);
你可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

使用以下代码发送带附件的邮件

$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();