wp_mail(Wordpress邮件功能)未发送到gmail或live.co.uk帐户 [英] wp_mail (Wordpress mail function) not sending to gmail or live.co.uk accounts

查看:180
本文介绍了wp_mail(Wordpress邮件功能)未发送到gmail或live.co.uk帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,访问者可以通过两种方式与我联系-通过其自己页面上的联系表和侧边栏中的"ajax"小联系表.

I have a website that allows visitors to contact me two ways - via a contact form on it's own page and via an 'ajax' small contact form in the sidebar.

两种联系方式都会向我的gmail帐户发送电子邮件.

Both forms of contact send an email to my gmail account.

在其自己的页面上的联系表单可以正常工作,但ajax表单不会发送至gmail(也不会发送至以.live.co.uk结尾的电子邮件地址)

The contact form on it's own page works fine but the ajax form doesn't send to gmail (nor does it send to email addresses ending in .live.co.uk)

如果我将ajax联系人表单上的收件人"地址更改为我的其他域之一(即其他电子邮件地址),那么它可以正常工作.

If I change the 'to' address on the ajax contact form to one of my other domains (i.e. a different email address) then it works fine.

我检查了已发送电子邮件的标头,并最终安装了一个插件",该插件会更改返回路径,以防万一Google(和live.co.uk)在接受电子邮件之前对其进行了检查.这没什么区别.

I've checked the headers of the emails that are sent and ended up installing a 'plugin' that alters the return-path in case Google (and live.co.uk) check this before accepting emails. This hasn't made any difference.

这些论坛和其他论坛上有很多关于不发送到gmail但没有实际解决方案的wp_mail的话题.

There is a lot of chatter on these forums and others about wp_mail not sending to gmail but no actual solution.

我已经检查了gmail垃圾邮件文件夹等,以防电子邮件进入其中,但是它们没有.

I've checked the gmail spam folders etc in case the emails went in there but they are not.

我也尝试仅使用'mail()'函数,但无济于事.

I've also tried using just the 'mail()' function but to no avail.

我在ajax调用转到的页面上的代码如下:

My code on the page that the ajax call goes to looks like this:

$headers  = 'From: myWebsite <enquiries@mywebsite.co.uk>' . "\r\n";
$headers .= 'Reply-To: myWebsite <enquiries@mywebsite.co.uk>';
$email_to = "myemailaddy@gmail.com";
wp_mail( $email_to , sanitize_text_field( $subjectLine ), wp_strip_all_tags( $emailContent ), $headers );
$email_to = "myemailaddy@anotherdomain.com";
wp_mail( $email_to , sanitize_text_field( $subjectLine ), wp_strip_all_tags( $emailContent ), $headers );

每次提交表单时,我都会将电子邮件发送到我的"anotherdomain.com"地址,而不是我的gmail.com地址.

Everytime the form is submitted I get the email to my 'anotherdomain.com' address but not to my gmail.com address.

有什么想法吗?

推荐答案

许多这类问题都涉及到电子邮件,而不是发送"到某些域.但是,很有可能没有收到该电子邮件. 未收到"并不等同于未发送",这是故障排除中的重要区别.

A lot of these types of questions involve email not "sending" to certain domains. However, it is more likely that the email is not being received. "Not received" does not mean the same as "not sent" and this is an important distinction in troubleshooting.

如果正在接收其他电子邮件地址,则可能是在您列出的接收主机上标记了您的邮件.

If other email addresses are receiving, then it is likely that something is flagging your message at the receiving hosts that you listed.

您可以做一些事情,以使您的电子邮件有更好的机会通过而不会被丢弃:

There are things that you can do to give your email a better chance of getting through without being dumped somewhere along the way:

  • 使用真实地址的发件人"地址. WP默认为wordpress@yourdomain.com.可以使用 wp_mail_from
  • 进行过滤
  • 将发送者"设置为发件人"地址.如果邮件标头的这两个元素不匹配,则某些垃圾邮件过滤器会将电子邮件拒绝为垃圾邮件.这里有一个简单的代码段即可完成.
  • 通过SMTP发送是最好的选择.您可以通过插件(在wordpress.org插件存储库中有多个插件)执行此操作,也可以
  • Use a "from" address that is a real address. WP default is wordpress@yourdomain.com. This can be filtered with wp_mail_from
  • Set the "sender" as the "from" address. Some spam filters reject email as spam if these two elements of the mail header do not match. There is a simple code snippet here that will do it.
  • Sending via SMTP is the best option. You can do this via a plugin (there are several in the wordpress.org plugin repository) or you can also set it up yourself using the phpmailer_init action.

这篇关于wp_mail(Wordpress邮件功能)未发送到gmail或live.co.uk帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