我正在尝试使用mandrill api从我的localhost发送电子邮件,但每次我调用发送电子邮件功能时,我都会获得“排队”状态。如果我看到mandrill api日志,我看到通话成功,我也没有收到任何电子邮件。这是我正在使用的代码 -
try {
$mandrill = new Mandrill($this->api_key);
$template_name = 'Invitation';
$template_content = array(
array(
'name' => 'main',
'content' => 'Hi *|FIRSTNAME|*, you are cordially invited.'
)
);
$message = array(
'html' => '<p>Example HTML content</p>',
'text' => 'Example text content',
'subject' => 'example subject',
'from_email' => 'message.from_email@example.com',
'from_name' => 'Example Name',
'to' => array(
array(
'email' => 'someone@somemail.com',
'name' => 'Recipient Name',
'type' => 'to'
)
),
'headers' => array('Reply-To' => 'someother@anothermail.com'),
'important' => false,
'track_opens' => null,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => null,
'view_content_link' => null,
'bcc_address' => 'someone@somemail.com',
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'merge_language' => 'mailchimp',
'global_merge_vars' => array(
array(
'name' => 'merge1',
'content' => 'merge1 content'
)
),
'merge_vars' => array(
array(
'rcpt' => 'another@anothermail.pro',
'vars' => array(
array(
'name' => 'FIRSTNAME',
'content' => 'My First Name'
)
)
)
),
'tags' => array('password-resets'),
'subaccount' => 'customer-123',
'google_analytics_domains' => array('example.com'),
'google_analytics_campaign' => 'message.from_email@example.com',
'metadata' => array('website' => 'www.example.com'),
'recipient_metadata' => array(
array(
'rcpt' => 'recipient.email@example.com',
'values' => array('user_id' => 123456)
)
),
'attachments' => array(
array(
'type' => 'text/plain',
'name' => 'myfile.txt',
'content' => 'ZXhhbXBsZSBmaWxl'
)
),
'images' => array(
array(
'type' => 'image/png',
'name' => 'IMAGECID',
'content' => 'ZXhhbXBsZSBmaWxl'
)
)
);
$async = false;
$ip_pool = 'Main Pool';
$send_at = '2014-11-02 01:11:13 PM';
$result = $mandrill->messages->sendTemplate($template_name, $template_content, $message, $async, $ip_pool, $send_at);
print_r($result);
我想找到一个解决方案,但仍然没有希望。 (这是我第一次使用mandrill api)。我做错了吗?
答案 0 :(得分:1)
看起来您指定了subaccount
,但可能没有具有该名称的子帐户。请考虑删除您未实际指定的任何可选参数,以确保事情按预期工作。同样,您已经获得了预定的时间,附件和图片,但这些都是样本,因此您可能希望将它们排除在外。当您包含附件时,将异步处理该消息;删除样本将会出现更多错误,因为消息不应再异步处理。