NYCPHP Meetup

NYPHP.org

[nycphp-talk] Botched email header

Chris Shiflett shiflett at php.net
Thu Jul 24 17:37:48 EDT 2003


--- Jeff <jsiegel1 at optonline.net> wrote:
> My concern is that I don't want the From address to have
> double-quotes around it.

In your email, the following is the From header used:

From: "Jeff" <jsiegel1 at optonline.net>

That is the format you want to achieve when you specify your own mail headers.
It really doesn't matter whether you *want* the format to be this way, because
that is not your decision. Does that make better sense now?

> Of course I can't let the emails go out with botched up headers
> but I'm leaning in the direction of a solution that would clean
> up these anomalies (which are a handful of cases) and leave the
> other stuff alone.

These aren't anomalies. Commas are fairly common within the name part of a From
header, and they don't require any special handling so long as you adhere to
the proper format as I initially suggested. The only potential problem would be
whether the name already contains a quotation mark (which is something you
should filter prior to the code in question) or some other invalid character
(\r\n would be bad, too). Along the same lines, you want to make sure the email
address is a valid email address. Assuming you have properly filtered your data
(which was my initial assumption), something as simple as this will work:

$from_header = "From: \"$name\" <$email>\r\n";

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/



More information about the talk mailing list