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

Sean Flanagan
Sean Flanagan
33,230 Points

"Invalid email address"


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?

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.

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,230 Points

Darrell Conklin

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

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->SMTPDebug = 2;
$mail->Host = '';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "your email";
$mail->Password = "your password";
Sean Flanagan
Sean Flanagan
33,230 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.


You are very welcome :)

1 Answer

Spenser Hale
Spenser Hale
18,535 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.