Mohamed Ali O.Ameur
Mohamed Ali O.Ameur

Reputation: 733

How to use a custom SMTP settings in my WordPress site

I need to use custom SMTP settings for my WordPress site to send email through my email servers such as Mailgun or SendGrid.

Upvotes: 0

Views: 619

Answers (1)

Mohamed Ali O.Ameur
Mohamed Ali O.Ameur

Reputation: 733

Place this in your theme function.php or your own plugin.

add_action( 'phpmailer_init', 'custom_phpmailer_init' );
function custom_phpmailer_init( $phpmailer ) {

    $phpmailer->isSMTP();
    $phpmailer->Host = 'smtp.mailgun.com';
    $phpmailer->Port = 465;
    $phpmailer->Username = 'user_name';
    $phpmailer->Password =  '********';
    $phpmailer->SMTPAuth = true;
    $phpmailer->SMTPSecure = 'ssl';
    $phpmailer->From       = '[email protected]';
    $phpmailer->FromName   = 'FromName';

}

Upvotes: 1

Related Questions