?
Solved

an error message that i cannot understand

Posted on 2006-11-12
16
Medium Priority
?
343 Views
Last Modified: 2010-08-05
hi
i am new in php and i`m trying to build a small shpping cart with a tutorial.
everything works until i try to send it i get this error messahe:
Warning: mail() [function.mail]: SMTP server response: 501 5.5.2 Syntax: RCPT TO: <address> in ...

what is wrong here and how to fix it?

and maybe a more broad question: if i get an error message that i cannot figure out where can i check for it? i tryed in google but did not get anything i could understand.


best regards

ron

0
Comment
Question by:derrida
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +2
16 Comments
 
LVL 8

Expert Comment

by:Rytmis
ID: 17924622
Looks like your outbound mail server doesn't like the recipient address. If you could paste the bit where you call mail(), it'd make it easier to help.

Google is a great resource for finding information, but you need a bit of experience to first only search for the relevant part of the error message and then to recognize the relevant results.
0
 
LVL 1

Author Comment

by:derrida
ID: 17924631
hi

thanks for answring. this is the code:

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: <myemail@gmail.com>\r\n";
$headers .= "Cc: <myemail@gmail.com>\r\n";
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n";

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

i sent the headers too cause i feel that there is where the problem is. the other elements are good i`m quite sure.

best regards

ron
0
 
LVL 8

Expert Comment

by:Rytmis
ID: 17924662
Actually, your headers look just fine. However, I'd like to see what $to contains -- is it possible that $to is empty or malformed, because that's what the SMTP server seems to be complaining about?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:derrida
ID: 17924706
hi
it seem like you are right.

there is this code:
$to = "<" . $email .">";

but i cannot see where in the 3 setp checkout pages there is the definition of this variable.

according to the tutorial the email will go to the customer and to the administrator. how can i specify that, maybe to write just before that line something like:
$email="$_POST['email'], myemail$gmail.com";

as i said i`m new to php so it is possible that its a stupi move:)


ron
0
 
LVL 8

Expert Comment

by:Rytmis
ID: 17924721
Well, variables don't automatically persist across requests, so if you can't find a $email = something anywhere, that's definitely a problem.

One thing you could do is replace the mail() call with a die($to); so the script will terminate and print out the address instead of sending the email. That way you can check what the issue with the address is.
0
 
LVL 1

Author Comment

by:derrida
ID: 17924733
hi

i have commented the mail() and wrote die($to) but i still get this message:

Warning: mail() [function.mail]: SMTP server response: 501 5.5.2 Syntax: RCPT TO: <address> in C:\Program_files\wamp\www\shoppingCart\checkout3.php on line 252

can it be?

ron
0
 
LVL 8

Expert Comment

by:Rytmis
ID: 17924739
Well something funny is going on then. Most likely you commented out the wrong mail() or didn't actually update the file. See line 252 in C:\Program_files\wamp\www\shoppingCart\checkout3.php like the error message says: is there a mail() call there?
0
 
LVL 1

Author Comment

by:derrida
ID: 17924748
hi

no i have commented it. there is no mail() as far as i can see.

ron
0
 

Expert Comment

by:Jezdo
ID: 17924943
Is this on your local host?
Did you started up Mail server?
If I did saw very well, email (that to) must not be in format:
< email@domain.tld >
It shold be in:
email@domain.tld
I almost never use this function so I'm not expert on it.
And, I think your problem is in $to variable.
try to use $to = $email  or change $to var into $email (if you have $email var defined).
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 17926171
> there is this code:
> $to = "<" . $email .">";
$to should not have the < > parens. It should contain pure email address only. The < > are added automatically by PHP. So in Your example smtp server gets
RCPT TO: <<some@where.com>>
which is wrong.
0
 
LVL 1

Author Comment

by:derrida
ID: 17928318
hi

thanks for the answer. well i did that and now i get this error message regarding the mail function:
mail($to, $subject, $message, $headers);

Warning: mail() [function.mail]: SMTP server response: 501 5.5.2 Syntax: RCPT TO: <address> in C:\Program_files\wamp\www\shoppingCart\checkout3.php on line 252


so it seem like nothing has changed.


ron
0
 
LVL 8

Expert Comment

by:Rytmis
ID: 17928352
Try forcing a known good email address in $to :

$to = "youremail@yourdomain.com";

just before the mail() call

That way you can verify that a good address will / won't work.
0
 
LVL 1

Author Comment

by:derrida
ID: 17928393
hi

i still get the same error message.


i do not have any idea why, all you said was so reasonable.


ron
0
 
LVL 18

Expert Comment

by:Mark Gilbert
ID: 17928922
I looked up the error 501 5.5.2 Syntax error and found the following:

Sender has no domain specified (usually in MAIL FROM)

Or:

SMTP session syntax invalid. (usually unbalanced brackets)

Source: http://www.icewarp.com/support/faq/3280.php

I would check the format of all email addresses being parsed before the mail() call.  One thing to note is that SPF records now generally get checked by servers.  If the email address you claim the email is being sent from doesn't actually match up when the SPF is checked, then you will also get similar messages.  You must ensure that if you are sending "from" a gmail address, that you correctly authenticate with their smtp server.  Have a look at PHPMailer classed which allow you to "log in" to smtp before sending mails...this will ensure your SPF records match: http://phpmailer.sourceforge.net
0
 

Accepted Solution

by:
Jezdo earned 250 total points
ID: 17937306
Comment all code before this and add next:
[code]
// This needs to be configured:
$to = "user@domain.com"; // Replace user & domain.com. Don't add anything.
// Make this your email!
// Don't change anything next
mail($to,"[ Test Email ]","If you see this MSG something is wrong with your previous code.") or die("SMTP server error: Mail not sent.");
[/code]
If you recive email, something is wrong with your code.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 18120720
And what was wrong?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question