Using WordPress With External SMTP Server

I really don’t like having sendmail running on a webserver, but some features of WordPress just don’t work if it can’t send email (user registration, for example). Still, WordPress offers support to send email through external SMTP servers instead if a local mailer.

In /wp-includes/pluggable.php around line 377, change

	$phpmailer->isMail();

to

	$phpmailer->isSMTP();

Then, in /wp-includes/class-phpmailer.php around line 155, set your SMTP host:

    var $Host        = "my.smtphost.com";

You may also need to set a username and password, and tell WP to attempt authentication. You’ll see those in the lines below the hostname variable.

    var $SMTPAuth     = true;
    var $Username     = "username";
    var $Password     = "password";

On the other hand, you could do this via a plugin, perhaps even Callum McDonald’s WP Mail SMTP.

17 thoughts on “Using WordPress With External SMTP Server

  1. Pingback: A Life of Constant Flux » Blog Archive » Installing LAMP and Wordpress on Slicehost (or elsewhere) Redux

  2. Thanks for your help! I found a class-smtp.php in the named directory, so I guess that’s the one to use for SMTP configuration, isn’t it!? (WordPress version 2.3.3)

    • Oh I see – it should be class-phpmailer, as you said. Yet I’m actually wondering why one wouldn’t edit class-smtp for SMTP settings!? Anyways – never mind. Maybe this comment is a hint for other users.

  3. Thanks for sharing that with us. I did thsi to my WAMP server a couple of months ago. Then I did an upgrade to the latest version of wordpress and didn’t think put the SMTP mods back in place… doh!

  4. Works perfectly! Thanks.

    I’ve been having problems with my hosting’s sendmail and wanted to switch to gmail for notifications. Your post was all I needed to make the switch.

    Great Job!

  5. Pingback: SMTP is up and running

  6. Pingback: Using WordPress With External SMTP Server « PlanetMaks

  7. Pheew!

    After loosing my password and noticing my email configuration was crap, I though I had to reinstall wordpress from scratch! Your post helped me recover my password :)

    Thank you!

Comments are closed.