使用 PHP 读取 Outlook 预约回复

发布于 2024-11-15 11:05:33 字数 4824 浏览 0 评论 0原文

我有一个页面,管理员可以在其中为委员会创建活动,并将日历通知发送给给定委员会的所有成员。

我想要做的是以某种方式检索回复,无论它是被接受、暂定还是拒绝,并显示响应列表以及事件信息。

活动创建者将设置为使用电子邮件地址,其唯一目的是创建活动。

我能够连接到收件箱并阅读电子邮件,我可以很好地读取初始事件创建,就像它的 ics 文件一样,但是当我尝试读取某人的响应时,我得到的只是垃圾:

--_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ 内容类型:文本/纯文本;字符集 =“utf-8”内容传输编码:base64 SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLg0KDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ 内容类型:text/html;字符集 =“utf-8”内容传输编码:base64 PGh0bWw+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0i dGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29udGVu dd0iTWljcm9zb2Z0IEV4Y2hhbmdlIFNlcnZlciI+DQo8IS0tIGNvbnZlcnRlZCBmcm9tIHJ0ZiAt LT4NCjxzdHLsZT48IS0tIC5FbWFpbFF1b3RlIHsgbWFyZ2luLWxlZnQ6IDFwdDsgcGFkZGluZy1s ZWZ0OiA0CHQ7IGJvcmRlci1sZWZ0OiAjODAwMDAwIDJweCBzb2xpZDsgfSAtLT48L3N0eWxlPg0K PC9oZWFkPg0KPGJvZHk+DQo8Zm9udCBmYWNlPSJDYWxpYnJpLCBzYW5zLXNlcmlmIiBzaXplPSIy Ij4NCjxkaXY+SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLjwvZGl2Pg0K PGRpdj4mbmJzcDs8L2Rpdj4NCjwvZm9udD4NCjwvYm9keT4NCjwvaHRtbD4NCg== --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ 内容类型:文本/日历;字符集=“utf-8”;方法=回复内容传输编码:base64 QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVQTFkNClBST0RJRDpNaWNyb3NvZnQgRXhjaGFuZ2Ug U2VydmVyIDIwMDcNClZFUlNJT046Mi4wDQpCRUdJTjpWVElNRVpPTkUNClRaSUQ6Q2VudHJhbCBT dGFuZGFyZCBUaW1ldQpCRUdJTjpTVEFOREFSRA0KRFRTVEFSVDoxNjAxMDEwMVQwMjaWMDANClRa T0ZGU0VURlJPTTotMDUwMA0KVFpPRkZTRVRUTzotMDYwMA0KulJVTEU6RlJFUT1ZRUFSTFk7SU5U RVJWQUw9MTtCWURBWT0xU1U7QllNT05USD0xMQ0KRU5EOlNUQU5EQVJEDQpCRUdJTjpEQVlMSUDI VA0KRFRTVEFSVDoxNjAxMDEwMVQwMjAwMDANClRaT0ZGU0VURlJPTTotMDYwMA0KVFpPRkZTRVRU TzotMDUwMA0KUlJVTEU6RlJFUT1ZRUFSTFk7SU5URVJWQUw9MTtCWURBWT0yU1U7QllNT05USD0z DQpFTkQ6REFZTELHSFQNCkVORDpWVElNRVpPTkUNCkJFR0lOolZFVkVOVA0KT1JHQU5JWkVSO0NO PVJ5YW4gTGVpc2luZzpNQUlMVE86cmxlaXNpbmdAbWl0Y2hlbGx3YXluZS5jb20NCkFUVEVOREVF O1BBURTVEFUPUFDQ0VQVEVEO0NOPUtlbGxpIEdldHRpbmdlcjpNQUlMVE86a2VsbGlAbWl0Y2hl bGx3YXluZS5jbw0KIG0NCkNPTU1FTlQ7TEFOR1VBR0U9ZW4tVVM6SnVzdCBpbiBjYXNlIHlvdSBu ZWVkIHRvIHNlZSBhIHJlc3BvbnNlLlxuXG4NClNVTU1BUlk7TEFOR1VBR0U9ZW4tVVM6QWNjZXB0 ZWQ6IHRlc3RpbmcNCkRUU1RBUlQ7VFpJRD1DZW50cmFsIFN0YW5kyXJkIFRpbWU6MjAxMTA2MTVU MTUzMDAwDQpEVEVORDtUWklEPUNlbnRyYWwgU3RhbmRhcmQgVGltZToyMDExMDYxNVQxNjAwMDAN ClVJRDowNDAwMDAwMDgyMDBFMDAwNzRDNUI3MTAxQTgyRTAwODAwMDAwMDAwMjBFNkFFN0Y2RDJC Q0MwMTAwMDAwMDAwMDAwMDAwMA0KIDAxMDAwMDAwMDBCRDdCRDdDNDlDMjIyNDg4QTZFMTE3OTc4 QzdDNUQyDQpDTEFTUzpQVUJMSUMNClBSSU9SSVRZOjUNCkRUU1RBTVA6MjAxMTA2MTVUMjawNDM3 Wg0KVFJBTlNQOk9QQVFVRQ0KU1RBVFVTOkNPTkZJUk1FRA0KU0VRVUVOQ0U6MA0KTE9DQVRJT047 TEFOR1VBR0U9ZW4tVVM6TVdUDQpYLU1JQ1JPU09GVC1DRE8tQVBQVC1TRVFVRU5DRTowDQpYLU1J Q1JPU09GVC1DRE8tT1dORVJBUFBUSUQ6LTExOTAxNzI3MDkNClgtTulDUk9TT0ZULUNETy1CVVNZ U1RBVFVTOkJVU1kNClgtTulDUk9TT0ZULUNETy1JTlRFTkRFRFNUQVRVUzpCVVNZDQpYLU1JQ1JP U09GVC1DRE8tQUxMREFZRVZFTlQ6RkFMU0UNClgtTulDUk9TT0ZULUNETy1JTVBPUlRBTkNFOjEN ClgtTULDUk9TT0ZULUNETy1JTlNUVFlQRTowDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFSDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_--

下面是我如何创建和发送通知。

$vcal = "BEGIN:VCALENDAR\r\n";
$vcal .= "PRODID:-//CompanyName//ProductName//EN\r\n";
$vcal .= "VERSION:2.0\r\n";
$vcal .= "METHOD:REQUEST\r\n";
$vcal .= "BEGIN:VEVENT\r\n";
foreach($comstmt->fetchAll(PDO::FETCH_ASSOC) as $commem){
    $vcal .= "ATTENDEE;CN=\"".$commem['first']." ".$commem['last']."\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:".$commem['email']."\r\n";
}
$vcal .= "ATTENDEE;CN=\"Ryan Leising\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:[email protected]\r\n";
$vcal .= "DESCRIPTION:".$_POST['event_description']."\r\n";
$vcal .= "DTEND:$dtend\r\n"; 
$vcal .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
$vcal .= "DTSTART:$dtstart\r\n";
$vcal .= "LOCATION:".$_POST['event_location']."\r\n";
$vcal .= "SUMMARY:".$comname." event\r\n";
$vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-domain.com\r\n";
$vcal .= "BEGIN:VALARM\r\n";
$vcal .= "TRIGGER:-PT15M\r\n";
$vcal .= "ACTION:DISPLAY\r\n";
$vcal .= "END:VALARM\r\n";
$vcal .= "END:VEVENT\r\n";
$vcal .= "END:VCALENDAR\r\n";
$headers = "From: [email protected]\r\nReply-To: [email protected]"; 
$headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; method=REQUEST; charset=\"iso-8859-1\"";
$headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 
$mailsent = mail($to, $comname." event", $vcal, $headers);

I have a page where the admins create events for a committee and the calendar notification is sent out to all of the member of the given committee.

What I want to be able to do is somehow retrieve the reply, whether it was accepted, tentative, or declined, and display the list of responses along with the event info.

The event creator will be setup to use an email address with the sole purpose of creating the events.

I am able to connect to the inbox and read emails, i can read the initial event creation just fine, like its an ics file, but when i try to read the response from someone all i get is garbage:


