您好,
我想知道mandrill是否支持发送附带 ics 文件的邮件。
假设我有一些模板。
function sendMailMandrillInvite($name, $contact_email, $textarea, $url, $template_name = 'invite-businesses'){
$merge = 'true';
$message = array('dest_mail' => $contact_email, 'merge' => $merge);
$message['to'] = array(array('email' => $contact_email));
$mergeVars[] = array(
'rcpt' => $contact_email,
'vars' => array(
array('name' => 'contact_name', 'content' => $name),
array('name' => 'message', 'content' => $textarea),
array('name' => 'url', 'content' => $url)
)
);
$template_content = array(array('name' => 'example name', 'content' => 'example content')); // dummy usage
$message['merge_vars'] = $mergeVars;
return $this->messages_send_template($template_name, $template_content, $message);
}
创建模板(HTML)和附加ics文件以使mandrill邮件成为“邀请”的方式是什么?
有可能吗?
谢谢,
答案 0 :(得分:7)
目前,我们无法支持文本/日历多部分格式 - 通常是用于在电子邮件中添加这些事件邀请的格式。当Mandrill的解析器遇到这些类型的消息部分(文本/日历)时,它会跳过它们,因为它们不符合它知道如何抽象的任何东西。它不是真正的文本或HTML,附件或嵌入式图像。在将来,我们会考虑为这种特殊形式的消息添加特殊支持,因为它非常受欢迎,但我无法提供任何特定的ETA。与此同时,您可以考虑生成.ics文件并附加它们,就像通过Mandrill API或SMTP集成一样使用其他类型的附件。
The Mandrill Crew
所以这是我用过的方式:
模板的
{
"key": "xxxxxxxxxxxxxxxxxx",
"template_name": "fess1",
"template_content": [
{
"name": "example name",
"content": "example content"
}
],
"message": {
"merge": "true",
"to": [
{
"email": "snaggs@gmail.com",
"name": "Snaggs",
"type": "to"
}
],
"headers": {
"Reply-To": "snaggs@gmail.com",
"MIME-Version": 1.0
},
"merge": true,
"merge_vars": [
{
"rcpt": "snaggs@gmail.com",
"vars": [
{
"name": "FNAME",
"content": "Snaggis"
}
]
}
],
"attachments": [
{
"type": "text/calendar",
"name": "meeting.ics",
"content": "QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOi0vL01lZXRlci9tZWV0ZXIvL05PTlNHTUwgdjEuMC8vRU4NCkNBTFNDQUxFOkdSRUdPUklBTg0KTUVUSE9EOlJFUVVFU1QNCkJFR0lOOlZFVkVOVA0KRFRTVEFSVDoyMDE0MTAxOFQyMDMwMDBaDQpEVEVORDoyMDE0MTAxOFQyMTAwMDBaDQpVSUQ6MjAxNDEwMTVUMDAyODEzLTIyMzc4ODg2OEBtZWV0ZXIuY29tDQpEVFNUQU1QOjIwMTQxMDE0VDIxMjgxM1oNCk9SR0FOSVpFUjtDTj0ic25hZ2dzQGdtYWlsLmNvbSI7U0VOVC1CWT0iTUFJTFRPOnNvbWVhcHBAZ21haWwuY29tIjtMQU5HVUFHRT1zZTpNQUlMVE86c25hZ2dzQGdtYWlsLmNvbQ0KQVRURU5ERUU7Q1VUWVBFPUlORElWSURVQUw7Uk9MRT1SRVEtUEFSVElDSVBBTlQ7UEFSVFNUQVQ9TkVFRFMtQUNUSU9OO1JTVlA9VFJVRTtDTj1GZXNzeSBNO1gtTlVNLUdVRVNUUz0wOk1BSUxUTzpzbmFnZ3MyQGdtYWlsLmNvbQ0KREVTQ1JJUFRJT046ZGRkZCBtYW5kcmlsbA0KTE9DQVRJT046ZGRkZGRkIG1hbmRyaWxsDQpTVU1NQVJZOkNhbiBJIGxheSBsb3c/IENvb2sgc29tZSB5YXkteW8gMg0KVFJBTlNQOk9QQVFVRQ0KU0VRVUVOQ0U6MA0KU1RBVFVTOkNPTkZJUk1FRA0KRU5EOlZFVkVOVA0KRU5EOlZDQUxFTkRBUg=="
}
]
}
}
content
的位置:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Meeter/meeter//NONSGML v1.0//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20141018T203000Z
DTEND:20141018T210000Z
UID:20141015T002813-223788868@meeter.com
DTSTAMP:20141014T212813Z
ORGANIZER;CN="snaggs@gmail.com";SENT-BY="MAILTO:someapp@gmail.com";LANGUAGE=se:MAILTO:snaggs@gmail.com
ATTENDEE;CUTYPE=INDIVIDUAL;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EOlZFVkVOVA0KRU5EOlZDQUxFTkRBUg==
答案 1 :(得分:0)
您应该使用https://icalendar.readthedocs.io/en/latest/index.html生成简单的ics文件,使用https://docs.python.org/2/library/base64.html#base64.b64decode将其转换为base64并作为附件发送
[
{
'type': "text/calendar",
'content': b64encode(
make_isc_calendar(start, end, location, event)),
'name': "calendar.ics",
}
]