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

Problems with headers using mail() function

P: n/a
Oops, I meant to write:
function send_mail($to_name, $to_email, $from_name, $from_email,
$subject, $message)
{
$thedate = date("r", time());

$headers = "X-Mailer: PHPMailProgram/1.0\n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "Date: $thedate\n";
$headers .= "Content-Type: text/plain\n\n";

$to = "\".$to_name."\" <".$to_email.">";

return mail( $to, $subject, $message, $headers);
}

Sorry 'bout that.

Thank you,
Spartacus
Jun 13 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Spartacus wrote:
Oops, I meant to write:
function send_mail($to_name, $to_email, $from_name, $from_email,
$subject, $message)
{
$thedate = date("r", time());

$headers = "X-Mailer: PHPMailProgram/1.0\n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "Date: $thedate\n";
$headers .= "Content-Type: text/plain\n\n";

$to = "\".$to_name."\" <".$to_email.">";

return mail( $to, $subject, $message, $headers);
}

Sorry 'bout that.

Thank you,
Spartacus
First of all, please learn to REPLY to messages instead of starting a
new thread every time.

And why are you putting quotes in the from and to headers?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 13 '07 #2

P: n/a
Spartacus wrote:
Oops, I meant to write:
function send_mail($to_name, $to_email, $from_name, $from_email,
$subject, $message)
{
$thedate = date("r", time());

$headers = "X-Mailer: PHPMailProgram/1.0\n";
$headers .= "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "Date: $thedate\n";
$headers .= "Content-Type: text/plain\n\n";

$to = "\".$to_name."\" <".$to_email.">";

return mail( $to, $subject, $message, $headers);
}

Sorry 'bout that.

Thank you,
Spartacus
I should also add - the best way to fix these problems is to look at the
headers for a working email, then look at the headers in the email
you're sending. See what is different.

And when I say "look at the headers", I mean examining the source - not
what your reader displays.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 13 '07 #3

P: n/a
Jerry Stuckle wrote:
First of all, please learn to REPLY to messages instead of starting a
new thread every time.
OK, thanks for the tip.
And why are you putting quotes in the from and to headers?
Because they go like this (if you want them to, I believe):

"John Doe" <jo**@doe.com>

That's a legal email address, isn't it?

Spartacus

Jun 13 '07 #4

P: n/a
Jerry Stuckle wrote:
I should also add - the best way to fix these problems is to look at the
headers for a working email, then look at the headers in the email
you're sending. See what is different.
Nothing different, except I don't get what I want - the missing quotes,
names and brackets.
And when I say "look at the headers", I mean examining the source - not
what your reader displays.
I already have. I've echo()'d the headers and examined the source of the
email that turned up.

Spartacus
Jun 13 '07 #5

P: n/a
Spartacus wrote:
Jerry Stuckle wrote:
>I should also add - the best way to fix these problems is to look at
the headers for a working email, then look at the headers in the email
you're sending. See what is different.

Nothing different, except I don't get what I want - the missing quotes,
names and brackets.
>And when I say "look at the headers", I mean examining the source -
not what your reader displays.

I already have. I've echo()'d the headers and examined the source of the
email that turned up.

Spartacus
And when you compare the source of the failing email to the source of a
working email, what do you see?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 13 '07 #6

P: n/a
Jerry Stuckle wrote:
Spartacus wrote:
>Jerry Stuckle wrote:
>>I should also add - the best way to fix these problems is to look at
the headers for a working email, then look at the headers in the
email you're sending. See what is different.

Nothing different, except I don't get what I want - the missing
quotes, names and brackets.
>>And when I say "look at the headers", I mean examining the source -
not what your reader displays.

I already have. I've echo()'d the headers and examined the source of
the email that turned up.

Spartacus

And when you compare the source of the failing email to the source of a
working email, what do you see?
I have to take out the name and the angle brackets. So all I see is an
email address. I can't seem to get the emails to display/send as

Name <email>

--
Spartacus
Jun 13 '07 #7

P: n/a
Spartacus wrote:
Jerry Stuckle wrote:
>Spartacus wrote:
>>Jerry Stuckle wrote:
I should also add - the best way to fix these problems is to look at
the headers for a working email, then look at the headers in the
email you're sending. See what is different.

Nothing different, except I don't get what I want - the missing
quotes, names and brackets.

And when I say "look at the headers", I mean examining the source -
not what your reader displays.

I already have. I've echo()'d the headers and examined the source of
the email that turned up.

Spartacus

And when you compare the source of the failing email to the source of
a working email, what do you see?

I have to take out the name and the angle brackets. So all I see is an
email address. I can't seem to get the emails to display/send as

Name <email>

--
Spartacus
As I said - what do you see when you display the source of the failing
email and compare it to the source of a working email?

It does work.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 13 '07 #8

P: n/a
Spartacus <no****@nowhere.comwrote:
>Jerry Stuckle wrote:
>And why are you putting quotes in the from and to headers?

Because they go like this (if you want them to, I believe):

"John Doe" <jo**@doe.com>

That's a legal email address, isn't it?
Yes, for the header lines in the email message, although the quotes aren't
necessary unless the name has certain special characters, so this is ok
too:
John Doe <jo**@doe.com>

However, the addresses that get passed as parameters to the "mail" command
are NOT headers in an email message. They are used in the SMTP dialog with
the mail server. The nickname part is not used there.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jun 15 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.