Jump to content

HOW TO: sendmail setup with smtp.gmail for local web development


OrganizedFellow
 Share

Recommended Posts

I've spent two days trying to get my Windows 10 WAMP server setup to send the confirmation email generated by Ryans LoginRegister Module.

It's a fine Module and I struggle with PHP and coding in general. BUT TODAY, I finally set it up and here is my HOW TO GUIDE for the community so no one else has to struggle as much as I did ? 

STEP #1: download the sendmail executable here https://www.glob.com.au/sendmail/

STEP #2: extract all the files anywhere you like. I chose, 'C:\Users\orgfel\www\_sendmail'.

STEP #3: open and edit 'sendmail.ini', insert the following with your credentials:

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=YourGmailUser@gmail.com
auth_password=YourGmailPass
smtp_ssl=ssl
default_domain=localhost
hostname=localhost

I have 2-Step Verification set up for my Gmail account. 

I was incredibly frustrated when I kept trying to configure the module WireMailSmtp to send a test email and it continued to fail. The prompt kept saying I had the wrong password. I KNEW I did not have the wrong Gmail password and it was driving me nuts! 

I discovered that I needed an App Password ( Sign in using App Passwords). There's a generator process what give you a 16 character password that you put into your 'sendmail.ini'.

STEP #4: open and edit 'php.ini', insert the path to where you put your 'sendmail.exe':

sendmail_path = "C:\Users\orgfel\www\_sendmail\sendmail.exe -t"

STEP #5: restart your Apache server and it should be working!

STEP #6: create a simple page + template and paste in the following code for a quick test!

<?php
$to       = 'recipient@gmail.com';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: [your_gmail_account_username]@gmail.com' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=utf-8';
if(mail($to, $subject, $message, $headers))
    echo "WOOHOO, email sent";
else
    echo "BUMMER, email failed";
?>

 

I completed my setup about an hour ago after having tried several other Windows STMP server solutions. They were all overly complex with too many settings that I just didn't need. 

I hope that's it and that I didn't miss anything.

  • Like 3
Link to comment
Share on other sites

Thanks for for the write-up of how you got this working.

49 minutes ago, OrganizedFellow said:

I've spent two days trying to get my Windows 10 WAMP server setup to send the confirmation email

I've tried many different AMP stacks for Windows over the years and Laragon is the best. Among the useful features is a built-in mail sender:

2019-03-16_104336.png.0a5f1684f2ca08afcacb4553c5e40e16.png

I recommend it to any Windows user - you'll be sending email from your local dev environment within minutes rather than days. ? 

  • Like 8
Link to comment
Share on other sites

29 minutes ago, Robin S said:

I've tried many different AMP stacks for Windows over the years and Laragon is the best. 

 

I've developed for years on Debian.

I recently made the move to Windows and ... well, I'm not liking it ? So many things require more complex processes to install Nodejs and other things I need for web dev.

I will check out Laragon, thanks! 

  • Like 1
Link to comment
Share on other sites

2 hours ago, Robin S said:

I've tried many different AMP stacks for Windows over the years and Laragon is the best. Among the useful features is a built-in mail sender:

 

OMGOODNESSS!

Yesterday I was on XAMPP, earlier today I was on WAMP SERVER ... as of 20 minutes ago I am now on LARAGON - and it is superbly amazing!

My favorite feature is the easy at setting up VirtualHosts and the email server? Literally took seconds! THANK YOU ROBIN! 

  • Like 2
Link to comment
Share on other sites

12 hours ago, OrganizedFellow said:

I was incredibly frustrated when I kept trying to configure the module WireMailSmtp to send a test email and it continued to fail. The prompt kept saying I had the wrong password. I KNEW I did not have the wrong Gmail password and it was driving me nuts! 

 

Just a note, to give WireMailSmtp a third party access on your Gmail account, you have to enable "Less Secure Apps".

https://support.google.com/accounts/answer/6010255

 

Thanks for this tutorial ?

  • Like 1
Link to comment
Share on other sites

Here is a tip in general to speed up whatever local server you are using:

1) Open the server php.ini
2) Search for "realpath_cache_size"
3) Remove the semi-colon at the beginning of the line and change the 16k into 32M or 64M

 

  • Like 2
Link to comment
Share on other sites

On 3/16/2019 at 7:31 AM, pwired said:

Here is a tip in general to speed up whatever local server you are using:

Thanks for the tip. My php.ini file has this line: realpath_cache_size = 4096k

I'll leave that there and see what performance increase I notice ?
(but more important this post so I can come back to it later)

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi. I don't know about programming. I have some questions. I have wordpress on localhost wampserver version 3.2.0 I have not been able to send mail from my wordpress. If I follow your instructions, except step 6, should I be able to send emails from my wordpress? The videos I have seen is though plugin and they have a domain, and my wordpress is on localhost. Thanks for your indications, I have been working on this topic for 2 days.

Link to comment
Share on other sites

@David Leon Hello, I'm sure you are aware that this forum is for ProcessWire and not Wordpress. There is probably someone here who has some experience of running Wordpress, but that's not me so I can't help directly. Have you had any success asking about your issue on any Wordpress forum?

Hope you manage to get this sorted out.
 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...