Jump to content
OrganizedFellow

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

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...