Sahitya-K

email phpmailer

Apr 1st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. <?php
  2. // Import PHPMailer classes into the global namespace
  3. // These must be at the top of your script, not inside a function
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. use PHPMailer\PHPMailer\Exception;
  6.  
  7. require 'PHPMailer/src/Exception.php';
  8. require 'PHPMailer/src/PHPMailer.php';
  9. require 'PHPMailer/src/SMTP.php';
  10.  
  11. $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  12. try {
  13.     //Server settings
  14.     $mail->SMTPDebug = 2;                                 // Enable verbose debug output
  15.     $mail->isSMTP();                                      // Set mailer to use SMTP
  16.     $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  17.     $mail->SMTPAuth = true;                               // Enable SMTP authentication
  18.     $mail->Username = 'icom';                 // SMTP username
  19.     $mail->Password = 'S8';                           // SMTP password
  20.     $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  21.     $mail->Port = 587;                                    // TCP port to connect to
  22.  
  23.     //Recipients
  24.     $mail->setFrom('inforus1968@gmail.com', 'Rus Gold');
  25.     $mail->addAddress($email, 'RUS GOLD USER');     // Add a recipient
  26.  
  27.     //Content
  28.     $mail->isHTML(true);                                  // Set email format to HTML
  29.     $mail->Subject = 'RUS GOLD Reset Password';
  30.     $mail->Body    = "  <h2 style='font-family: arial'>Hello, We are from RUS GOLD</h2>
  31. <p style='font-family: arial'>We just recived a Request saying You Forgot your password. Don't Worry you can Change your password by Clicking below Link</p>
  32. <a href=".$url."><button style='background-color:#5E0000;color:white;padding:14px 20px;margin:8px 0;border:0;cursor:pointer;width:20%;opacity:.9;'>Choose a new Password</button></a>
  33. <p style='font-family: arial'>If you don't have any idea about this, then you can ingore this E-mail. your RUS GOLD password will not change.</p>";
  34.     $mail->AltBody = "  <h2 style='font-family: arial'>Hello, We are from RUS GOLD</h2>
  35. <p style='font-family: arial'>We just recived a Request saying You Forgot your password. Don't Worry you can Change your password by Clicking below Link</p>
  36. <a href=".$url."><button style='background-color:#5E0000;color:white;padding:14px 20px;margin:8px 0;border:0;cursor:pointer;width:20%;opacity:.9;'>Choose a new Password</button></a>
  37. <p style='font-family: arial'>If you don't have any idea about this, then you can ingore this E-mail. your RUS GOLD password will not change.</p>";
  38.  
  39.     $mail->send();
  40. } catch (Exception $e) {
  41.     echo 'Message could not be sent. Mailer Error';//, //$mail->ErrorInfo
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment