Click here to Subscribe to Our RSS Feed
Powered by MaxBlogPress  

Here’s a sample for using SMTP. Webhost4life REQUIRES all customer to use SMTP authorization in order to send out email.

IMPORTANT:  From email address and your authorization email addres MUST be same.


< ?php
require(”class.phpmailer.php”);

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = “
mail.yourdomain.com“;  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = “youremail@yourdomain.com“;  // SMTP username
$mail->Password = “password of youremail@yourdomain.com“; // SMTP password

$mail->From = “youremail@yourdomain.com“;
$mail->FromName = “Sender Name”;
$mail->AddAddress(receiver@receiver.com, “Receiver Name”);

$mail->WordWrap = 50;                                 // set word wrap to 50 characters

$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = “Subject with phpmailer.”;
$mail->Body    = “Body with phpmailer.in bold!“;
$mail->AltBody = “This is the body in plain text for non-HTML mail clients”;

if(!$mail->Send())
{
echo “Message could not be sent.”;
echo “Mailer Error: ” . $mail->ErrorInfo;
exit;
}

echo “Message has been sent”;
?>



To add inforation about sender, use following functions:

$mail->From=youremail@yourdomain.com; //REMEMBER, this MUST be same as your authorization email address above.
$mail->FromName=”My site’s mailer”;
$mail->Sender=”mailer@example.com”; // indicates ReturnPath header
$mail->AddReplyTo(”replies@example.com”, “Replies for my site”); // indicates ReplyTo headers

For specifying various types of recepients use these:

$mail->AddAddress(”mail1@domain.com”, “Recepient 1″);
$mail->AddCC(”mail1@domain.com”, “Recepient 1″);
$mail->AddBCC(”mail1@domain.com”, “Recepient 1″);

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis
  • Yahoo! Buzz

If you're new here, you may want to subscribe to my Email Feed or RSS feed.
You can follow me on Twitter here http://www.Twitter.com/Webhost4life
Thanks for visiting!

Related posts brought to you by Yet Another Related Posts Plugin.

Tweet this Post: Twit this post

Comments

No Responses to “How do I send email using PHP with phpMailer class”

Write a Comment

CommentLuv Enabled