简体   繁体   中英

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.

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       = 'FromName@example.com';
    $phpmailer->FromName   = 'FromName';

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM