Guest User

Untitled

a guest
Jan 5th, 2018
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. $mail = new PHPMailer(false); // Passing `true` enables exceptions
  2.  
  3. //Server settings
  4. //$mail->SMTPDebug = 1;//Enable verbose debug output
  5. $mail->isSMTP();//Set mailer to use SMTP
  6. $mail->Host = 'smtp host';//Specify main and backup SMTP servers
  7. $mail->SMTPAuth = true;//Enable SMTP authentication
  8. $mail->Username = 'user';//SMTP username
  9. $mail->Password = 'password';//SMTP password
  10. $mail->SMTPSecure = 'tls';//Enable TLS encryption, `ssl` also accepted
  11. $mail->Port = 587;//TCP port to connect to
  12.  
  13.  
  14. //Recipients
  15. $mail->setFrom('example@example.com','myapp');
  16. $mail->addAddress('hi@examle.com');//Add a recipient
  17. //$mail->addAddress('ellen@example.com');//Name is optional
  18. $mail->addReplyTo('support@example.com','Contact');
  19.  
  20.  
  21.  
  22. //Content
  23. $mail->isHTML(true);//Set email format to HTML
  24. $mail->Subject = 'test';
  25.  
  26. $mail->Body = 'this is a test';
  27.  
  28.  
  29. $mail->send();
  30.  
  31. $mail->isSMTP();//Set mailer to use SMTP
  32. $mail->Host = 'smtp host';//Specify main and backup SMTP servers
  33. $mail->SMTPAuth = true;//Enable SMTP authentication
  34. //Assuming SMTP_USERNAME is your environment variable which holds username
  35. $mail->Username = getenv('SMTP_USERNAME');
  36. //Assuming SMTP_PASSWORD is your environment variable which holds password
  37. $mail->Password = getenv('SMTP_PASSWORD');
  38. $mail->SMTPSecure = 'tls';//Enable TLS encryption, `ssl` also accepted
  39. $mail->Port = 587;//TCP port to connect to
Add Comment
Please, Sign In to add comment