PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, July 7, 2022

[FIXED] How to use a custom SMTP settings in my WordPress site

 July 07, 2022     email, mailgun, phpmailer, smtp, wordpress     No comments   

Issue

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


Solution

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';

}


Answered By - Mohamed Ali O.Ameur
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing