Tutorial – Sending email from WordPress using Google Gmail

This tutorial covers how you easily can modify your WordPress installation to send email with a Google Gmail account instead of sending through your webserver. Only ONE file needs to be modified. You also need to have a working WP-installation and a Gmail-account.

Step 1
Open the file ”wp-includes/class-phpmailer.php” (which is the class that sends email in WordPress) in your favourite text-editor.

Step 2
Find and modify the following properties.

var $Mailer = ‘smtp’;
var $Host = ‘smtp.gmail.com’;
var $Port = 465;
var $SMTPAuth = true;
var $Username = ‘your_username@gmail.com’;
var $Password = ‘your_gmail_password’;

Step 3
Find the the method ”IsMail” (in the same file) and comment out one row of code like this:

function IsMail() {
//$this->Mailer = ‘mail’;
}

All steps complete!

This should work with all WordPress versions that uses a version of the phpMailer-class that is Gmail compatible.

Tested in WordPress v 2.7

LOOK HERE
I don’t use this method any longer because I don’t want to touch the core-files of wordpress. It is a bad habit to do so, because they get overwritten each time you update wordpress. There is a plugin called XPertMailer that can send email through gmail. Use that one instead!

3 Comments

chris  on april 3rd, 2009

Forgot one:
var $SMTPSecure = ”ssl”;

Sweet Baby Girl  on juli 28th, 2009

it didn’t work for me :(

does it work on 2.8.2 WP?

PicZasso  on september 2nd, 2009

Nice post! Great tutorial!

Leave a Comment