Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.



Im trying to send info from my contact form to my email but its showing this warnings:

Warning: mail() [function.mail]: SMTP server response: 501 Your domain does not seem to be valid. Could not find MX record for your domain. in D:\Inetpub\vhosts\drmendozaklein.com\httpdocs\contacto.php on line 22

Warning: Cannot modify header information - headers already sent by (output started at D:\Inetpub\vhosts\drmendozaklein.com\httpdocs\contacto.php:22) in D:\Inetpub\vhosts\drmendozaklein.com\httpdocs\contacto.php on line 23

can someonde help me!


2 Answers

Can you post up the lines of code it refers to? I'm just getting to grips with php but I do like it that it often tells you exactly where your mistake is.

This is the code. thanks


$to_email = "e-mail@hotmail.com";

$name = $_POST["name"]; $email = $_POST["email"]; $message = $_POST["message"];

$subject = "[Te Contactaron] " . $_POST["subject"];

function isValidEmail($email) { return strpos($email, "@") !== false; }

if($name != "" && $email != "" && $message != "" && isValidEmail($email)) {

$full_message = "Name : ". $name . "\n";
$full_message .= "Email : ". $email . "\n";
$full_message .= "Message :\n". $message . "\n";

mail($to_email, $subject, $full_message);      /*line 22*/
header("location: contacto.html");    /*line 23*/



die("Your data is invalid.");