Sending emails via phpmailer

Here we configure SMTP authentication Using phpmailer. You can acquire a copy of phpmailer class from You should upload the file "class.phpmailer.php" to same folder for your script

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

$mail = new PHPMailer();$mail = new PHPMailer();
$mail->CharSet ="utf-8"; // You can adjust the Charset according to your language
$mail->Host = "";
$mail->From=""; //REMEMBER, this MUST be same as your authorization email address above.
$mail->FromName="PHPmailer Testing";
$mail->SMTPAuth = true;
$mail->Username = "";
$mail->Password = "yourpassword";

$mail->Subject = "Test 1";
$mail->Body = "Test 1 of PHPMailer.";

   echo "Error sending: " . $mail->ErrorInfo;;
   echo "Letter is sent";

To add information about sender, use following functions:

$mail->Sender=""; // indicates ReturnPath header
$mail->AddReplyTo("", "Replies for my site"); // indicates ReplyTo headers

For specifying various types of recepients use these:

$mail->AddAddress("", "Recepient 1");
$mail->AddCC("", "Recepient 1");
$mail->AddBCC("", "Recepient 1");



- has written 121 posts.

Leave a Reply

You must be logged in to post a comment.