dphoyt Posted April 30, 2009 Share Posted April 30, 2009 I am new to attempting to program in PHP. I am trying to write a form for people to fill out and then click on the send button and have the form information sent to us. I can't seem to get the email portion to work. When I try to debug the email file I get an error message that says "SMTP server response: 553 Sorry, that domain isn't in my list of allowed rcpthosts." When I try the file on the website, it seems to work alright but no email is actually sent. The form code is: <html> <head> <title>Pipeline Questionnaire</title> </head> <body> <form action="Feedback Sender.php" method="POST"> <p><strong>Name:</strong> <input type="text" size="25" name="user"/></p> <p><strong>Email Address::</strong> <input type="text" size="25" name="email" /></p> <p><strong>Company Name:<strong> <input type="text" size="35" name="Company Name"/></p> <p><input type="submit" value="Send" /></p> </form> </body> </html> The mail code is: <html> <head> <title>Pipeline Questionnaire Answers</title> </head> <body> <?php ini_set("SMTP","smtpout.secureserver.net"); ini_set ("sendmail_from", "[email protected]"); echo"<p>Thank you for your EMTEK Pipeline Questionnaire submission. A member of our sales department will contact you shortly.</p>"; //start building the mail string $msg = "Name: ".$_POST["name"]."\n"; $msg .= "E-Mail: ".$_POST["email"]."\n"; $msg .= "Company Name: ".$_POST["company name"]."\n"; //set up the mail $recipient = "[email protected]"; $from = $_Post["email"]; $subject = "Pipeline Questionnaire Answers"; $mailheaders = "Reply-To: ".$_POST["email"]; //mail it mail($recipient, $from, $subject, $msg, $mailheaders); ?> </body> </html> Can anyone see what I am doing wrong? Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/ Share on other sites More sharing options...
revraz Posted April 30, 2009 Share Posted April 30, 2009 You are not using the MAIL parameters correctly http://us2.php.net/manual/en/function.mail.php Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/#findComment-822900 Share on other sites More sharing options...
jutaro Posted April 30, 2009 Share Posted April 30, 2009 $to = "[email protected]"; $subject = "Subject"; $msg = "Message."; $from = "FROM: Mail Form <[email protected]>"; mail($to,$subject,$msg,$from); And your form Method is going to a file with a space in it. Don't put spaces in your filename. Also, I personally don't like lettings Users decide what my mail statement says who it's coming from. I don't have data off the top of my head of why it's a bad idea, but I recall reading there is security issues with doing that. Only thing that does for you is makes it so you can reply. I'd rather just copy their email out of the email I receive and do the email myself. Looks like you got your code from someone else. Perhaps a tutorial of some sort. I would definitely suggest following the link revraz provided so you can familiarize yourself with the function you are using. Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/#findComment-822962 Share on other sites More sharing options...
revraz Posted April 30, 2009 Share Posted April 30, 2009 Most ISP's won't accept a FROM address that is not on it's domain. Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/#findComment-822968 Share on other sites More sharing options...
the182guy Posted April 30, 2009 Share Posted April 30, 2009 $to = "[email protected]"; $subject = "Subject"; $msg = "Message."; $from = "FROM: Mail Form <[email protected]>"; mail($to,$subject,$msg,$from); The fourth argument to this function is not for the senders email address. It is for the list of additional headers to send with the email message, one of which being the senders email address. Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/#findComment-822991 Share on other sites More sharing options...
jutaro Posted April 30, 2009 Share Posted April 30, 2009 I know, I was just doing a simple example. If he wants to know about headers the link to the mail function was provided. Link to comment https://forums.phpfreaks.com/topic/156299-email-wont-work-in-my-php-code/#findComment-823005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.