WP Mail SMTP

This WordPress plugin reconfigures the wp_mail() function so all mail from your blog can be sent by SMTP instead of using PHP’s mail() function. The plugin also adds an Options > Email page which allows you to configure the settings from the admin interface of your site.

Download: Current Version: 0.8.2, Released 14/Dec/2008

WordPressMU

Since version 0.8, this plugin is WPMU compatible. I recommend setting your options as constants in wp-config.php (see line 19 in the plugin file). This will disable the options page, slightly improve performance, and apply the same settings across your entire WPMU site.

Troubleshooting

Could not connect to host

If you see an error like “Failed to connect to server”, the plugin is working, PHP cannot connect to the server. Look at the whole error message and investigate from there.Check your php.ini settings around fopen() permissions, check your SMTP host is correct, or contact your server administrator.

If your error is “Cannot connect to host”, please look for support elsewhere, please do not ask for support here. These questions have been asked many times before, please search the history. The plugin is working, the issue lies elsewhere.

Gmail / Google Apps

To send email via Gmail or Google Apps, use these settings:

Mailer: SMTP
SMTP Host: smtp.gmail.com
SMTP Port: 465
Encryption: SSL
Authentication: Yes
Username: your full gmail address
Password: your mail password

No email from plugins?

If you’re using plugins to send email, these plugins will ignore the SMTP settings if they call PHP’s mail() function directly. If you see the function mail() and not wp_mail() in the plugin’s source, that’s the problem. You should be able to simply add wp_ in front of the existing mail command and it will probably work! (Insert lawyer-speak no warranty blurb here!)

Other Problems

Try sending a test email. The error message should help you detect your problem.

Support: Post questions here

Changelog

0.8.2 – Bugfix, call phpmailer_init_smtp() correctly, props Sinklar.
0.8.1 Internationalisation improvements.
0.8 – Added port, SSL/TLS, option whitelisting, validate_email(), and constant options.
0.7 – Added checks to only override the default from name / email
0.6 – Added additional SMTP debugging output
0.5.2 – Fixed a pre 2.3 bug to do with mail from
0.5.1 – Added a check to display a warning on versions prior to 2.3
0.5.0 – Upgraded to match 2.3 filters which add a second filter for from name
0.4.2 – Fixed a bug in 0.4.1 and added more debugging output
0.4.1 – Added $phpmailer->ErroInfo to the test mail output
0.4 – Added the ability to send a test email
0.3.2 – Changed to use register_activation_hook for greater compatability
0.3.1 – Added readme for WP-Plugins.org compatability
0.3 – Various bugfixes and added From options
0.2 – Reworked approach as suggested by westi, added options page
0.1 – Initial approach, copying the wp_mail function and replacing it

