Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. <?
  2.  
  3. namespace helpers\mail;
  4.  
  5. class MailHelper {
  6.  
  7. public static function welcome($playername, $password, $email, $email_ip = false) {
  8.  
  9.  
  10. $mail = new \PHPMailer();
  11.  
  12. $mail->IsSMTP(true); // send via SMTP
  13.  
  14. $mail->SMTPAuth = true; // turn on SMTP authentication
  15. $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
  16. $mail->SMTPAuth = true; // authentication enabled
  17. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  18. $mail->Host = 'smtp.gmail.com';
  19. $mail->Port = 465;
  20. $mail->Username = PHPMAILER_USERNAME; // SMTP username
  21. $mail->Password = PHPMAILER_PASSWORD; // SMTP password
  22. $webmaster_email = PHPMAILER_EMAIL; //Reply to this email ID
  23.  
  24. $name = $playername; // Recipient's name
  25. $mail->From = $webmaster_email;
  26. $mail->FromName = "Comunidade Minecraft Portugal";
  27. $mail->AddAddress($email,$name);
  28. $mail->WordWrap = 50; // set word wrap
  29. $mail->IsHTML(true); // send as HTML
  30.  
  31. $mail->Subject = "Comunidade Minecraft Portugal: Registo!";
  32. $body = file_get_contents(WEB_ROOT . "/templates/email/registo.html");
  33. $body = str_replace('$playername', $playername, $body);
  34. $body = str_replace('$password', $password, $body);
  35.  
  36. if ($email_ip) {
  37. $body = str_replace('$ip', $_SERVER['REMOTE_ADDR'], $body);
  38. } else {
  39. $body = str_replace('$ip', "Server Administrator", $body);
  40. }
  41. $mail->Body = $body;
  42. $mail->AltBody = strip_tags($body); //Text Body
  43.  
  44. if(!$mail->Send()) {
  45. die("Mailer Error: " . $mail->ErrorInfo);
  46. }
  47. }
  48. }
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement