By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,761 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

mail() messages bounce with 501 syntax error in MAIL FROM command

P: n/a
Hi,

I have this website that contains an internal message system that allows
users to send each other "email" messages. My client wants me to extend
the system so that when a user receives an internal message, the system
will send an actual email to the user's email address.

here's the sample code:

function notify_recipient()
/* Send an external email to the recipient of the internal email. */
{
$return = false;
$recip = new User();
if (strcmp($this->recipient, "") == 0 )
{
$this->errormessage .= "Email Recipient is Missing,";
}
else
{
$recip->userid = $this->recipient;
$recip->load_by_id();
}
$sender = new User();
if(strcmp($this->sender, "") == 0)
{
$this->errormessage .= "Email Sender Is Missing,";
}
else
{
$sender->userid = $this->sender;
$sender->load_by_id();
}
$site = new Site();
$site->site_id = $recip->site_id;
$site->load_by_id();

$to = $recip->email;
$from = "<webmaster@" . strtolower( $site->site_name ) .">";
$subject = "New Message at $site->site_name";
$message = "Howdy, $recip->username, \r\n".
"You have received a new message from $sender->username over at
$site->site_name." .
" Please visit $site->site_url to retrieve your message.\r\n\r\n" .
"Thanks,\r\n\r\n" .
"The Team at $site->site_name";

$headers = "From: $from\r\n";
if (mail( $to, $subject, $message, $headers))
{
$return = true;
}
return $return;
}

Here's the raw message it generates:

Received: by [host obscured] (Postfix, from userid 72)
id A684219E678; Thu, 10 Feb 2005 16:46:58 -0800 (PST)
To: [email obscured]@yahoo.com
Subject: New Message at LeatherM4M.net
From: <we*******@leatherm4m.net>
Message-Id: <20************************@stud.aliceblue.org>
Date: Thu, 10 Feb 2005 16:46:58 -0800 (PST)

Howdy, bigredpaul,
You have received a new message from bigredpaul over at [site name
obscured]. Please visit http://[url obscured]/ to retrieve your message.

Thanks,

The Team at [site name obscured]
And here's the message I get back from yahoo, for instance:

<[email obscured]@yahoo.com>: host mx1.mail.yahoo.com[67.28.113.11]
said: 501 Syntax error in parameters or arguments (in reply to MAIL FROM
command)
Does anyone have any thoughts about what I might be doing wrong?

Thanks,

Paul
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
paul brown <nn**@paulbrown.net> wrote in news:ntTOd.3699$aW6.483
@newssvr22.news.prodigy.net:
Hi,

I have this website that contains an internal message system that allows users to send each other "email" messages. My client wants me to extend the system so that when a user receives an internal message, the system
will send an actual email to the user's email address.

here's the sample code:

[snip]

$headers = "From: $from\r\n";
Remove the \r\n from that line and you should be OK. It's only necessary
if you're sending multiple headers, e.g.

$headers = "From: $from\r\nBcc: fo*@example.com";

Received: by [host obscured] (Postfix, from userid 72) ^^^^^^^^^^^^^^^ Subject: New Message at LeatherM4M.net


hth ;))
--

Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fung.arg');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
Jul 17 '05 #2

P: n/a
Senator Jay Billington Bulworth wrote:
paul brown <nn**@paulbrown.net> wrote in news:ntTOd.3699$aW6.483
@newssvr22.news.prodigy.net:

Hi,

I have this website that contains an internal message system that


allows
users to send each other "email" messages. My client wants me to


extend
the system so that when a user receives an internal message, the system
will send an actual email to the user's email address.

here's the sample code:

[snip]

$headers = "From: $from\r\n";

Remove the \r\n from that line and you should be OK. It's only necessary
if you're sending multiple headers, e.g.

$headers = "From: $from\r\nBcc: fo*@example.com";


It doesn't matter whether or not they exist or not. I've tried it with
and without.

Thanks though,

Paul
Jul 17 '05 #3

P: n/a
*** paul brown wrote/escribió (Fri, 11 Feb 2005 01:01:07 GMT):
if (mail( $to, $subject, $message, $headers))


If the error is returned by the mail server, the only line in your code
that matters is the one above. What are the actual values of the variables
you pass as arguments?

Hint: echo

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #4

P: n/a
Alvaro G Vicario wrote:
*** paul brown wrote/escribió (Fri, 11 Feb 2005 01:01:07 GMT):
if (mail( $to, $subject, $message, $headers))



If the error is returned by the mail server, the only line in your code
that matters is the one above. What are the actual values of the variables
you pass as arguments?

Hint: echo


The values are correct, so it's leading me to think that perhaps the
problem lie in my outgoing mail server.

Thanks,

Paul
Jul 17 '05 #5

P: n/a
paul brown wrote:
Hi,

I have this website that contains an internal message system that allows
users to send each other "email" messages. My client wants me to extend
the system so that when a user receives an internal message, the system
will send an actual email to the user's email address.


I ended up using an open source group of classes called PHPMailer, and
its companion SMTP class. While that Postfix server works just fine for
every other type of mail, sending via mail() wasn't cutting it, but the
PHPMailer and SMTP objects work just fine.

Thanks to everyone who suggested things,

Paul
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.