Jump to content

Email won't work in my PHP code


dphoyt

Recommended Posts

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

$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.

$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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.