Web Hosting Forum - A Web Hosting community for Webmasters


Divi WordPress Theme

Author Topic: send mail using SMTP authentication :: phpmailer script  (Read 11570 times)

0 Members and 1 Guest are viewing this topic.

Offline Kailash

  • Administrator
  • Web Hosting Master
  • *****
  • Posts: 601
  • iTrader: +153/-0
    • View Profile
send mail using SMTP authentication :: phpmailer script
« on: February 04, 2007, 01:42:44 PM »
Hi,

Now a day, most of the hosting providers disable nobody user on their server or do not allow to send mail through script without SMTP authentication to stop the spamming from their servers. In such cases, you have to use SMTP authentication to send mail through PHP, ASP, or ASP.Net script. Below is the sample SMTP authentication script to send mail through PHP script:

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

$mail = new PHPMailer();

$mail->IsSMTP();                                // send via SMTP
$mail->Host     = "smtp.domain.com"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "email@domain.com";   // SMTP username
$mail->Password = "password"; // SMTP password

$mail->From     = "email@domain.com";
$mail->FromName = "Name";
$mail->AddAddress("Recipient@emailaddress.com","Name");
$mail->AddReplyTo("yourname@domain.com","Your Name");

$mail->WordWrap = 50;                              // set word wrap
 
$mail->IsHTML(true);                               // send as HTML

$mail->Subject  =  "Here is the subject";
$mail->Body     =  "This is the <b>HTML body</b>";
$mail->AltBody  =  "This is the text-only body";

if(!$mail->Send())
{
   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

?>

Note: To use above script, PHPMailer must be installed on the server. For more information, go to https://github.com/PHPMailer/PHPMailer

Thanks,
« Last Edit: November 15, 2015, 01:27:45 AM by Kailash »

Divi WordPress Theme
Tags:
 

Related Topics

  Subject / Started by Replies Last post
0 Replies
5392 Views
Last post September 30, 2007, 02:29:35 PM
by Tech
0 Replies
5934 Views
Last post November 30, 2008, 10:47:40 AM
by Kailash
0 Replies
480 Views
Last post December 14, 2014, 07:53:50 PM
by wRick
3 Replies
2715 Views
Last post March 12, 2015, 10:32:53 AM
by Kailash
4 Replies
999 Views
Last post March 20, 2015, 12:12:45 AM
by utsav