Integrating SMTP into WordPress Without Using a Plug-in

The wp_mail function is implemented using the PHPMailer class to send emails. By default, there is a hard coded $phpmailer->IsMail(); function call that enables the PHPMailer class to use native PHP mail function. This is why, the wp_mail function ultimately use PHP mail functions to send emails.

You can also setup PHPMailer to send email through SMTP using the phpmailer_init action. In this article, you will learn a simple way to integrate SMTP into WordPress without using any plug-in. The phpmailer_init action calls right before sending an email so that you can override all the parameters and functions associated with PHPMailer. You just need to pass PHPMailer object to the function and update all the parameters there.


User Comments

3 thoughts on “Integrating SMTP into WordPress Without Using a Plug-in

    Serdar says:


    Should add I this code to functions.php of theme?

    Help me please!

      Hello Serdar,

      Yes, you have to put this code in your theme’s “function.php” file and write your details accordingly. And then call it in “phpmailer_init” WP action hook.

      Thank you for contacting us. Please let us know if you need any further assistance.

      Ahmed | Associate Plugin Developer

Leave a Reply

Your email address will not be published. Required fields are marked *

Get in Touch