1

Possible Duplicate:
Send email using GMail SMTP server from PHP page

Hi

I want to send email using gmail server for my php site. Can anyone help me with the code using phpmailer for accomplishing this?

require("phpmailer/class.phpmailer.php");

$mail = new PHPMailer();    
$mail->IsSMTP(); // send via SMTP
IsSMTP(); // send via SMTP

$mail->SMTPAuth = true; // turn on SMTP authentication  
$mail->Username = "mail@domain.com"; // SMTP username
$mail->Password = "mailpass"; // SMTP password
$webmaster_email = "admin@frendzpark.com"; //Reply to this email ID
$email="sanksmr@gmail.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject"; 
$mail->Body = "Hi, This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body

if(!$mail->Send())
{
    echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
    echo "Message has been sent";
}
Community
  • 1
  • 1
  • what error do you get? can u append it here, also please format your code – Santosh Linkha Mar 03 '11 at 06:11
  • Warning: require(phpmailer/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in /home/fpark/public_html/phpmailer0.9/email.php on line 2 Warning: require(phpmailer/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory in /home/fpark/public_html/phpmailer0.9/email.php on line 2 Fatal error: require() [function.require]: Failed opening required 'phpmailer/class.phpmailer.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fpark/public_html/phpmailer0.9/email.php on line 2 – Sanket Raut Mar 03 '11 at 06:19
  • well you need to have file `class.phpmailer.php` in path `/phpmailer` and use @displayname to alert user and welcome to StackOVerflow – Santosh Linkha Mar 03 '11 at 06:22
  • @experimentX:I renamed phpmailer.inc.php to class.phpmailer.php and smtp.inc.php to class.smtp.php. But there's another error i get. issmtp function not found on line 5 in email.php – Sanket Raut Mar 03 '11 at 06:28
  • of course you need to remove `IsSMTP(); // send via SMTP ` on the piece of code ` – Santosh Linkha Mar 03 '11 at 06:31
  • Any place where i can get demo of phpmailer? – Sanket Raut Mar 03 '11 at 06:51

0 Answers0