[英]WAMP / Drupal 7 / SMTP module : Can't send mail with drupal_mail, but “testing mail” can send
I set up, with a Gmail account (smtp.gmail.com:465). 我使用Gmail帐户(smtp.gmail.com:465)进行设置。
I'm using the SMTP module , and after setup, I can (ie have no problem with Gmail) send the "test e-mail" it offers in the admin page. 我正在使用SMTP模块 ,设置后,我可以 (即Gmail没问题)发送它在管理页面中提供的“测试电子邮件”。
However, trying to call this function: 但是,尝试调用此函数:
drupal_mail('casabaca_s3s', FORM_ALIAS_CONTACTO, 'luisfmasuelli@gmail.com', language_default(), array());
which is implemented here (hook impl.): 在这里实现(钩实现):
function casabaca_s3s_mail($key, &$message, $params)
{
$data = array();
foreach($params as $k => $v)
{
$data['${'.$k.'}'] = $v;
}
$messages = array(
FORM_ALIAS_CONTACTO => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
FORM_ALIAS_COTIZAR => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
FORM_ALIAS_TALLERES => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
FORM_ALIAS_EXONERADOS => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
FORM_ALIAS_AVALUO => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
FORM_ALIAS_MANTENIMIENTO => array(
'subject' => '',
'html.message' => <<<MESSAGE
MESSAGE
),
);
$base_message = $messages[$key];
$message['body']['plain'] = '<html><body>HTML version of "test message"</body></html>'; //drupal_wrap_mail(drupal_html_to_text(strtr($base_message['html.message'], $data)));
$message['body']['html'] = 'text version of "test messages"'; //drupal_wrap_mail(strtr($base_message['html.message'], $data));
$message['subject'] = 'test subject';//$base_message['subject'];
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'multipart/alternative; charset=UTF-8;',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal'
);
foreach ($headers as $key => $value) {
$message['headers'][$key] = $value;
}
}
doesn't work . 不起作用 。 The returned message comes as follows:
返回的消息如下:
No se pudo enviar el correo electrónico.
没有任何帮助。 Contacte con la administración del sitio si persiste el problema.
持续存在的行政管理联系方式。
(message in Spanish. possible English message could be - I don't know since I'm a total n00b and just using a Spanish Drupal 7 version -: E-mail couldn't be sent. Contact with site administration if the problem persists). (西班牙语消息。可能的英语消息可能是-我不知道,因为我总共是n00b,仅使用西班牙语Drupal 7版本-:无法发送电子邮件。如果问题仍然存在,请与网站管理联系)。
Q: What am I screwing? 问:我在拧什么? Hypothesis: I think it's in my code, but I copied most of it and try to understand it
假设:我认为它在我的代码中,但是我复制了其中的大部分并试图理解它
Goal : send a multiple alternatives email ( please note, currently the options are just a stub, and not implemented ), depending on six possibilities (each responding to a different form, a different feature, but currently they have dummy body and subject). 目标 :发送多种替代电子邮件( 请注意,当前这些选项只是一个存根,尚未实现 ),具体取决于六种可能性(每种响应的形式,功能不同,但当前具有伪造的主体和主题)。
Preconditions: Drupal 7, PHP 5.4.16, SMTP module 7.x-1.0. 前提条件:Drupal 7,PHP 5.4.16,SMTP模块7.x-1.0。
Edit : For those not being sure what the "test e-mail" is, see Here for a detailed example. 编辑 :对于那些不确定“测试电子邮件”是什么的人,请参见此处获取详细示例。
Found it ... had many problems. 发现它...有很多问题。
(summary: a 8th-layer error). (摘要:第8层错误)。
In some cases problem might be in the mail_system
variable. 在某些情况下,问题可能出在
mail_system
变量中。 It should be set to SmtpMailSystem
. 它应该设置为
SmtpMailSystem
。 Some modules like Mail System or Mime Mail change it. 某些模块(如邮件系统或Mime Mail)会对其进行更改。
See also drupal_mail_system and drupal_mail . 另请参阅drupal_mail_system和drupal_mail 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.