I keep getting an error when I run the following PHP script. The browser says there is an error on line 53 - which is the mail($EmailTo,$Subject,$Body,$name); line, but I can't see anything wrong there, or subsequently.
Can anybody help me out with where I'm going wrong?
Thanks!
<?php
$EmailFrom = $_POST['email'];
$EmailTo = 'relevant email address here';
$Subject = 'Contact Request';
$name = $_POST['name'];
$org = $_POST['org'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$mail_list = $_POST['mail_list'];
$headers = "From: " . $EmailFrom. "\r\n" . 'X-Mailer: PHP/' . phpversion('5.0');
$Body .= "---------------------------";
$Body .= "\n";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Organisation: ";
$Body .= $org;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $address;
$Body .= "\n";
$Body .= "Contact number: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "E-mail: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $comments;
$Body .= "\n";
$Body .= "\n";
$Body .= "Mail List: ";
$Body .= $mail_list;
$Body .= "\n";
$Body .= "---------------------------";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../tpollo.css" />
<title>T'Pollo - Great Northern Comedy</title>
</head>
<body>
<?php
mail($EmailTo,$Subject,$Body,$EmailTo);
echo("<p class=conf>Thank you. We will contact you shortly.<br />
<a href=../index.htm>Click here to return to the website.</a></p>");
?>
</body></html>
Browser error with PHP email script
Moderator: General Moderators
-
penkomitev
- Forum Newbie
- Posts: 6
- Joined: Sat Dec 26, 2009 10:40 am
- Location: Plovdiv, Bulgaria
Re: Browser error with PHP email script
There has to be something with the contents of the variables you are using as arguments of mail().
However, due to the lack of additional information, I can't say anything in particular.
I suggest that you format your code in a
However, due to the lack of additional information, I can't say anything in particular.
I suggest that you format your code in a
Code: Select all
so it is easier to read. Also, try finding the mistake. "There is an error" is pretty vague. You have to specify what kind of error it is so we can provide assistance.
RegardsRe: Browser error with PHP email script
Hi,
On the line where the error is:
I notice that the 4th parameter is the "TO" address. You have created a $headers var, but have not used it. Change you line to the following as a test:
Let me know..Cheers
On the line where the error is:
Code: Select all
mail($EmailTo,$Subject,$Body,$EmailTo);Code: Select all
$Header = "From: $EmailTo";
$Send = mail($EmailTo,$Subject,$Body,$Header);
if(!$Send)
{
print "Sorry an error occurred!";
}Re: Browser error with PHP email script
Thanks for your comments.
This is the error message I am getting:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for email address in C:\apachefriends\xampp\htdocs\....php on line 53
This is on the testing server on my computer, but I've tested it on the web server too.
I will re-check everything but if you can see what's wrong from this please let me know.
Cheers.
This is the error message I am getting:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for email address in C:\apachefriends\xampp\htdocs\....php on line 53
This is on the testing server on my computer, but I've tested it on the web server too.
I will re-check everything but if you can see what's wrong from this please let me know.
Cheers.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Browser error with PHP email script
Your email server is either not configured to relay email for that email address or it requires authentication. You can check out the PEAR Mail package or Swift Mailernormcity wrote:Thanks for your comments.
This is the error message I am getting:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for email address in C:\apachefriends\xampp\htdocs\....php on line 53
This is on the testing server on my computer, but I've tested it on the web server too.
I will re-check everything but if you can see what's wrong from this please let me know.
Cheers.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.