473,320 Members | 1,883 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,320 software developers and data experts.

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('n*****@example.com', 'the subject', 'the message', null,
'-**********@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

Jul 24 '08 #1
4 1382
On Jul 24, 9:27*am, Jeff <jeff@spam_me_not.comwrote:
* 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: ex*****@example.com" . "\r\n" . "Cc:
ex******@example.com" . "\r\n" . "Bcc: ex******@example.com" . "\r
\n" . "Reply-To:ex******@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
Jul 24 '08 #2
*** 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('n*****@example.com', 'the subject', 'the message', null,
'-**********@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('n*****@example.com', 'the subject', 'the message',
"From: we*******@example.com\nBcc: fo*@example.com\nReply-To:
ba*@example.com',
'-**********@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
--
Jul 24 '08 #3
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('n*****@example.com', 'the subject', 'the message', null,
'-**********@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
Jul 27 '08 #4
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('n*****@example.com', 'the subject', 'the message', null,
'-**********@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
>
Jul 30 '08 #5

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

Similar topics

4
by: Geoff Soper | last post by:
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...
2
by: knoak | last post by:
Hi there, I've found a script at these great Google fora. a script to send emails with attachments. The script is below this message, name etc. aren't mine, but from the original post. My...
0
by: BigSizeXXL | last post by:
hi, i'm new to python and have a couple of questions about working with smtp. i read that you need a pop3 service for receiving mails. i want to create my own (private) mail service. i'm using a...
3
by: Alessandro Brollo | last post by:
Far from a professional programmer, I'm simply a newbie Python user. Two basic questions: 1. I don't want to post banal questions about Python to main Python list. Does a "banal Python questions...
3
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it...
7
by: GeorgeAtkins | last post by:
I want to create a web-based form or page that consists of a series of formatted questions and answers. The form will resemble an existing paper form. When the form is filled in, I want the user to...
6
by: Zeeway | last post by:
hi,everybody I use dotnet 2005 and c sharp to deliever a mail to a certain mail address,but it failed with messages such as "invalid parameter,the server response: decode failed". My codes is...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
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...
0
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.