Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include the PHPMailer classes
- // If these are located somewhere else, simply change the path.
- require_once("PHPMailer/class.phpmailer.php");
- require_once("PHPMailer/class.smtp.php");
- require_once("PHPMailer/language/phpmailer.lang-ar.php");
- // mostly the same variables as before
- // ($to_name & $from_name are new, $headers was omitted)
- $to_name = "tp mail";
- $to = "sunil.gandhi007@gmail.com";
- $subject = "Mail Test at ".strftime("%T", time());
- $message = "This is a test.";
- $message = wordwrap($message,70);
- $from_name = "sunil";
- $from = "sunil.gandhi007@gmail.com";
- // PHPMailer's Object-oriented approach
- $mail = new PHPMailer();
- // Can use SMTP
- // comment out this section and it will use PHP mail() instead
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->Host = "smtp.gmail.com"; // SMTP server
- // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only
- $mail->SMTPDebug = 2;
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->SMTPSecure = "tls"; // sets the prefix to the servier
- $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
- $mail->Port = 587; // set the SMTP port for the GMAIL server
- $mail->Username = "sunil.gandhi007@gmail.com"; // GMAIL username
- $mail->Password = "***************"; // GMAIL password
- $mail->FromName = $from_name;
- $mail->From = $from;
- $mail->AddAddress($to, $to_name);
- $mail->Subject = $subject;
- $mail->Body = $message;
- $result = $mail->Send();
- echo $result ? 'Sent' : 'Error';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement