SMTP Problem (Windows)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stebut05
Forum Commoner
Posts: 35
Joined: Wed Sep 21, 2005 9:29 am
Location: Liverpool, UK

SMTP Problem (Windows)

Post by stebut05 »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, 

I keep geeting an error message when trying to send an email using PHP on a Windows server and cant find the problem. I would really appreicate any help given. I get the follwong error message: 

Warning: mail() [function.mail]: SMTP server response: 501 Bad address syntax in E:\SSLRoot\premier\includes\order_update_email.php on line 57. 

My email script is as follows:

Code: Select all

<?php 
$email = $rows['customer_email_address']; 

//5)email confirmations to us and to the customer 
/* recipients */ 
$to = "<" . $email .">"; 

/* subject */ 
$subject = "Order Status Update"; 

/* message */ 
/* top of message */ 
$message = " 
<html> 
<head> 
<title>Order Status Update Confirmation</title> 
</head> 
<body> 
<p>Dear $customer_title $customer_firstname $customer_lastname,</p> 
<p>Your order status has been updated and is due to be dispatched on $dispatch_date and is due for delivery on $delivery_date. If you have any queries, 
please contact our customer services department.</p> 


<table width=\"50%\" border=\"0\"> 
<tr> 
<td> 
<p>Order Number:"; 
$message .= " &nbsp;"; 
$message .= $order_id; 
$message .= "<br>"; 
$message .= "Customer Number:"; 
$message .= " &nbsp;"; 
$message .= $customer_id; 
$message .= "<br>"; 
$message .= "Order status:"; 
$message .= " &nbsp;"; 
$message .= $customer_message; 
$message .= " &nbsp;"; 
$message .= "<p>"; 
$message .= " 

</td> 
</tr> 
</table> 
</body> 
</html>"; 

/* headers */ 
$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "From: <ecommerce@christmastreeland.co.uk>\r\n"; 
$headers .= "Cc: <dianne@rainford.com>\r\n"; 
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n"; 

/* mail it */ 
mail($to, $subject, $message, $headers); 


?>
Thanks in advance for any help, suggestion and advice.

Kind Regards,

Steven


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

So how are you sending the username and password to the mailserver? Or doesn't it need them?
stebut05
Forum Commoner
Posts: 35
Joined: Wed Sep 21, 2005 9:29 am
Location: Liverpool, UK

Post by stebut05 »

Hi bokehman,

Thanks for your help.
bokehman wrote:So how are you sending the username and password to the mailserver? Or doesn't it need them?
I was running this script form test server at first and was working fine, then i switched to live server and getting problems. If i have to log in with username and password, how do i add this to script? I thought that i did not need username and password with php mailer function? I appreciate you r thoughts and comments.

regards,

Steven
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your email server likely doesn't like the <> around the to..
stebut05
Forum Commoner
Posts: 35
Joined: Wed Sep 21, 2005 9:29 am
Location: Liverpool, UK

Post by stebut05 »

Hi feyd,
feyd wrote:your email server likely doesn't like the <> around the to..
How do i resolve this problem? thanks for your help

Regards,

Steven
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

stebut05 wrote:Hi feyd,
feyd wrote:your email server likely doesn't like the <> around the to..
How do i resolve this problem? thanks for your help
remove the <> around the to... :?
stebut05
Forum Commoner
Posts: 35
Joined: Wed Sep 21, 2005 9:29 am
Location: Liverpool, UK

Post by stebut05 »

Hi,


[/quote]remove the <> around the to... :?[/quote]

I removed <> from code and changed to:

$to = "" . $email ."";

and got the following message

Warning: mail() [function.mail]: SMTP server response: 554 : Recipient address rejected: Relay access denied in

Then changed code to:

$to = ". $email . ";

and got follwing message:

Warning: mail() [function.mail]: SMTP server response: 554 <.steven@sbwebhosting.co.uk.>: Recipient address rejected: Relay access denied in

Then changed code to:

$to = " $email ";

and got the follwing message:

Warning: mail() [function.mail]: SMTP server response: 554 : Recipient address rejected: Relay access denied in

Then changed code to:

$to = $email;

and got the following message:

Warning: mail() [function.mail]: SMTP server response: 554 : Recipient address rejected: Relay access denied in

Any thoughts?? really appricate your help


Regards,

Steven
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"Relay access denied" means the server you are trying to communicate to or through denied the sending of the email. Your server is not a registered SMTP server with it likely or something like that.. A lot of servers will not accept relay smtp messages due to the spam nature involved with them normally.. so I will again say for the fifth or so time today, use phpMailer
Post Reply