473,769 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1837
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********@alp haworks.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*****@exampl e.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*****@exampl e.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.p hp>:]
| The to parameter should not be an address in the form of "Something
| <so*****@exampl e.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
3324
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. Issue#1: I get 2 copies of the form that gets submitted each time. Issue#2: The header does not display the "FROM" information in Outlook, but I can see the From information in my email spam filter
2
1742
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, however if I forward that mail from yahoo I can see it perfectly again in outlook/eudora. By some trial and errors I found that without the first 2 headers, it works fine in yahoo mail too, so what's wrong with my headers ? Thanks in advance to who...
6
2217
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 can send mail to yahoo.com, gmail.com, and hotmail.com no problem. 100% success. Same script from some servers gets mail through to cox.net addresses,
6
1976
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 a little but I can't seem to get it to work. It attaches the file properly, but only displays the Plain Text message, even in an HTML-capable mail client. I'm guessing it has something to do with the placement of the boundaries,
4
3902
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. The part of the program that sends an email states this: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers if (isset($_REQUEST)){ $headers .= 'Bcc: '.$bcc....
12
4593
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, one I am currently developing. I am testing the mail functionality by sending a test message to an email account associated with my old website, and to my hotmail account. The message seems to be sent to both accounts, and I receive the message on...
1
2760
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 see what's going on. Any reason why this might happen? here's my code just in case. $counter=1; function send_mail($emailaddress, $fromaddress, $emailsubject, $body, $method) {
2
2674
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. Because I don't understand PHP I cannot find the error. Who is willing to help? regards Ruud
10
3335
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 different occassions when I send the exact same mail (same e-mail address, same name, same body content) through my site's contactform it produces the wellknown strange characters instead of the intended diacritical characters. This problem also...
7
16923
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 line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.