Web Toolbar by Wibiya phpmailer() script example
   Home   Help Login Register  
Welcome, Guest. Please login or register.

Login with username, password and session length

Search
Pages: [1]
Print
Topic: phpmailer() script example  (Read 8654 times)
0 Members and 1 Guest are viewing this topic.
« on: September 23, 2009, 01:11:33 PM »
Janak
Administrator
Full Member

View Profile
*****
Posts: 160



Most of the hosting providers disable nobody user on their server to send mail through script without SMTP authentication. In such cases, you have to use SMTP authentication to send mail through PHP, ASP, or ASP.Net script. phpmailer() is a very good SMTP authentication script to send emails using PHP script. Below is an example:

<?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: PHPMailer must be installed on the server. For more information, go to http://phpmailer.sourceforge.net/

Thanks,
Logged

Pages: [1]
Print
Jump to:  

� 2006 VPS forum, VPS hosting forums, VPS discussions, VPS web hosting solutions, issues, providers, virtual web hosting questions, VPS hosting
Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC | Forum style designed by PixelSlot
| Sitemap - XML Sitemap