Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Contact Form & Sending Email Sending Our Email

Aleksandr Antropov
Aleksandr Antropov
6,458 Points

How to send an email via SMTP (Google) with Swiftmailer on localhost (WAMP)

If you are running a project on a localhost (in my case - WAMP) you are going to have issues with sending an email. I encountered this error: Connection could not be established with host smtp.gmail.com [ #0]

The source of an error is unknown to me. However there is a workaround:

  1. Go to \vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport;
  2. Open 'StreamBuffer.php';
  3. Go to line 266 and paste the following code before '$streamContext' assignment: $options['ssl']['verify_peer'] = FALSE; $options['ssl']['verify_peer_name'] = FALSE;

This will allow us to send emails within our testing environment.