【问题标题】:sending inline meeting invite using phmailer failed after multiple effort多次努力后使用 phmailer 发送内联会议邀请失败
【发布时间】:2019-07-17 09:32:58
【问题描述】:

现在已经三天了,我花了很多时间和精力在stackoverflow上弄清楚,终于想到发布这个问题,用下面的代码我可以发送电子邮件邀请但以附件形式,我想要内联附件

我可以使用以下代码发送带有附加 .ical 文件的邀请, 但我不想要附件,我想要内联邀请和邮件正文,

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

$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>
";

【问题讨论】:

  • 能够让它工作,但附件为 .ics 文件,我想要内联附件

标签: php outlook phpmailer


【解决方案1】:

为什么不使用 PHPMailer 内置的 iCal 支持?

$mail->Ical = $attachment;

你所做的一切乱七八糟的标题都会适得其反 - 让 PHPMailer 为你处理它。

请记住,电子邮件客户端中的 iCal 支持非常不一致,因此不要期望它在不同系统上的工作方式相同。

【讨论】:

  • 我试过了,但又没有邮件正文内容
  • 您还没有发布修改后的代码或调试输出,所以我无法告诉您更多信息。
  • 还没有运气,有人可以提出解决方案吗?
猜你喜欢
  • 2011-06-16
  • 1970-01-01
  • 1970-01-01
  • 2018-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多