NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Bcc Headers

Rolan Yang rolan at omnistep.com
Mon Aug 4 17:50:15 EDT 2008


Some mail servers will send out email using a default envelope like 
"apache at localhost.com" (even though the email header reads 
"From:member at sovsite.com").
The receiving mail server will see this domain as bogus and reject the 
email as spam. If this is done at the start of the smtp session, the 
recipient will never even see it. Try adding this additional parameter 
to your mail function:

mail("greg at lioncube.com <mailto:greg at lioncube.com>", "test", "test", 
$headers,'-f member at sovsite.com');

The "-f" passes the value to sendmail or postfix to use as the envelope 
sender.

~Rolan


(Margaret) Michele Waldman wrote:
>
> I did resort to calling mail() twice. I hated doing it.
>
> Then he called me and said there was no from on the email and the 
> client isn’t getting the email, which made me think it was a header 
> issue again.
>
> However, My testing shows there is a from.
>
> I think the email in question has spam filters set too high.
>
> ------------------------------------------------------------------------
>
> *From:* talk-bounces at lists.nyphp.org 
> [mailto:talk-bounces at lists.nyphp.org] *On Behalf Of *Patrick May
> *Sent:* Monday, August 04, 2008 3:47 PM
> *To:* NYPHP Talk
> *Subject:* Re: [nycphp-talk] PHP Bcc Headers
>
> Hello,
>
> I recommend following bzcoder's suggestion of using PHP Mailer, or 
> simply calling mail() twice:
>
> <?php
> $headers = "From: member at sovsite.com <mailto:member at sovsite.com>" . 
> "\r\n";
> $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
>
> mail("greg at lioncube.com <mailto:greg at lioncube.com>", "test", "test", 
> $headers);
> mail("mmwaldman at optonline.net <mailto:mmwaldman at optonline.net>", 
> "test", "test", $headers);
> ?>
>
> Cheers,
>
> Patrick
>
> On Mon, Aug 4, 2008 at 3:40 PM, (Margaret) Michele Waldman 
> <mmwaldman at optonline.net <mailto:mmwaldman at optonline.net>> wrote:
>
> I have a test script already.
>
> Bcc doesn't work on either.
>
> <?php
> $headers = "From: member at sovsite.com <mailto:member at sovsite.com>" . 
> "\r\n";
> $headers .= "Bcc: mmwaldman at optonline.net 
> <mailto:mmwaldman at optonline.net>" . "\r\n";
> $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
>
> mail("greg at lioncube.com <mailto:greg at lioncube.com>", "test", "test", 
> $headers);
> ?>
>
> And
>
> <?php
> $headers = "From: member at sovsite.com <mailto:member at sovsite.com>" . "\n";
> $headers .= "Bcc: mmwaldman at optonline.net 
> <mailto:mmwaldman at optonline.net>" . "\n";
> $headers .= "X-Mailer: PHP/" . phpversion() . "\n";
>
> mail("greg at lioncube.com <mailto:greg at lioncube.com>", "test", "test", 
> $headers);
> ?>
>
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org 
> <mailto:talk-bounces at lists.nyphp.org> 
> [mailto:talk-bounces at lists.nyphp.org 
> <mailto:talk-bounces at lists.nyphp.org>] On
> Behalf Of csnyder
>
> Sent: Monday, August 04, 2008 3:37 PM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] PHP Bcc Headers
>
> On Mon, Aug 4, 2008 at 3:17 PM, (Margaret) Michele Waldman
> <mmwaldman at optonline.net <mailto:mmwaldman at optonline.net>> wrote:
> > I'm using "\r\n" at the end of each line.
> >
> > The headers are being completely ignored.
> >
> > I'll try switching. The did cross my mind before, but I wasn't sure what
> to
> > test other than "\r\n".
>
> Completely ignored is probably a bad sign, but you could try using just
> "\n".
>
> When that doesn't work, try setting just a single "X-sent-by: php"
> header to avoid line-ending issues altogether. It may be worth
> creating a test script that does nothing but send a simple email so
> you can isolate the problem from other potential bugs, post the code
> to this list for review, etc.
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
>
>
> -- 
> Patrick May
> 135 Oak Street
> Brooklyn, NY 11222
> +1 (347) 232-5208
> patrick at hexane.org <mailto:patrick at hexane.org>
> http://www.hexane.org
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php



More information about the talk mailing list