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 Build a Basic PHP Website (2018) Adding a Basic Form Utilizing Object Properties and Methods

Sean Flanagan
Sean Flanagan
33,235 Points

"Invalid email address"

Hi.

I put my email address in the Email field and click Send but all I get is a white screen with the above message. Why is that?

Darrell Conklin
Darrell Conklin
21,988 Points

If you post your code or a snapshot of your Workspace I'd be happy to take a look. My personal suggestion would be to look back over your code for typos or other errors ... we all make them.

Darrell Conklin
Darrell Conklin
21,988 Points

https://teamtreehouse.com/community/invalid-email-address-message-with-valid-emailhelp

This was the problem however you get a 502 Bad Gateway error when using your smtp settings. If you remove the smtp from the code it works as it did in the video.

PS You should probably change your gmail password now since you left it in your snapshot for others to see.

Sean Flanagan
Sean Flanagan
33,235 Points

Darrell Conklin

So even if I fill out all the fields on the form, I'll still get that message?

Darrell Conklin
Darrell Conklin
21,988 Points

Follow the instructions in the link I provided and remove the smtp settings in your code and it should work just fine.

Remove the following lines to remove smtp settings.

$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "your email";
$mail->Password = "your password";
Sean Flanagan
Sean Flanagan
33,235 Points

Hi Darrell Conklin.

I got rid of those lines and changed the $email and $details operators. It now goes to the Thanks page.

Thanks for your help.

Sean

1 Answer

Hey Sean and Darrell,

It would be good for the community to have an answer selected as best answer so this questions is not listed in the unresolved section.