Re: PHP's mail(): proper way to send a 'From' header

From: Date: Tue, 08 Jul 2008 00:08:15 +0000
Subject: Re: PHP's mail(): proper way to send a 'From' header
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-276421@lists.php.net to get a copy of this message
> <?php > > $to = "email1@example.com"; > > $from = "email2@example.org"; > > $subject = "This is a test!"; > > $body = "\tThis is a test email.\n"; > $body .= "That is all."; > > $headers = "From: ".$from."\r\n"; > $headers .= "Reply-To: ".$from."\r\n"; > $headers .= "X-Mailer: > ".basename(__FILE__)."-PHP/".phpversion()."\r\n"; > $headers .= "Return-Path: ".$from."\r\n"; > > mail($to,$subject,$body,$headers,'-f'.$from); > ?> > > Note the fifth parameter passed to mail(): > > http://php.net/mail > And also note that the 5th parameter is an email address only.. Don't do something like: <?php $from = "Me <email@example.org>"; and try to use that as the 5th parameter, it won't work. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#276421) next »