现在已经三天了,我花了很多时间和精力在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>
";
答案 0 :(得分:0)
为什么不使用PHPMailer的内置iCal支持?
$mail->Ical = $attachment;
弄乱您正在处理的标头会适得其反-让PHPMailer为您处理它。
请记住,电子邮件客户端中的iCal支持非常不一致,因此不要指望它在不同系统上的工作方式相同。