Page 1 of 1
PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 12:53 pm
by benrud
Hello Everyone,
I recently started learning very basic php. One of the first things I've tried was emailing a contact form via php. One thing I've noticed is that the emailed form is not received by every e-mail server. Gmail will accept the form but when I send it to hotmail or my work e-mail it never shows up?
Am I doing something wrong or is there a special way to code the email so all email servers accept it?
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$reason = $_POST['reason'];
$comment = $_POST['comment'];
$to = "
tbenrud@guhsd.net";
$subject = $reason;
$body = "Contact Form \n $last_name \n $phone \n $reason \n $email \n $reason \n $comment \n";
$headers = "From: $email\n";
mail($to, $subject, $body, $headers, "-f$email");
?>
Thanks for your help,
Todd
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 1:48 pm
by josh
Your MTA is not configured properly. Probably EHLOing localhost or some noob mistake

Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 2:40 pm
by benrud
jshpro2,
It is a noob mistake. Can you please help me correct this? Is it something I can fix in the php code or do I have to modify the php installation on my server?
Any help is greatly appreciated?
Thanks,
Todd
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 2:47 pm
by josh
Nope. Not calling you a PHP noob, but you're a noob at being a sysadmin

don't worry so am I. and no its not something you can fix in the code. Its a misconfiguration with your web hosts software, you probably set up your own box on the command line huh? and are using the default sendmail configuration?
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 2:58 pm
by benrud
Actually, I'm a web design teacher at the high school level. I only teach the CS3 suite and basic static web design. Recently, several of my students asked about php and emailing forms so I'm working on a lesson so I can teach them that skill.
I do have a web server but I didn't configure it, the school district's tech did. I can get him to help me but I want to have the information I need to steer him in the right direction.
If you can point me to an online tutorial for properly configuring php so it handles php formmail correctly or the key words I should use so I can search one out on my own, I would appreciate it.
I've tried googling but haven't had much luck. Probably because I'm not sure what I'm looking for yet.
Thanks again for your help and have a great day.
Todd
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 3:43 pm
by josh
Yep, your server is sending EHLO localhost, instead of a FQDN ( fully qualified domain name ). Basically this is your SMTP daemon, PHP just talks "in SMTP" on to your MTA ( mail transfer agent ) which is probably sendmail or exchange server. You need to set up masquerading if you're using sendmail, but I'd focus on basic concepts like constructs, variables, etc.. before getting into integrating 3rd party applications, but maybe you're already on it..
Good luck
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 5:26 pm
by benrud
Thanks for the direction and have a good one!
Todd
Re: PHP form mail not being delivered to hotmail, yahoomail, etc
Posted: Tue Jan 13, 2009 6:19 pm
by josh
Yep, one last thing. In gmail view "original message" and you should see the incorrect headers