Send mail through Wordpress (without using SMTP plugins)

Posted: 2015-08-21 00:48:39

WordPress itself does not provides SMTP settings to configure in the admin area.

But there are two ways that you can send mail from WordPress:

  1. By using plugins that set up SMTP connections to outside mail servers.
  2. Or by using WordPress’ internal wp_mail() function, which defaults to using PHP’s mail() function, fully relying on PHP’s settings to handle mail.

To send mail via wp_mail(), WordPress uses an internal PHPMailer class which sets some default values.

The included PHPMailer class defaults to using PHP’s mail() function, but can also instead connect to your mail account (e.g., gmail) directly.

To use the mail() function, you’ll need to enable and configure MSMTP to establish a local SMTP proxy/forwarding to a real mail server or mail account (such as gmail).

Then edit file –


public $From = 'root@localhost';
public $Host = 'localhost';
public $SMTPAutoTLS = true;


public $From = '';
public $Host = '';
public $SMTPAutoTLS = false;

The above settings is for a local SMTP proxy such as MSMTP or for a local SMTP server.

If you want to connect to gmail directly, change “$Mailer” to “SMTP” and update settings accordingly.

Debugging SMTP Issues

Check the website’s HTTP and PHP error log files, and the general PHP error log file for logged PHP errors.

Check PHP’s mail() function log and MSMTP’s log file to make sure that email is not being rejected because the header/from is invalid.

PHP mail log – C:\WampDeveloper\Logs\Php\maillog.txt

MSMTP mail log – C:\WampDeveloper\Tools\msmtp\msmtplog.txt