gpt4 book ai didi

Drupal_mail() 正文为空且没有主题

转载 作者:行者123 更新时间:2023-12-03 09:27:02 25 4
gpt4 key购买 nike

我在使用 drupal_mail() 时遇到问题。我收到电子邮件,但主题和正文为空。

Drupal 版本 7

下面的代码

$params = array(
'subject' => t('Client Requests Quote'),
'body' => t("Body of the email goes here"),
);
drupal_mail("samplemail", "samplemail_html_mail", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcb9b1bdb5b09cb9b1bdb5b0f2bfb3b1" rel="noreferrer noopener nofollow">[email protected]</a>", language_default(), $params, "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5e3b333f37321e3b333f3732703d3133" rel="noreferrer noopener nofollow">[email protected]</a>", TRUE);

我什至用下面的钩子(Hook)尝试过,得到了相同的结果。

function hook_mail($key, &$message, $params) {
switch ($key) {
case 'samplemail_html_mail':
/*
* Emails with this key will be HTML emails,
* we therefore cannot use drupal default headers, but set our own headers
*/
/*
* $vars required even if not used to get $language in there since t takes in: t($string, $args = array(), $langcode = NULL) */
$message['subject'] = t($params['subject'], $var, $language->language);
/* the email body is here, inside the $message array */
$body = "<html><body>
<h2>HTML Email Sample with Drupal</h2>
<hr /><br /><br />
{$params['body']}
</body></html>";
$message['body'][] = $body;
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
break;
}
}

drupal_mail_system() 可以工作,但它以纯文本形式出现。

最佳答案

在你的模块中你不应该使用 hook_mail 它应该是 <MODULE_NAME>_hook() .

改变

function hook_mail($key, &$message, $params) {

function samplemail_mail($key, &$message, $params) {

关于Drupal_mail() 正文为空且没有主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18306832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com