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 trialjamescool
44,592 Pointspotential improvement
If the user fails to include ".com" in the email field, he will receive an error message like this: "There was a problem sending the email: Could not instantiate mail function." This doesn't seem ideal because--at least from the perspective of the average user--it's cryptic. Also, from a developer's perspective, it's not an intended error message. So, I think it would be useful to add to the conditional statement. Instead of:
if (!isset($error_message) && !$mail->ValidateAddress($email){
$error_message = "You must specify a valid email address.";
}
it should be:
if (!isset($error_message) && (!$mail->ValidateAddress($email) OR stripos($email, '.com') == FALSE)){
$error_message = "You must specify a valid email address.";
}
Now, I'm no PHP wiz so please chime in if this will break anything or cause unintended results. I've tested this locally and it seems to work. Anyway, hope this helps!
-James Cool