Guest User

Untitled

a guest
Oct 25th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2. require_once 'config.php';
  3. require '../../libs/phpmailer/src/Exception.php';
  4. require '../../libs/phpmailer/src/PHPMailer.php';
  5. require '../../libs/phpmailer/src/SMTP.php';
  6.  
  7. use PHPMailerPHPMailerPHPMailer;
  8. use PHPMailerPHPMailerException;
  9.  
  10. class Email{
  11. private $host;
  12. private $smtp_auth;
  13. private $username;
  14. private $password;
  15. private $port;
  16. private $from;
  17. private $name;
  18.  
  19. function __construct(){
  20. $this->host = HOST_EMAIL;
  21. $this->smtp_auth = SMTP_AUTH;
  22. $this->username = USER_EMAIL;
  23. $this->password = PASS_EMAIL;
  24. $this->port = PORT_EMAIL;
  25. $this->from = USER_EMAIL;
  26. $this->name = NAME_EMAIL;
  27. }
  28.  
  29. public function send($email, $name, $subject, $body, $file){
  30. $mail = new PHPMailer(true);
  31. $mail->isSMTP();
  32. $mail->Host = $this->host;
  33. $mail->SMTPAuth = $this->smtp_auth;
  34. $mail->Username = $this->username;
  35. $mail->Password = $this->password;
  36. $mail->Port = $this->port;
  37. $mail->setFrom($this->from, $this->name);
  38. $mail->addAddress($email, $name);
  39. if(isset($file) && $file != ''){
  40. $mail->addAttachment($file);
  41. }
  42. $mail->isHTML(true);
  43. $mail->Subject = utf8_decode($subject);
  44. $mail->Body = $body;
  45. $mail->send();
  46. }
  47. }
  48. ?>
Add Comment
Please, Sign In to add comment