Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you load PHPMailer into or where do you get PHPMailer to use in this instance?

PHP
<?php
require_once('class.phpmailer.php');
//
$mail             = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "ssl://smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "gmail@gmail.com";  // GMAIL username
$mail->Password   = "pass1";            // GMAIL password

$mail->From('gmail@gmail.com');

//$mail->AddReplyTo("gmail@gmail.com");

$mail->Subject    = $subject;

//$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->Body=$body;

$mail->AddAddress($email);

//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>
Posted
Updated 21-Jun-14 3:04am
v2
Comments
[no name] 21-Jun-14 9:09am    
What?
Teledextri 21-Jun-14 9:42am    
I downloaded 'class.phpmailer.php'. It is giving me an error on "require_once".
Teledextri 21-Jun-14 9:47am    
Is there a better way?

1 solution

Check this out: PHPMailer tutorial[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900