Like many other scripts, WordPress also uses PHPmailer to send transactional emails. If no email is set for sending emails, WordPress will use the default cPanel email account ([email protected]) which isn’t pretty.
SMTP (Simple Mail Transfer Protocol) is an industry-standard for sending emails. Proper SMTP configuration helps increase email deliverability by using authentication.
To specify which email account WordPress should use for sending all emails you need to add the login credentials for an email account either in code (your theme’s functions.php file or create a new plugin) or use an existing plugin such as WP Mail SMTP by WPForms.
To set SMTP from email in WordPress you need the following information:
- Server address (e.g. gmail.com)
- Username – email address
- Password
- Port (usually 25, 587 or 465 – ask your hosting provider)
- SMTP Connection type: TLS or SSL
In cPanel you can see this information Under Email Accounts > Connect Devices

Under the Secure SSL/TLS Settings (Recommended) section there is also a link to the Non-SSL Settings (NOT Recommended):

To use Secure SSL/TLS Settings in your WordPress site you can add the following code:
add_action( 'phpmailer_init', 'setup_phpmailer_init' );
function setup_phpmailer_init( $phpmailer ) {
$phpmailer->Host = 'smtp.example.com';
$phpmailer->Port = 587; // set the appropriate port: 465, 2525, etc.
$phpmailer->Username = '[email protected]';
$phpmailer->Password = 'yourpassword';
$phpmailer->SMTPAuth = true;
$phpmailer->SMTPSecure = 'tls'; // preferable but optional
$phpmailer->From = "[email protected]";
$phpmailer->FromName = "Your Name";
$phpmailer->IsSMTP();
}
Another option is to use a WP plugin that will allow you to set login information directly from wp-admin.
I recommend WP Mail SMTP by WPForms:
WP Mail SMTP plugin works with all major email services such as Gmail, Yahoo, Outlook, Microsoft Live, and any other email-sending service that offers SMTP.
From the plugin settings you can set the following options:
- Specify an SMTP host.
- Specify an SMTP port.
- Choose SSL / TLS encryption.
- Choose to use SMTP authentication or not.
- Specify an SMTP username and password.
