doushui3216 2019-07-17 09:32
浏览 115

多次努力后,使用phmailer发送内联会议邀请失败

its been three days now, i spend lot of time and efforts on stackoverflow to figure it out, finally thought of posting this question, with the below code i can send email invite but in attachment form, i want inline attachment

i am able to send invite with attached .ical file with below code, but i dont want attachment, i want inline invite along with mail body,

$headers = 'Content-Type:text/calendar; Content-Disposition: inline;
    charset=utf-8;
';
$headers .= "Content-Type: /text/plain;charset=\"utf-8\"
"; 

$attachment="
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Asia/Kolkata
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "example.com
DTEND:". $dbInsertEndTime . "T" . $EndTime . "00
DTSTAMP:" . gmdate('Ymd') . 'T' . gmdate('His') . "Z
DTSTART:". $dbInsertStartDate . "T" . $StartTime . "00
SUMMARY:" . $subject . "
ORGANIZER;CN=Foobar:mailto:foobar@myemail.com
LOCATION:" . $Location . "
DESCRIPTION:" . $desc . "
TRANSP:TRANSPARENT
BEGIN:VALARM
TRIGGER:-PT30M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR";

$headers .= $attachment;


$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->SMTPDebug = 0;  
$mail->Host = 'xxxxxxxxxx';
$mail->Port = 25;                                    // TCP port to connect to
$mail->Username = EMAIL;                 // SMTP username
$mail->Password = PASS;           
$mail->setFrom(EMAIL, 'xxxx');
$ext = "@outlook.com";
$mail->addAddress($my_ID.$ext);     // Add a recipient
$mail->addReplyTo(EMAIL);
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = ($subject);
$mail->addStringAttachment($attachment,'invite.ics','base64','text/calendar');


$mail->Body    = "<html>
<head>
<title>Meeeting Invite</title>
<style type='text/css'>
table.example2 {background-color:transparent;border-collapse:collapse;width:100%;}
table.example2 th, table.example2 td {text-align:center;border:1px solid black;padding:5px;}
table.example2 th {background-color:AntiqueWhite;}
table.example2 td:first-child {width:15%;}
</style>
</head>
<body>
<p>Dear ". $Employee_Name. " ,<br /><br /></p>
<p>Your meeting  Scheduled.<br /></p>
</body>
</html>
";
  • 写回答

1条回答

  • duanmu0834 2019-07-17 09:53
    关注

    Why not use PHPMailer’s built-in iCal support?

    $mail->Ical = $attachment;
    

    All that messing with headers you’re doing is counter-productive - let PHPMailer deal with it for you.

    Bear in mind that iCal support in email clients is very inconsistent, so don’t expect it to work the same way on different systems.

    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题