doujiaci7976 2018-04-19 15:11
浏览 122

在邮件中使用`addStringAttachment`和`addEmbeddedImage`到MS Outlook

I have been trying to send emails with an attachment using PHPMailer. This worked fine. Then I decided to embed an image using the addEmbeddedImage-method.

Now I have a problem! The emails are received fine in gmail. But when I open the email in windows (using MS-Outlook) the attachment disappears!!

$mail = new PHPMailer;

//Server settings
$mail->SMTPDebug = 0;                       // Disable verbose debug output
$mail->isSMTP();                            // Set mailer to use SMTP
$mail->Host = $mailHost;                    // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                     // Enable SMTP authentication
$mail->Username = $mailUserName;            // SMTP username
$mail->Password = $mailPassword;            // SMTP password
$mail->SMTPSecure = 'tls';                  // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                          // TCP port to connect to

//Recipients
$mail->setFrom($mailSentFrom , $organisation);
$mail->addAddress($emailAdress, $recipientFullName);

//Attachments
$mail->addEmbeddedImage($_SERVER['DOCUMENT_ROOT'].PHP_PATH.'/library-overrides/FPDF/images/small-logo.jpg', 'logo');
$mail->addStringAttachment($attachment, "$categoryName $seasonName, $recipientFullName.pdf", 'base64', 'application/pdf');

$mail->isHTML( true );
$mail->Subject = "$categoryName $seasonName";
$mail->Body = ""; // contains html version of email (omitted for readability)
$mail->AltBody = "";

$mail->send();

Any ideas how to fix this?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了