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 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题