Hi there! Another blog that I hope can be of help. In this article, we will be using XAMPP as our local webserver. If you don’t have this software yet, you can go to apachefriends.org/index.html. I recommend to download the latest version of PHP. Cheers!
1. Open XAMPP directory. C:\xampp
2. Go to C:\xampp\php and open the php.ini file. Or you could open the XAMPP control panel, click on “Config” button at the Apache column, then click on php.ini
3. Find or search the following lines then configure
- line 1084: SMTP=smtp.gmail.com
- line 1086: smtp_port=587
- line 1090: sendmail_from = firstname.lastname@example.org
- line 1094: sendmail_path =”\”C:\xampp\sendmail\sendmail.exe\” -t”
If they have a semicolon “;” before the words, remove it. Save the file, exit.
4. Now, go to C:\xampp\sendmail and open sendmail.ini file.
5. Find or search the following then configure
if they have a semicolon “;” before the words, remove it. Save the file, exit.
6. Every time you configure your php.ini file, restart Apache for it to take effect. By restarting, it doesn’t mean exiting the controller then opening it again.
7. Go to the controller, click the stop button, wait for it to become “Start”, then click on it again hehehe restart.
8. Or you know, you can quit the whole controller then open everything again. It’s your choice really. Quit button? Yes, not the “X” at the top right.
After all that shinanigans, lol, now we test it. Below are sample snippets on how to send emails using WordPress
How To Send Email In WordPress
<?php $subject = 'ARK Web Creatives - How to Send Email in WordPress using Localhost'; // Receiver of the email $to = 'email@example.com'; // Sender of the email $from_name = 'From: firstname.lastname@example.org'; $reply_to = 'Reply-To: email@example.com'; // This is to make sure that the email will be using HTML to display the body content. $head = 'Content-Type: text/html; charset=UTF-8'; // Header of the email $head .= $from_name.' <'.$from_email.'>'.$reply_to; $head .= 'X-Mailer: PHP/' . phpversion(); // Since we setup the header to use html, we can now add the body like this $email_body = '<h1>Welcome!</h1><br><p>I hope you learned something in this short article.<br> Good luck!</p><br><br>'; $email_body .= 'Yours truly,<br>Ryner Galaus | AWC'; wp_mail( $to, $subject , $email_body, $head ); ?>
That’s all for this post. Again, if you find this article informative or interesting, you can share it with your fwends. hihi
If you have any suggestions or comments regarding this article or if you have any topic you’d like to ask, comment below. Let’s be friends! haha
If you are building your own website or you are creating for someone else, and you happen to be looking for a hosting provider. I would like to recommend Hostinger. Cheers!