How to set up SMTP on Your WordPress Website

0
951
how to setup SMTP
how to setup SMTP

There is a lot of websites running at this time in the world. They have many options for contact with them. If you are a website owner, email sending functionality is very important for you. Because of that, you have to send an email to your clients, visitors or any others. In this article, I will show you how to set up SMTP on your WordPress website. Let’s begin…

What is SMTP?

If you want to setup SMTP, you have to know what is SMTP first. SMTP means Simple Mail Transfer Protocol. That means if you want to send an email you have to pass the Simple Mail Transfer Protocol. Otherwise, you can’t send any mail from the server. You may have a question of why you need to setup SMTP. Because of that, some hosting providers do not configure SMTP by default for you. That’s why you have to set up SMTP on your website.

How to set up SMTP?

You have know before setup SMTP on WordPress website that which script uses WordPress in there core file. By default WordPress uses Phpmailer for sending email. It’s a PHP script created by some creative guy. You have know about Phpmailer first. But I will tell you about simple way, so that you can set up SMTP on you WordPress website very easily.

Set up some code with WordPress hook.

Now go to your functions.php file which is located on your website root folder and open for editing. Write following code in your functions.php file. It will be set up your SMTP on your server.

 function simple_smtp_setup( $phpmailer ) {
	    $phpmailer->isSMTP();                        
	    $phpmailer->Host 		= 'smtp.gmail.com'; 
	    $phpmailer->SMTPAuth   	= true;
	    $phpmailer->SMTPAutoTLS = false; 
	    $phpmailer->Username   	= 'mddalwar9195@gmail.com';
	    $phpmailer->Password   	= '659195Dalwar';
	    $phpmailer->SMTPSecure 	= 'tls';
	    $phpmailer->Port       	= 587;
	    $phpmailer->setFrom('admin@anri.com', 'Md Dalwar');
    }

    add_action( 'phpmailer_init', 'simple_smtp_setup' );

Good news is that, you can send email using this code via local server like Xampp, Wampp etc. That’s why you need to use this configuration in your function file. If you are developing a WordPress theme, you can provide a simple plugin for your user. I will be publish a article about plugin development later.

So, I hope you have enjoyed this article, I will be back to you with another article. Bye…