I haven't used php to send mail yet and have some questions.
I see that you can add headers, and these days it is essential to have a
real "from".
But I see you can also do this:
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
Does that only work with sendmail and how can you tell what the MTA
(is that right) is?
Also, how would you include a BCC or Reply To with that?
On a related note, what's with CR LF I see in the examples. I see there
are some issues with the CR, can I simple do this?:
$header=<<<'thisdata'
From: some_from
BCC: some blind copy
thisdata;
and expect that to work?
Jeff
> I haven't used php to send mail yet and have some questions.
>
[quoted text clipped - 22 lines]
>
> Jeff
Hey here's some help.
With the PHP mail() function the From MUST be included either in the
php.ini file or in the headers section otherwise it returns a warning.
Separate headers are separated by CRLF in the form of "\r\n" for
example:
$headers = "From: example@example.com" . "\r\n" . "Cc:
example2@example.com" . "\r\n" . "Bcc: example3@example.com" . "\r
\n" . "Reply-To:example4@example.com";
Note: If messages are not received, try using a LF (\n) only. Some
poor quality Unix mail transfer agents replace LF by CRLF
automatically (which leads to doubling CR if CRLF is used). This
should be a last resort, as it does not comply with » RFC 2822.
the mail() would then be something like:
mail($to, $subject, $message, $headers)
I hope that helped if more assistance is needed check out PHPs website
they have very useful documentation:
http://us.php.net/manual/en/function.mail.php
*** Jeff escribió/wrote (Thu, 24 Jul 2008 09:27:37 -0400):
> I see that you can add headers, and these days it is essential to have a
> real "from".
[quoted text clipped - 6 lines]
> Does that only work with sendmail and how can you tell what the MTA
> (is that right) is?
If I'm not wrong, it works with Sendmail *and* Sendmail-compatible MTAs
such as Postfix or Qmail. But you must be aware that -f sets the
Return-Path address, not the From header: they're different things.
> Also, how would you include a BCC or Reply To with that?
These are regular headers: just append them to the fourth parameter of
mail():
mail('nobody@example.com', 'the subject', 'the message',
"From: webmaster@example.com\nBcc: foo@example.com\nReply-To:
bar@example.com',
'-fwebmaster@example.com');
> On a related note, what's with CR LF I see in the examples. I see there
> are some issues with the CR, can I simple do this?:
[quoted text clipped - 5 lines]
>
> and expect that to work?
Short answer: yes. Specs say that e-mail should use \r\n but \n tends to
work in practice and I've even seen \r\n failing some times...
Just be careful with $header; if extra line feeds get added, headers will
jump to the message body.

Signature
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Peter H. Coffin - 27 Jul 2008 17:19 GMT
> *** Jeff escribió/wrote (Thu, 24 Jul 2008 09:27:37 -0400):
>> I see that you can add headers, and these days it is essential to have a
[quoted text clipped - 11 lines]
> such as Postfix or Qmail. But you must be aware that -f sets the
> Return-Path address, not the From header: they're different things.
And you need both, not necessarily set to the same thing. The From: can
go to the email address for someone to answer questions, the From_ needs
to go to someone (or some process) that handles undeliverable mail.
Neither should be set to a "noreply" or invalid or nonfunctional
address. Some anti-spam measures will check either or both for
functionality.

Signature
36. I will not imprison members of the same party in the same cell block, let
alone the same cell. If they are important prisoners, I will keep the only
key to the cell door on my person instead of handing out copies to every
bottom-rung guard in the prison. --Peter Anspach's Evil Overlord List
Jeff - 30 Jul 2008 22:57 GMT
>> *** Jeff escribió/wrote (Thu, 24 Jul 2008 09:27:37 -0400):
>>> I see that you can add headers, and these days it is essential to have a
[quoted text clipped - 17 lines]
> address. Some anti-spam measures will check either or both for
> functionality.
Can you talk a bit more about the Return Path? How would you set that as
a header?
And, I understand that some mail clients look at something like a
return path and this should be set somewhere on the site for the server
to check. I'm quite hazy on all this and any clarification would be a
huge help.
Jeff