PHP Build a Basic PHP Website (2018) Adding a Basic Form Utilizing Object Properties and Methods

Sean Flanagan
Sean Flanagan
33,223 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?

Eliyah Kohein
Eliyah Kohein
20,910 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.

Eliyah Kohein
Eliyah Kohein
20,910 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,223 Points

Darrell Conklin

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

Eliyah Kohein
Eliyah Kohein
20,910 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,223 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

Eliyah Kohein
Eliyah Kohein
20,910 Points

You are very welcome :)

1 Answer

Spenser Hale
Spenser Hale
18,330 Points

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.