Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > PHP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-2008, 01:27 PM
Jeff
 
Posts: n/a
mail questions

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



Reply With Quote
  #2 (permalink)  
Old 07-24-2008, 02:57 PM
GYates
 
Posts: n/a
Re: mail questions

On Jul 24, 9:27*am, Jeff <jeff@spam_me_not.com> wrote:
> * 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('nob...@example.com', 'the subject', 'the message', null,
> * * '-fwebmas...@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


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
Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 05:03 PM
=?iso-8859-1?Q?=C1lvaro?= G. Vicario
 
Posts: n/a
Re: mail questions

*** 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".
>
> 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?


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?:
>
> $header=<<<'thisdata'
> From: some_from
> BCC: some blind copy
> thisdata;
>
> 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.


--
-- 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
--
Reply With Quote
  #4 (permalink)  
Old 07-27-2008, 04:19 PM
Peter H. Coffin
 
Posts: n/a
Re: mail questions

On Thu, 24 Jul 2008 19:03:12 +0200, Álvaro G. Vicario wrote:
> *** 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".
>>
>> 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?

>
> 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.


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.

--
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
Reply With Quote
  #5 (permalink)  
Old 07-30-2008, 09:57 PM
Jeff
 
Posts: n/a
Re: mail questions

Peter H. Coffin wrote:
> On Thu, 24 Jul 2008 19:03:12 +0200, Álvaro G. Vicario wrote:
>> *** 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".
>>>
>>> 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?

>> 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.

>
> 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.


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
>

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > PHP


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:30 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109