使用联系表单发送的电子邮件显示管理员“来自”地址,而不是访客的电子邮件

发布于 2024-09-11 17:44:00 字数 851 浏览 4 评论 0原文

此页面使用 Drupals 联系表单发送电子邮件: http://www.westlake.school.nz/contact< /a>

问题是,学校工作人员使用 Outlook。当他们收到来自父母等的电子邮件时,电子邮件的格式为

“发件人:[电子邮件受保护] 代表 西湖男子高中”

在 Gmail 中正确输入,例如

来自西湖男子高中 [电子邮件受保护]

不幸的是,我无法告诉整个学校工作人员停止使用展望与交流。

可以改变 Drupals drupal_mail 函数来解决这个问题吗?

来自 contact.pages.inc:

drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);

This page uses Drupals contact form to send emails: http://www.westlake.school.nz/contact

Problem is, the school staff use outlook. When they recieve email from parents etc, the email comes in as

"From: [email protected] On Behalf Of
Westlake Boys High School"

In Gmail it comes in correctly such as

from Westlake Boys High School
[email protected]

Unfortunately, I cannot tell the entire school staff to stop using Outlook and exchange.

Can Drupals drupal_mail function be altered in order to fix this?

From contact.pages.inc:

drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);

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

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

发布评论

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

评论(1

单身狗的梦 2024-09-18 17:44:00

tmsimont 对此 URL 进行了解释 (http://api.drupal.org/api/函数/drupal_mail#comment-3243

$from 参数只会改变
来自标头,而不是发件人,错误至
或返回路径。

contact_mail_page_submit 使用的 drupal_mail 函数。

更多详细信息(来自 drupal_mail() 函数的代码)

line 3 - $default_from = variable_get('site_mail', ini_get('sendmail_from'));

line 9 -     'from'     => isset($from) ? $from : $default_from,

line 23 -  if ($default_from) {
line 24 -    // To prevent e-mail from looking like spam, the addresses in the Sender and
line 25 -    // Return-Path headers should have a domain authorized to use the originating
line 26 -    // SMTP server. Errors-To is redundant, but shouldn't hurt.
line 27 -    $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
line 28 -  }
line 29 -  if ($from) {
line 30 -    $headers['From'] = $from;
line 31 -  }
line 32 -  $message['headers'] = $headers;

因此,为了解决您的问题,您可以实现 hook_mail 函数(http://drupal.org/node/358855#comment-2079266)

更多资源可以在这里找到:

1 - http://drupal.org/node/656472

2 - http://drupal.org/node/861562

3 - http://www.nmglc.co.uk/content/overriding-drupals-mail-function

tmsimont explains on this URL (http://api.drupal.org/api/function/drupal_mail#comment-3243) that

the $from parameter will only alter the
From header, not the Sender, Errors-to
or Return-Path.

of the drupal_mail function that is used by contact_mail_page_submit.

with more details (code from the drupal_mail() function)

line 3 - $default_from = variable_get('site_mail', ini_get('sendmail_from'));

line 9 -     'from'     => isset($from) ? $from : $default_from,

line 23 -  if ($default_from) {
line 24 -    // To prevent e-mail from looking like spam, the addresses in the Sender and
line 25 -    // Return-Path headers should have a domain authorized to use the originating
line 26 -    // SMTP server. Errors-To is redundant, but shouldn't hurt.
line 27 -    $headers['From'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
line 28 -  }
line 29 -  if ($from) {
line 30 -    $headers['From'] = $from;
line 31 -  }
line 32 -  $message['headers'] = $headers;

So to solve your problem you could implement hook_mail function (http://drupal.org/node/358855#comment-2079266)

More resources can be found here:

1 - http://drupal.org/node/656472

2 - http://drupal.org/node/861562

3 - http://www.nmglc.co.uk/content/overriding-drupals-mail-function

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