Send attachments with PHP Mail()?

前端 未结 14 2442
北恋
北恋 2020-11-21 04:46

I need to send a pdf with mail, is it possible?

$to = \"xxx\";
$subject = \"Subject\" ;
$message = \'Example message with html\';
$header         


        
14条回答
  •  太阳男子
    2020-11-21 04:57

    After struggling for a while with badly formatted attachments, this is the code I used:

    $email = new PHPMailer();
    $email->From      = 'from@somedomain.com';
    $email->FromName  = 'FromName';
    $email->Subject   = 'Subject';
    $email->Body      = 'Body';
    $email->AddAddress( 'to@somedomain.com' );
    $email->AddAttachment( "/path/to/filename.ext" , "filename.ext", 'base64', 'application/octet-stream' );
    $email->Send();
    

提交回复
热议问题