473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

mail() and To: headers

I'm using the mail() function to send e-mails. The first argument to the
function is the e-mail address the mail will be sent to. I understand this
should just be in the format 'address@domain' and not '"Name"
<address@domain>' and that if I want to specify the name of the recipient as
well as the address of the recipient I should pass it as an addition header.
This works fine locally under Windows and Apache but remotely under Linux
and Apache the resultant raw message has 2 To: headers meaning the client
displays it as being sent to 2 addresses (the same address twice). Am I
doing this correctly? It seems a clumsy way of doing it, especially as
SpamAssassin marks down a message with only an email address in the two
header.

Thanks,
Geoff
Jul 17 '05 #1
4 1821
Geoff Soper wrote:
I'm using the mail() function to send e-mails. The first argument to the
function is the e-mail address the mail will be sent to. I understand this
should just be in the format 'address@domain' and not '"Name"
<address@domain>'


I've been using it with the first format without problems.


$ uname -srmo
Linux 2.4.26-1-686 i686 GNU/Linux

$ php -v
PHP 4.3.4 (cli) (built: Mar 27 2004 08:04:22)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

$ cat mailgeoff.php
cat mailgeoff.php
<?php
mail('"Geoff Soper" <ge********@alphaworks.co.uk>',
'test',
'seems to have worked :-)',
'From: Pedro Graca <he****@hotpop.com>',
'-fhe****@hotpop.com');
?>

$ php mailgeoff.php

$

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
Pedro Graca wrote:
Geoff Soper wrote:
I'm using the mail() function to send e-mails. The first argument to the
function is the e-mail address the mail will be sent to.
Basically, yes. The documentation's examples *imply* that the first
parameter should be a comma-and-space-separated list of one or more
addr-specs, but I can't find where this is explicitly stated.
I understand this should just be in the format 'address@domain'
To send mail to a single mailbox, probably.
and not '"Name" <address@domain>'

Again, that's probably correct; the docs are waffly.
I've been using it with the first format without problems.


OK. But read the Manual's note, which feigns a quotation:

| The to parameter should not be an address in the form of "Something
| <so*****@example.com>". The mail command may not parse this properly
| while talking with the MTA (Particularly under Windows).

"PHP: mail - Manual",
http://www.php.net/manual/en/function.mail.php

And there are related user-comments dated 2003-01-17 and 2003-06-09:

http://www.php.net/manual/en/function.mail.php#28610
http://www.php.net/manual/en/function.mail.php#32848

We're left wondering what the Manual's preferred forms are. Had it
referenced RFC2822, and stated that the first parameter to mail should
be a comma-[and-space-]separated list of addr-specs, our questions
would be answered. As it is, we have to guess.

--
Jock
Jul 17 '05 #3
> Pedro Graca wrote:
Geoff Soper wrote:
I'm using the mail() function to send e-mails. The first argument to the function is the e-mail address the mail will be sent to.

Basically, yes. The documentation's examples *imply* that the first
parameter should be a comma-and-space-separated list of one or more
addr-specs, but I can't find where this is explicitly stated.

| The to parameter should not be an address in the form of "Something
| <so*****@example.com>". The mail command may not parse this properly
| while talking with the MTA (Particularly under Windows).


Reading this excerpt from the manual again, is it the case that any mail
server the message might pass through potentially might have a problem or is
it just the SMTP server my script talks to directly? If it's the latter then
it works so it must be OK for me to use but if it's the former then it's
about taking a chance.

Any suggestion?

Thanks,
Geoff
Jul 17 '05 #4
Geoff Soper wrote:
[From <http://www.php.net/manual/en/function.mail.php>:]
| The to parameter should not be an address in the form of "Something
| <so*****@example.com>". The mail command may not parse this properly
| while talking with the MTA (Particularly under Windows).


Reading this excerpt from the manual again, is it the case that any mail
server the message might pass through potentially might have a problem or is
it just the SMTP server my script talks to directly?


Just the SMTP server your script talks to directly.

Conversations between user-agents and MTAs are private matters. What
happens after that, however, is covered in RFC2821.

RFC2821, Simple Mail Transfer Protocol,
http://www.ietf.org/rfc/rfc2821.txt

--
Jock
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug....
2
by: johnny | last post by:
hi all, I have a script to send newsletters both in html and text version, all works fine in email clients but unfortunately not in yahoo mail: it shows nothing in the body of the message,...
6
by: jerrygarciuh | last post by:
Hi folks, HELP!!!! My habitual use of mail() is causing me some grief. I am having slightly different results depending on the server I use but the gist is that mail() is returning 1, and I...
6
by: Karl Groves | last post by:
I'm trying to work out a mail system which can send an attachment as well as an HTML formatted message (and a default plain text version). I found some pretty good code on PHP.net and modified it...
4
by: Jason | last post by:
I'm troubleshooting a program that I didn't build, so forgive me on this one. It's called email.php, and it looks like a program that the original developer must have downloaded from somewhere. ...
12
by: e_matthes | last post by:
Hello everyone, I am trying to use the mail() function to send a simple, text-only message. I have two websites hosted by the same company, on different servers. One is old and established,...
1
by: robbiesmith79 | last post by:
I'm trying to spam myself :-\ with 2,000 emails, shooting for 15,000, and I will occasionally get two identical emails. I'm putting a $counter++ as the from and part of the subject line so I can...
2
by: Ruud | last post by:
Just before leaving for a holiday my collegue modified this script. Now it won't send any body text (The data filled in on the form) and in an error condition it won't send any attachments either....
10
by: amygdala | last post by:
Hi all, Another problem that has been bugging me for a while now, but which I swept under the rug too long too now is a mail encoding problem at my (shared) webhost. The problem is that on...
7
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.