Re: [PHP] email with style (again)

2008-02-27 Thread Daniel Brown
On Tue, Feb 26, 2008 at 8:33 PM, tedd <[EMAIL PROTECTED]> wrote:
> Ok gang:
>
>  What's wrong with the following code?
[snip!]

The placement was wrong with the content-type info, that's all.
It should be in the headers, after your from/x-mailer/blah/blah/blah
envelope information.  Also, when starting a long string, the first
entry doesn't need to be dotted.  In fact, if that variable was
elsewhere populated already, you'll append on to that, rather than
re-instantiating the variable.  Of course, there's also HEREDOC to
consider but that's for a different email.  Here's the reworked
(and working - tested and all) code:

// Common Headers
$headers  = "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;

// HTML Version
$headers .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$msg = $body.$eol.$eol;

-- 


Daniel P. Brown
Senior Unix Geek


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] email with style (again)

2008-02-26 Thread Andrés Robinet
> -Original Message-
> From: tedd [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 26, 2008 8:33 PM
> To: php-general@lists.php.net
> Subject: [PHP] email with style (again)
> 
> Ok gang:
> 
> What's wrong with the following code?
> 
> It sends the email OK, but nothing is styled.
> 
> Where did I go wrong?
> 
> Thanks,
> 
> tedd
> 
> --- code
> 
>  
> $to = "[EMAIL PROTECTED]";
> $body = make_mail();
> $subject = "Subject";
> $fromaddress = "[EMAIL PROTECTED]";
> $fromname = "tedd";
> 
> send_mail($to, $body, $subject, $fromaddress, $fromname,
> $attachments=false);
> 
> echo('Email sent');
> 
> ?>
> 
> 
>  
> function make_mail()
> {
> $message = << 
> Title: A title of something
> Presenter: By someone
> 
> tedd
> 
> EOT;
> return $message;
> }
> 
> function send_mail($to, $body, $subject, $fromaddress, $fromname,
> $attachments=false)
> {
> $eol="\r\n";
> 
> // Common Headers
> $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
> $headers .= "X-Mailer: PHP v".phpversion().$eol;
> 
> // HTML Version
> $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
> $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
> $msg .= $body.$eol.$eol;

Shouldn't this be added?
$msg .= "MIME-Version: 1.0".$eol;
...

And, actually, shouldn't this be placed in the $headers variable? Like:

$headers = "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
$headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
$headers .= "X-Mailer: PHP v".phpversion(); // I REMOVED THE LAST $eol, IS IT
NECESSARY???

$msg .= $body.$eol.$eol;
...

> 
> // SEND THE EMAIL
> ini_set(sendmail_from,$fromaddress);
> $mail_sent = mail($to, $subject, $msg, $headers);
> 
> ini_restore(sendmail_from);
> 
> return $mail_sent;
> }
> ?>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> --

Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4207 | FAX 954-337-2695 | 
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |
 Web: bestplace.biz  | Web: seo-diy.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php