76 Comments

  1. s1mone
    Posted 31 Aug 2007 at 12:34 | Permalink

    Oops… Something is wrong with the file! :)

  2. Posted 31 Aug 2007 at 13:43 | Permalink

    @s1mone: Woops, you’re dead right. I’ve updated the link, now it should download ok. Thanks for pointing that out.

  3. Posted 05 Sep 2007 at 11:00 | Permalink

    Hi there,
    Just the mod I’m looking for..

    What port have you used for SSL authenticated mail ?

    Trying to use it with gmail on smtp port 465

  4. Posted 05 Sep 2007 at 11:06 | Permalink

    @Dorian: I haven’t configured it to use SSL authenticated mail, although that does seem like a sensible option. I’ll look into adding those options.

  5. NetGirl
    Posted 05 Sep 2007 at 17:51 | Permalink

    Hello,

    This is the message I get when I hit the update button, no matter what the selection:

    “Cannot load wp_mail_smtp2Fwp_mail_smtp.php.”

    Please advise.

  6. Posted 05 Sep 2007 at 20:11 | Permalink

    @NetGirl: You get that message when you click “Update Options” right? That’s an error because of the way your data is submitted to WordPress. It could be a server or browser issue, but if your other options pages all work, I’m not sure what’s causing it. Can you give me a couple of screenshots? Are you running on Windows / Linux hosting? Anything else you think might be relevant?

  7. lynn
    Posted 05 Sep 2007 at 23:27 | Permalink

    I was hoping this would solve my problem, but no dice. I tried it with authentication and without and got nada.

  8. lynn
    Posted 05 Sep 2007 at 23:28 | Permalink

    Sorry, meant to add that I’m using WP 2.2.1

  9. Posted 05 Sep 2007 at 23:37 | Permalink

    @lynn: Can you give me a bit more info as to the problem? Are you seeing any error messages?

  10. lynn
    Posted 07 Sep 2007 at 15:11 | Permalink

    All:

    Callum is da man. He totally figured out what the problem was and then even helped me with another mail plugin that was having problems.

    Awesomely awesome and many thanks,

    lynn

  11. Posted 20 Sep 2007 at 00:19 | Permalink

    Cannot load wp_mail_smtp2Fwp_mail_smtp.php

    Could you share the solution with the rest of us?

  12. Draft
    Posted 22 Sep 2007 at 05:51 | Permalink

    Getting the same error

    IIs 6.0 / Windows 2003
    PHP 5

    Cannot load wp_mail_smtp2Fwp_mail_smtp.php

  13. Posted 22 Sep 2007 at 12:36 | Permalink

    @Draft, TopCat & NetGirl: I believe the problem was fixed in version 0.3.2. It was a bug to do with forward slashes on *nix and back slashes on Windows. Let me know if you have the same problem with 0.3.2 or later.

  14. Draft
    Posted 26 Sep 2007 at 12:10 | Permalink

    Sorry for the slow response.
    Yes, it still produces the same error on Windows Server:

    Running Ver. 0.3.2.
    Cannot load wp-mail-smtp2Fwp_mail_smtp.php.

  15. Posted 26 Sep 2007 at 22:42 | Permalink

    I also get that error on version 0.3.2 with WP 2.2.3.
    =====
    Cannot load wp-mail-smtp2Fwp_mail_smtp.php.
    =====
    It appears on IE7 and FireFox. Server is located on ovh.org but I am not sute what is the platform. I suppose that some linux distribution.
    The same error appeared on my own ubuntu-debian server.

  16. Posted 26 Sep 2007 at 22:47 | Permalink

    Mentioned error message appears but system sends emails correctly :)

  17. Posted 26 Sep 2007 at 22:53 | Permalink

    The error message cannot find “wp-mail-smtp2Fwp_mail_smtp.php” is a redirection bug in WordPress. It’s something in WordPress core.

    It should only appear when you click “Update Options”. The options are updated and saved, but the error message appears instead of being redirected to the correct page.

    Until the bug is fixed in WordPress core, users will have to put up with the problem I’m afraid. It’s purely cosmetic, the plugin still functions as it should do. Hopefully we’ll fix it in WordPress core soon. :)

  18. Posted 01 Oct 2007 at 18:26 | Permalink

    Hi there,

    I have read all of these comments and I can not seem to match them up with my issue. When I set the plugin to utilize SMTP, I get no emails whatsoever. I have tested it a variety of different ways:

    With From email, Empty From email, mail server named address, mail server IP address, with Auth, without Auth. And all combinations of the above. Nothing seems to work. I’m not sure where to look for errors but I noticed that there is NO attempt to login by the username I specified. Essentially, mail just stops working when I turn on SMTP. Any thoughts?

    PS – thank you for donating this plugin. It is very useful (or will be).

  19. Posted 05 Oct 2007 at 22:29 | Permalink

    0.3.2 seems to be working well with me on WP 2.3, including SMTP AUTH. But my host would like me to use TLS for added security. Would that be an easy thing to add, as a new feature? I suppose that depends whether PHPMailer supports TLS, and I can’t see any sign that it does.

  20. Posted 05 Oct 2007 at 22:47 | Permalink

    @Peter Kirk: I don’t think the PHPMailer class supports SSL. If you want SSL support the Swift SMTP plugin might work for you. It uses the newer SwiftMailer class which I believe does support SSL / TLS.

  21. Posted 05 Oct 2007 at 23:20 | Permalink

    Thanks, Callum. Unfortunately Swift SMTP doesn’t seem to be working for me, and there has been no response for several months to the thread in their support forum about the error I have encountered. I appreciate your much faster response!

  22. Posted 05 Oct 2007 at 23:46 | Permalink

    @Tai Graham: I’m not sure what’s causing the issue. It’s hard to debug the problem because there’s no error messages. I think it could be to do with security settings on your server that prevents PHP being able to open a remote connection. If that is the case, unless you can change server settings you won’t be able to send mail via SMTP. You could try the Swift SMTP plugin, if that doesn’t work, it’s probably a server problem.

  23. Posted 06 Oct 2007 at 12:17 | Permalink

    My host reminds me that using SMTP AUTH without TLS or SSL is a security problem as the password is transmitted across the Internet in plain text. That means that spammer who intercepts this password can hijack the SMTP server as a spam source. Not a good idea.

    My host also helped me discover my problem with Swift SMTP. I was asked to use TLS on port 25 of the host’s mailserver, a separate system from where my blog is hosted. But Swift has some deliberate code written so that if port 25 is selected the host name is set to “localhost” and TLS and SSL are disabled. My host tells me that although SSL should be on port 465, it is correct according to rfc2487 for TLS to be on port 25.

    One advantage of Swift is that it lets you send a test message and displays any error reports. You might want to add that facility as it would help you debug problems like Tai’s.

  24. Posted 06 Oct 2007 at 12:51 | Permalink

    @Peter Kirk: Thanks for posting back the details. That’s an interesting idea, sending a test mail, I think it would work. I tried adding a debugging option, but that doesn’t work.

    Who is your hosting company? They sound great!

  25. Posted 06 Oct 2007 at 15:27 | Permalink

    I tried Cimy Swift SMTP for WordPress, a variant of the other one I tried, and that seems to have solved my problem.

    My hosting is currently with BCISGnet, with whom I have a special non-commercial arrangement. They are very security conscious – as I need to be for some things I do, although not for my blog.

  26. Posted 07 Oct 2007 at 14:06 | Permalink

    I’ve added the ability to send a test email and released the updated plugin as version 0.4. I’ve updated the code on WordPress.org, so automatic updates should be notified in a day or two.

  27. Posted 11 Oct 2007 at 01:31 | Permalink

    Just downloaded and installed WP-Mail-SMTP 0.4 on 10/10/2007. I installed on Wordpress 2.3, configured for SMTP w/ Auth pointing to my hosting provider SMTP server and sent the test message smooth as grease. Thanks so much…

  28. Posted 11 Oct 2007 at 01:49 | Permalink

    Just a quick follow-up. I forgot to mention I’m running WordPress 2.3 locally on a laptop with Windows XP SP2, Apache 2.2.4, PHP 5.2.4 and MySQL 5.0.45. You’d stated you didn’t test the AUTH feature, so with this you’ll have an environment that you can certify as working…

  29. Posted 11 Oct 2007 at 05:15 | Permalink

    @Max: Great, thanks for the feedback, nice to know it’s working for you.

  30. smelmoth
    Posted 19 Oct 2007 at 18:19 | Permalink

    Hello and thanks for this plugin.
    When I try to send a test email I get:

    Test Message Sent

    The result was:

    bool(false)

    Any suggestions on how to troubleshoot this?

  31. Posted 19 Oct 2007 at 19:13 | Permalink

    @smelmoth: Try using version 0.4.1, I’ve added more debugging output to the test email function. Hopefully that will shed some more light on the problem.

  32. YikYak
    Posted 24 Oct 2007 at 18:03 | Permalink

    Hi,

    I was having terrible problems with WordPress just not sending any emails, then I came across your plugin. It seems to work (only just begun to test it), so thank you very much for that!

    I also get the cannot load message, but I also notice that the “From:” user I set in the options page is not being used. The options page displays it correctly, but still Wordpress is sending from the default user wordpress@domainname.

    Any ideas?

  33. Posted 24 Oct 2007 at 19:57 | Permalink

    @YikYak: Aha, there’s a change to the way the mail from is handled in WordPress version 2.3. I’ve updated the plugin to reflect the two new filters, it should work if you download the latest version (0.5.0). Let me know if you have any other problems.

  34. Posted 29 Oct 2007 at 09:26 | Permalink

    Great plugin Callum. I am going to try it out right now and provide a feedback once I am done molesting it :P

  35. Posted 25 Nov 2007 at 22:24 | Permalink

    Hi thanks for this plugin. I was really wondering what was wrong with my comment notifications. But when I installed this and set it to SMTP, it worked again.

    Thank you very much!

    Allen

  36. Posted 28 Nov 2007 at 06:08 | Permalink

    Thank you Callum! I have been going crazy all night trying to figure out why users aren’t getting registration or password retrieval e-mails (I’m on WP 2.3.1). Your plugin fixed my problem, but only if I specified an e-mail in the “From Email” field (Options->Email after activating the plugin). If I leave that field blank, the test e-mail fails.

  37. Posted 28 Nov 2007 at 09:17 | Permalink

    @Moncef: Check out your admin email, is that a valid email address? The plugin defaults to the admin email if you leave the From field blank, so perhaps that’s where the problem lies. If the test mail fails, you should get a pretty comprehensive debugging output from the PHPMailer class, which will hopefully shed some light on the problem.

    Bottom line, glad it’s working! :)

  38. Posted 29 Nov 2007 at 03:08 | Permalink

    hi Dear

    dos not Work??

    Why ?? why ??

  39. Posted 29 Nov 2007 at 04:08 | Permalink

    hi

    dose not work , Way??

    >>>>>>>>>>>>>>>>>if(function_exists(’load_plugin_textdomain’))
    load_plugin_textdomain(’wp-mail-smtp’,'wp-content/plugins/wp-mail-smtp’);<<<<<<<<>

    >> load_plugin_textdomain (plugin-name) <<

  40. Posted 29 Nov 2007 at 10:03 | Permalink

    @zxo003: That code does not appear within the WP Mail SMTP plugin. I’m guessing you’re using another plugin for language translation, as that code is also not in WP core. Try deactivating your other plugins and then see if WP Mail SMTP works on its own. If it does, re-activate your plugins one at a time to find the problem.

  41. Posted 30 Nov 2007 at 05:21 | Permalink

    hi

    thanks !! thanks !!

    bay

  42. Posted 03 Dec 2007 at 17:57 | Permalink

    Hi.
    I’ve got some problems with sending emails, so i tried your plugin.
    I’ve got installed it and after have configured all data, i test sending a mail but i’ve got an error :

    The result was:
    bool(false)

    And the “!” is on the line :

    ["SMTPKeepAlive"]=>
    bool(false)
    ! ["smtp"]=>
    &object(smtp)(6) {
    ["SMTP_PORT"]=>
    int(25)
    ["CRLF"]=>
    string(2) ”

    Please help me, i don’t know what to do.
    Thank you very much, and sorry for my english.

  43. Posted 03 Dec 2007 at 18:57 | Permalink

    @ADR: Can you post the error message line from the debug output? The error message will hopefully tell you where the problem lies.

  44. Posted 04 Dec 2007 at 20:01 | Permalink

    WOW.. Thank you. Yoru plugin worked !!

    I am not a PHP guru but as an engineer have good enough intutive skils to dig around code.

    How can I cutomize the emails that are being send with the user name & password.

    I just want to add some more welcome text to be polite rather tahn just the username & password. Where in the code can I do it ?

    Any help please

  45. Posted 04 Dec 2007 at 21:08 | Permalink

    @Henry: The plugin hooks into the function wp_mail(). So look for all instances of “wp_mail” in the code and you’ll find all the places where emails are sent. There may be a hook or filter you can use to change the text of the emails. If you’d like my professional help, contact me to discuss.

  46. Posted 15 Dec 2007 at 09:53 | Permalink

    I simply cannot get it to work. I have tried numerous settings and all test emails fail. bool(false)

    I even tried with the gmail smtp server and no dice:

    object(SMTP)#132 (6) {
    ["SMTP_PORT"]=>
    int(25)
    ["CRLF"]=>
    string(2) ”

    ["do_debug"]=>
    bool(false)
    ["smtp_conn"]=>
    bool(false)
    ["error"]=>
    array(3) {
    ["error"]=>
    string(27) “Failed to connect to server”
    ["errno"]=>
    int(111)
    ["errstr"]=>
    string(18) “Connection refused”
    }
    ["helo_rply"]=>
    NULL
    }

  47. Kurt
    Posted 21 Dec 2007 at 03:17 | Permalink

    I was having a problem with the Workpress site for my ADDON domain (only). Emails are not being received by those who register at my Wordpress blog. There are no errors in the registration process, and the new user appears in the Wordpress user admin panel. The email password is just not being sent. (I’ve tested with my own email accounts, and it’s not a spam issue).
    I created a wordpress@myaddondomain.com, and wordpress@myaddondomain.myprimarydomain.com , which was suggested on another site. Nothing worked.

    I added your plugin and LIFE IS SWEET. Thanks!

  48. Posted 08 Jan 2008 at 15:09 | Permalink

    Everything works fine except when the e-mail is sent it does not include a password or a verification link. So if I try to register with the test username and password I created earlier, it says invalid username or password.

    I too, love this plug in. I have wrestled for weeks with the php mail and accomplished nothing. I was so happy when my text came through – but alas no registration link or password.

    Can you help?

    Thanks so much

  49. Posted 08 Jan 2008 at 15:59 | Permalink

    @Carol: I’m not sure why the emails don’t include the links. Are they being sent without the links, or just not sent at all? It sounds like a WordPress problem, are you running the very latest version? Right now that’s 2.3.2.

  50. Igor
    Posted 09 Jan 2008 at 08:58 | Permalink

    I get the following error when sending emails from my home hosted wordpress:

    (host a.mx.mail.yahoo.com[209.191.118.103] refused to talk to me: 553 Mail from xx.xx.xx.xx not allowed – 5.7.1 [23] Connections not accepted from IP addresses on Spamhaus XBL; see http://postmaster.yahoo.com/550571-2.html [550])

    It looks like a spam issue and happens with gmail and yahoo recepients. Any ideas what’s going on?

30 Trackbacks

  1. [...] WP Mail SMTP replaces the in-built wp_mail() function with a duplicate function which uses SMTP to localhost instead of PHP mail. [...]

  2. [...] WP Mail SMTP replaces the in-built wp_mail() function with a duplicate function which uses SMTP to localhost instead of PHP mail. [...]

  3. [...] באו לקיצן בזכות התוסף WP Mail SMTP. התוסף מאפשר לבחור בשיטת שליחת הדוא”ל של מערכת [...]

  4. [...] Visit [...]

  5. [...] WP Mail SMTP replaces the in-built wp_mail() function with a duplicate function which uses SMTP to localhost instead of PHP mail. [...]

  6. By Jody Sachse - Wandering the Webernet on 10 Oct 2007 at 03:02

    [...] WP Mail SMTP replaces the in-built wp_mail() function with a duplicate function which uses SMTP to localhost instead of PHP mail. [...]

  7. By わーどぷれすっ! » WP Mail SMTP on 19 Oct 2007 at 14:50

    [...] WP Mail SMTP at Callum Macdonald [...]

  8. [...] but I’ve now got that straightened out with a (still slightly-buggy) plugin called WP Mail SMTP. I had to add my admin e-mail to the options for BlueHost’s PHP mail function to work [...]

  9. [...]   刚才开始用WP-Mail-SMTP,不知道是我的设置问题还是服务器问题,总是收到到邮件,到用的是126的SMTP,好像126不支持SMTP吧,不太清楚.后面看到一个插件,专门为GMAIL设计的,ShiftThis.net | Swift SMTP,就是它,在WordPress  下载了它的最新版本,然后设置为GMAIL ,然后Test Connection ,看了看邮箱,成功.不过ShiftThis.net | Swift SMTP文件比较大,有一M多,像国内下载的话很慢,有的时候根本就连接不上,还好,搞到了无界8.7 ,我就用无界作代理,下载下来了. [...]

  10. [...] Download it here. Configure it to use SMTP instead of the php_mail() function. [...]

  11. [...] soluciones para arreglar el problema del correo en Wordpress y terminé optando por el plugin WP Mail SMTP. Este plugin lo que hace es reconfigurar de manera correcta la forma en que Wordpress envía los [...]

  12. [...] que traía aparejado problemas en los envíos del correo desde este CMS. Solución, el plugin WP Mail SMTP, creado por Callum Macdonald, que nos cuenta que sirve justo para reconfigurar la función [...]

  13. [...] Neue Plugins im Einsatz:  Post Notification, Similar Posts, WP-Mail-SMTP [...]

  14. [...] after some time, I have found this wonderful plugin called “WP Mail SMTP”. With it, we can configure NOT to use sendmail, but instead use SMTP for sending mails. [...]

  15. By WP Plugin Archive » WP Mail SMTP on 19 Mar 2008 at 05:26

    [...] WordPress Plugin WP Mail SMTP von Callum Macdonald rekonfiguriert die  wp_mail() Function so das die Email des Blogs per SMTP [...]

  16. [...] released a new version of the WP Mail SMTP plugin. There were a stream of similar questions about one particular error message over the last few [...]

  17. By WP Mail SMTP v0.7 at Callum Macdonald on 03 May 2008 at 02:18

    [...] be sure to look back at previous questions before posting here. « Charles with Etihad [...]

  18. [...] 5.WP-Mail-SMTP:使wp支持smtp邮件的插件。 [...]

  19. [...] ist nicht unbedingt zwingend nötig. Alternativ könnte man die WordPress-Erweiterung WP Mail SMTP nutzen. Damit weist man WordPress an, für das Versenden der Mails keinen lokalen Mailserver [...]

  20. [...] downloading of plugin (WP-Mail-SMTP by the way), install it…. and then totally forget my mail server [...]

  21. [...] som trodde att det gick att registrera sig! Men icke, jag kunde bara skicka internt. Men hittade WP Mail SMTP tackar som f** för det. Så NU ska det fungera. Ni som har försökt att skapa en användare på [...]

  22. [...] WP-Mail-SMTP 如果你的免费空间或者虚拟主机没有SMTP服务,你可以安装这个插件来使用外部SMTP, [...]

  23. [...] מומלצת: כדאי לשלב ב-PN גם את התוסף WP Mail SMTP כי שימוש ב-PN בלבד מוסיף ל-Header של הדוא”ל שנשלח למנוי גם [...]

  24. [...] used WP-Mail-SMTP. It was simple to install, i.e. point and click and simple to configure. There is even a test [...]

  25. By » Blog Archive on 27 Sep 2008 at 02:33

    [...] por la web de la información, navegando buscando una solución. Así fue como descubrí un plugin Wp-Mail-Smtp que te envia los correos de wordpress a través de una cuenta externa. Después de navegar un rato [...]

  26. By Paula’s Page »  WP SMTP Mail on 25 Nov 2008 at 00:26
  27. By Moving Wordpress from Apache to IIS on 25 Nov 2008 at 18:05

    [...] WP-Mail-SMTP – This is very important, as it allows WordPress to send email For kiwihost you just need to set SMTP Host to “localhost” and Authentication to “No: Do not use SMTP authentication.” [...]

  28. [...] also installed the Subscribe To Comments and WP-Mail-SMTP plugins earlier this evening which allow readers to subscribe to new comments as well as manage [...]

  29. [...] WP-Mail-SMTP — позволяет отправлять письма через внешний SMTP-сервер По традиции в версии Normal всего два плагина — russian date и rus-to-lat [...]

  • Categories

  • History