View Single Post
Old 01-05-2007, 10:21 PM   PM User | #11
apachehtaccess
New to the CF scene

 
Join Date: Jan 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
apachehtaccess is an unknown quantity at this point
Sending HTML email with PHP

I read a really good article about the PHP emailing program PHPmailer and decided to check it out.

Heres how I use it to send HTML emails on my sites:

Code:
<?php
require("class.phpmailer.php");
require("class.smtp.php");

class MyMailer extends PHPMailer {
    public $From = "form-results@google";
    public $FromName = "Google.com";
    public $Host = "mail.google";
    public $Hostname = "google";
    public $Mailer = "smtp";
    public $Sender = "form-results@google";
    public $SMTPAuth = true;
    public $Username = "form-results@google";
    public $Password = "youwish";
}


$emailresults = '<html><head><title></title></head><body>
<div style="position:relative; margin:40px 0; padding:1px;">'.$myformss.$debugger.$mess.'</div></body></html>';

session_start();

if(!isset($_SESSION['mailsent'])) $_SESSION['mailsent']=0;
else $_SESSION['mailsent']++;


if ($_SESSION["mailsent"] < 10) {
    $_SESSION["mailsent"]++;
    $mail = new MyMailer();
    $mail->IsHTML(true);
    $mail->AddAddress("post-to-blog@google");
    $mail->AddBCC("webmaster@google");
    $mail->Subject = $mysubject;
    $mail->Body = $emailresults;
    $mail->AltBody = "You are viewing this message because your email client is not configured for html emails.$mess";
    $mail->SetLanguage('en');
    if(!$mail->Send())
    {
        $mail->ClearAllRecipients();
        echo "Message was not sent<br>";
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else $mail->ClearAllRecipients();
    
} else die('MAILSENT OVER LIMIT!');

?>
apachehtaccess is offline   Reply With Quote