
內容簡介
如果您的 WordPress 網站無法發送電子郵件,該怎麼辦呢?超過 6,000 個網站使用 Mail250 平台解決其電子郵件發送問題。
WordPress 使用者一般都會面臨郵件發送問題,這是因為 WordPress 預設使用的 wp_mail() 內部使用 PHP 的 mail() 函數,而這個函數會使用伺服器的 localhost 設定(即網站所在的主機)來發送電子郵件。由於大多數共享主機提供商為了保護其基礎架構免於遭受垃圾郵件攻擊,會阻擋傳送郵件的 SMTP 連接埠 25。為了解決這個問題,這個外掛使用 Mail250 的 SMTP 服務,而不是您的主機提供商的服務器設定。
Mail250 是一個 AI 驅動的大量電子郵件行銷服務。
Mail250 外掛使用 SMTP 整合來從 WordPress 安裝中發送外寄電子郵件。它替換了 WordPress 中包含的 wp_mail 函數。
在啟用此外掛後,若要使其運作,請前往外掛設置頁面並設置 Mail250 憑證。
如何使用 wp_mail() 函數:
我們已修改了 wp_mail() 函數,因此所有從 WordPress 發送的電子郵件都應透過 Mail250 進行發送。
您可以使用以下函數發送電子郵件:wp_mail($to, $subject, $message, $headers = '', $attachments = array())
其中:
$to – 要傳送消息的電子郵件地址的陣列或逗號分隔的列表。
$subject – 您的郵件主旨。
$message – 您的郵件正文 (HTML)。
$headers – 額外標題的陣列或 "\n" 分隔的清單。可選。
$attachments – 附加文件的陣列或 "\n" / "," 分隔的列表。可選。
wp_mail 函數預設發送純文字郵件。如果您想要發送具有 HTML 內容的郵件,您需要在呼叫 wp_mail() 函數之前使用 add_filter('wp_mail_content_type', 'set_html_content_type'); 函數設置內容類型為 "text/html"。
在 wp_mail 函數之後,您需要運行 remove_filter('wp_mail_content_type', 'set_html_content_type'); 以刪除 "text/html" 過濾器以避免發生衝突-參考自 https://core.trac.wordpress.org/ticket/23578
以下是如何使用不同標頭發送 HTML 郵件的示例:
$subject = 'Test Email via WP Mail SMTP plugin';
$message = 'Body of the test email sent using WP Mail STMP WordPress plugin';
$to = '[email protected], Recipient Name <[email protected]>';
或
$to = array('[email protected]', 'Recipient Name <[email protected]>');
$headers = array();
$headers[] = 'From: Sender <[email protected]>';
$headers[] = 'X-Your-Custom-Header: YourCustomeHeaderValue';
$attachments = array('/tmp/img1.jpg', '/tmp/img2.jpg');
add_filter('wp_mail_content_type', 'set_html_content_type');
$mail = wp_mail($to, $subject, $message, $headers, $attachments);
remove_filter('wp_mail_content_type', 'set_html_content_type');
數據和隱私
您的郵件將透過 Mail250-第三方 AI 驅動的郵件傳送平台進行發送。有關詳細信息,請參閱 Mail250 隱私政策 和條款。
外掛標籤
開發者團隊
② 後台搜尋「Free WP Mail SMTP (Official – 2019)」→ 直接安裝(推薦)
原文外掛簡介
Having problem with your WordPress site not sending emails? over 6k websites use Mail250 platform to fix their email delivery issues.
WordPress users face this chronic email delivery problem due to the fact that by default WordPress website uses wp_mail() which internally uses PHP’s mail() function, which uses server’s localhost configuration (on which website is hosted) to send emails. The default configuration won’t work as most of the shared hosting providers blocks outgoing SMTP ports 25 to protect their infrastructure from spam. This plugin fixes this problem by using Mail250 SMTP services instead of your hosting provider’s server settings.
Mail250 is an AI-Driven Bulk Email Marketing Service
The Mail250 plugin uses SMTP integration to send outgoing emails from your WordPress installation. It replaces the wp_mail function included with WordPress.
To have the mail250 plugin running after you have activated it, go to the plugin’s settings page and set the mail250 credentials.
How to use wp_mail() function:
We amended wp_mail() function so all email sends from WordPress should go through Mail250.
You can send emails using the following function: wp_mail($to, $subject, $message, $headers = '', $attachments = array())
Where:
$to – Array or comma-separated list of email addresses to send message.
$subject – Your email subject
$message – Your email body (HTML)
$headers – Array or “\n” separated list of additional headers. Optional.
$attachments – Array or “\n”/”,” separated list of files to attach. Optional.
The wp_mail function is sending text emails as default. If you want to send an email with HTML content you have to set the content type to ‘text/html’ running add_filter('wp_mail_content_type', 'set_html_content_type'); function before to wp_mail() one.
After wp_mail function you need to run the remove_filter('wp_mail_content_type', 'set_html_content_type'); to remove the ‘text/html’ filter to avoid conflicts –https://core.trac.wordpress.org/ticket/23578
Example about how to send an HTML email using different headers:
$subject = 'Test Email via WP Mail SMTP plugin';
$message = 'Body of the test email sent using WP Mail STMP WordPress plugin';
$to = '[email protected], Recipient Name
or
$to = array('[email protected]', 'Recipient Name
$headers = array();
$headers[] = 'From: Sender
$headers[] = 'X-Your-Custom-Header: YourCustomeHeaderValue';
$attachments = array('/tmp/img1.jpg', '/tmp/img2.jpg');
add_filter('wp_mail_content_type', 'set_html_content_type');
$mail = wp_mail($to, $subject, $message, $headers, $attachments);
remove_filter('wp_mail_content_type', 'set_html_content_type');
Data & Privacy
Your emails will be sent via Mail250 – a third party AI based email delivery platform. For details please refer to Mail250 Privacy and Terms
