PHPMail is the default function used by WordPress to send email e.g. to notify you of a new comment or to send you a message posted via a contact form. However, many hosting providers are now disabling the use of PHPMail on their shared hosting servers for security reasons – usually because loads of spam mail is being sent out from the server using spamming scripts with the help of the PHPMail function.
Instead, they may require you to use SMTP authentication to continue to allow WordPress to send out emails – and if you don’t change then WordPress email delivery will fail.
It is possible to force WordPress to use SMTP mail by editing core .php files but this is not easy and it would help if you had some coding knowledge – a much simpler method for most WordPress users is to add the WP Mail SMTP plugin.
How To Use WP Mail SMTP Plugin – Download the plugin from WordPress here and install it to your WordPress site as usual then activate the plugin. In the WordPress ‘Settings’ menu you should see a new option of ‘Email’ – click on this to enter the ‘Advanced Email Options’ window and configure as follows:
- In the top section, fill in the email address and name that you want emails to be sent from
- Ensure that ‘Send All Emails Via SMTP’ is selected – this is the most important step (it should already be selected by default)
- Tick the ‘Return Path’ box if you want the return path of emails sent from WordPress to match the email address you put in ‘From Mail’ above – in most cases you would want to do this
Now fill in the rest of the ‘SMTP Options’ below (these settings should work for most users – if you are unsure, confirm them with your hosting provider):
- Type in your SMTP host name (your domain mail server or SMTP server for external email account e.g. Gmail if you use it)
- Set the SMTP port to 465 (for secure SMTP)
- Set encryption to ‘Use SSL encryption’
- Set authentication to ‘Yes: Use SMTP authentication’
- Now type in your email username and password (same domain as your SMTP host name above e.g. this could be your domain email account or Gmail etc if you have external email).
- Click the Save Changes button
To send yourself a Test Email to check if it works just type in your own email address and click ‘Send Test’. If everything is working right you should get the message ‘Your message was sent successfully’ – you are now using SMTP authentication instead of PHPMail for your email in WordPress :-)
If it doesn’t work, double check all the settings. If you were using Gmail etc try changing the settings to use your own domain email account and server name then retest – if it still fails then contact your web hosting provider to confirm specific settings for your email system and use those.
4 thoughts on “Use SMTP Mail Instead Of PHPMail On WordPress”
I just solved the smtp send mail problem from wordpress using a little bit coding. I didn’t used any plugin and didn’t found any configuration setting in wordpress for SMTP (I am new in WP). I did it for my gmail account.
Here is the code snippet which I placed just bellow line no. 405 (with the content “$phpmailer->IsMail();”) and in the function “wp_mail” in wordpress_installation_folder/wp-includes/pluggable.php file.
$phpmailer->SMTPAuth = true;
$phpmailer->IsSMTP(); // telling the class to use SMTP
$phpmailer->Host = “ssl://smtp.gmail.com”; // SMTP server
$phpmailer->Username = ‘[email protected]’;
$phpmailer->Password = ‘placed_my_password_here’;
$phpmailer->Port = 465;
It worked fine for me and definitely will work for you, too.
But my question is that, Is there any setting already for SMTP in the wordpress admin panel? Can anyone tell me plz?
Unfortunately there is no setting for SMTP in the WordPress admin panel – therefore the plugin (or a code snippet like yours) is required if you want to force SMTP for better security
“you are now using SMTP authentication instead of PHPMail for your email in WordPress” Not true – you’ve only used the wp-admin plugin form to send a test email – but mail() does not utilize this plugin, and wp_mail() is not found. (Call to undefined function wp_mail() ).
Hi Hugh, not sure whether you have a specific issue with your theme or plugins? ‘SMTP email in WordPress’ covers core WordPress, not extra plugins people may have added.
A plugin that calls mail() directly will still use PHPMail but you could edit the plugin or replace it to use SMTP instead. For a contact form ‘Fast Secure Contact Form’ works well with this plugin.
Comments are closed.