--_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLg0KDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: base64 PGh0bWw+DQo8aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0i dGV4dC9odG1sOyBjaGFyc2V0PXV0Zi04Ij4NCjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29udGVu dD0iTWljcm9zb2Z0IEV4Y2hhbmdlIFNlcnZlciI+DQo8IS0tIGNvbnZlcnRlZCBmcm9tIHJ0ZiAt LT4NCjxzdHlsZT48IS0tIC5FbWFpbFF1b3RlIHsgbWFyZ2luLWxlZnQ6IDFwdDsgcGFkZGluZy1s ZWZ0OiA0cHQ7IGJvcmRlci1sZWZ0OiAjODAwMDAwIDJweCBzb2xpZDsgfSAtLT48L3N0eWxlPg0K PC9oZWFkPg0KPGJvZHk+DQo8Zm9udCBmYWNlPSJDYWxpYnJpLCBzYW5zLXNlcmlmIiBzaXplPSIy Ij4NCjxkaXY+SnVzdCBpbiBjYXNlIHlvdSBuZWVkIHRvIHNlZSBhIHJlc3BvbnNlLjwvZGl2Pg0K PGRpdj4mbmJzcDs8L2Rpdj4NCjwvZm9udD4NCjwvYm9keT4NCjwvaHRtbD4NCg== --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_ Content-Type: text/calendar; charset="utf-8"; method=REPLY Content-Transfer-Encoding: base64 QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVQTFkNClBST0RJRDpNaWNyb3NvZnQgRXhjaGFuZ2Ug U2VydmVyIDIwMDcNClZFUlNJT046Mi4wDQpCRUdJTjpWVElNRVpPTkUNClRaSUQ6Q2VudHJhbCBT dGFuZGFyZCBUaW1lDQpCRUdJTjpTVEFOREFSRA0KRFRTVEFSVDoxNjAxMDEwMVQwMjAwMDANClRa T0ZGU0VURlJPTTotMDUwMA0KVFpPRkZTRVRUTzotMDYwMA0KUlJVTEU6RlJFUT1ZRUFSTFk7SU5U RVJWQUw9MTtCWURBWT0xU1U7QllNT05USD0xMQ0KRU5EOlNUQU5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VdUDQpYLU1JQ1JPU09GVC1DRE8tQVBQVC1TRVFVRU5DRTowDQpYLU1J Q1JPU09GVC1DRE8tT1dORVJBUFBUSUQ6LTExOTAxNzI3MDkNClgtTUlDUk9TT0ZULUNETy1CVVNZ U1RBVFVTOkJVU1kNClgtTUlDUk9TT0ZULUNETy1JTlRFTkRFRFNUQVRVUzpCVVNZDQpYLU1JQ1JP U09GVC1DRE8tQUxMREFZRVZFTlQ6RkFMU0UNClgtTUlDUk9TT0ZULUNETy1JTVBPUlRBTkNFOjEN ClgtTUlDUk9TT0ZULUNETy1JTlNUVFlQRTowDQpFTkQ6VkVWRU5UDQpFTkQ6VkNBTEVOREFSDQo --_000_D3E7EC0B6389944E84089DB2A556B79F01214822CACALOIS_--

Below is how I am creating and sending the notifications.

$vcal = "BEGIN:VCALENDAR\r\n";
$vcal .= "PRODID:-//CompanyName//ProductName//EN\r\n";
$vcal .= "VERSION:2.0\r\n";
$vcal .= "METHOD:REQUEST\r\n";
$vcal .= "BEGIN:VEVENT\r\n";
foreach($comstmt->fetchAll(PDO::FETCH_ASSOC) as $commem){
    $vcal .= "ATTENDEE;CN=\"".$commem['first']." ".$commem['last']."\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:".$commem['email']."\r\n";
}
$vcal .= "ATTENDEE;CN=\"Ryan Leising\";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:[email protected]\r\n";
$vcal .= "DESCRIPTION:".$_POST['event_description']."\r\n";
$vcal .= "DTEND:$dtend\r\n"; 
$vcal .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
$vcal .= "DTSTART:$dtstart\r\n";
$vcal .= "LOCATION:".$_POST['event_location']."\r\n";
$vcal .= "SUMMARY:".$comname." event\r\n";
$vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-domain.com\r\n";
$vcal .= "BEGIN:VALARM\r\n";
$vcal .= "TRIGGER:-PT15M\r\n";
$vcal .= "ACTION:DISPLAY\r\n";
$vcal .= "END:VALARM\r\n";
$vcal .= "END:VEVENT\r\n";
$vcal .= "END:VCALENDAR\r\n";
$headers = "From: [email protected]\r\nReply-To: [email protected]"; 
$headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; method=REQUEST; charset=\"iso-8859-1\"";
$headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 
$mailsent = mail($to, $comname." event", $vcal, $headers);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尸血腥色 2024-11-22 11:05:33

PHP IMAP 开始,选中新消息框并整理出您想要的消息想要解析。除此之外,您还需要确定 Outlook 回复消息的结构,并开始解析所需的信息。 preg_match() 将是您在那里提取文本的朋友,但如果没有看到消息的示例,我们将无法提供太多帮助。

如果只是检索如果 imap_fetchbody() 还不够,则消息正文。

Start with PHP IMAP to check the box for new messages and sort out the ones you want to parse. Beyond that, you'll need to identify the structure of the Outlook reply messages, and start parsing out the information you want. preg_match() will be your friend to extract text there, but without seeing examples of the messages we won't be able to help too much more.

The mailparse library will help to deconstruct the MIME messages, if simply retrieving the message body if imap_fetchbody() isn't enough.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文