WordPress教學 – eMail 設定

在WordPress 裡寄送Email的問題,讓我在程式裡卡了很久。實在是進退二難,如果最後弄不出來就用Ajax來解決,但Ajax又怕跟Server的連線還沒完成,User Redirect,不能確定這個情況下 email 有沒有被正確的寄出去。最後是用了  WooCommerce 3.0 + Postman SMTP Email Plugin 解決我在沒有multi-thread 的 php 架構裡,寄送 Email 造成 UI 會卡住的問題。

要記得把寄信給管理者的那個寄信用的Email,在信箱的設定裡加入為「聯絡人」,不然都要到「廣告信」裡去找Email.

資料來源:https://docs.woocommerce.com/document/email-faq/


WooCommerce, and most plugins sending email, send mail by using the wp_mail() function that is a core function of WordPress.

In most cases, if email is not being sent/received, then the issue is not with WooCommerce itself, but with the core email function on your web host. See the “How does email work with WordPress?” section below.

I am getting orders, but no emails are sending!

There are multiple factors that can be the cause. Before explaining the actual mail side of the issue, please ensure that it’s not one described below.

Check for Pending Orders

  • Your orders are pending. Pending orders are orders where the customer clicked “Place Order” but abandoned the payment page (depending on the payment gateway, i.e., PayPal) or had their credit card transaction declined. If you have pending orders, these orders will not generate emails.
  • You have pending orders but receive payment for them via a payment gateway such as PayPal, which requires a notice to update order status on your site. In this case, you are not looking at a email issue; you are looking at an issue with your payment gateway and may need to submit a support ticket.

Check your Email Settings

Orders that are properly updating to Processing should generate an email. Another possible issue is having mistakenly disabled emails from sending. Double-check that “Enable this email notification” is ticked for order notifications. This can be found under WooCommerce > Settings > Email and click on the “processing order” email template. An additional test should be setting the Email Type to Multipart.

Screen Shot 2016-07-21 at 3.37.30 PM

Your emails are broken

If emails are enabled and orders are updating to Processing, then there is most likely an issue in the email delivery to a recipient. This could be a spam blocker that classified your emails are spam and stopped them. The best way to resolve this is to sign up for an account with a dedicated SMTP provider, and an average site can usually stay within free usage accounts that are available.

How does email work?

Comparing a path an email takes to reach its destination vs. driving a car on a road trip, emails do not travel directly from point A to point B. The final destination is more like point W, and the email is bouncing from one server to another at the speed of light while being filtered at each step.

Google has put together this representation of the path an email follows. This story is specific to Gmail and delivering to a mobile device but helps explain how email works. Learn more.

How does email work with WordPress?

wp_mail() function

WooCommerce, and most plugins sending email, send mail by using the wp_mail() function that is a core function of WordPress.

Does that mean WordPress sends my email? Is WooCommerce sending the email?

Neither are sending the email. What happens is WooCommerce calls the wp_mail() function, which then requests WordPress to send the email. Because WordPress is not an email server, it typically asks PHP to send the email for it. PHP then checks for a local email server within the web server and tells that email server to send the email. Your email passes three steps before reaching your web server.

As of WooCommerce 3.0.0, a delayed CRON event is used to send emails.

If email is passed to my web server to be sent, how does a dedicated SMTP provider fit in?

By using a plugin the SMTP provider has available or the Postman SMTP plugin, the wp_mail() function reroutes the email from PHP to your SMTP provider. From there, the SMTP provider receives the request and adds your email to a queue to be sent.

What is a dedicated SMTP provider? Is that like my Gmail account?

A dedicated SMTP provider is like a web host in the sense that you have an account and use their servers. The difference is instead of hosting websites, you use their servers to send emails. Gmail is an email provider where you send and receive emails; a dedicated SMTP provider is similar to having half of Gmail, where you only send emails and not receive them.

Can I use Gmail as my SMTP provider?

Yes, but it is not ideal. Gmail will disable your account if you send emails to more than 500 unique recipients in an 24-hour period. This includes emails you send yourself and all emails your website is sending. Learn more.

Suggested Dedicated SMTP Providers

There are dedicated SMTP providers that will work for most websites. All have their own plugin on WordPress.org and can be installed from your WordPress dashboard, and have support available to help you get started.

  • SendGrid (Plugin) – Send 12,000 emails free per month. (這個規則改了,沒有這個好康)
  • Mailgun (Plugin) – Send 10,000 emails free per month.
  • SparkPost (Plugin) – Send 100,000 emails free per month. (這個顯示我所屬地區不能申請,可能需要用VPN連去米國試看看)
  • Mandrill (Plugin) – From MailChimp as a paid add-on. It costs $10/month for up to 25,000 emails. Emails are tracked and tagged for stats in the Mandrill Dashboard, and it can be used with MailChimp.

If emails are being blocked by spam filters, why is it not in my spam folder?

The spam filter is the last and final spam filter your email is filtered through, at which point it is going to spam based on your email client settings or how you mark other emails as spam. If your emails are denied by another spam filter before that, it simply is not delivered.

My contact form emails work, so why do WooCommerce emails get blocked?

Without deep investigation into server logs and tracking exact email paths, this is not a simple question to answer.

  • The short version is there is a lot more to spam filters than scanning for Nigerian Princes and typical spam. Spam filters check the IP address of origin, the sending user and domain, the amount of email that IP/sender has sent, how many times emails from that sender have been marked as spam, and the wording of emails.
  • The most common factor is where the email originates, which brings your overall score with spam filters down low enough that even minor differences in wording and formatting of WooCommerce emails may be flagged as spam and not sent.

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *