sb2014

phpmailer

Feb 23rd, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. $mail = new PHPMailer(true); // Passing `true` enables exceptions
  2. try {
  3. //Server settings
  4. $mail->SMTPDebug = 2; // Enable verbose debug output
  5. $mail->isSMTP(); // Set mailer to use SMTP
  6. $mail->Host = 'plesk.blackfirefly.org'; // Specify main and backup SMTP servers
  7. $mail->SMTPAuth = true; // Enable SMTP authentication
  8. $mail->Username = '[email protected]'; // SMTP username
  9. $mail->Password = 'passwort' // SMTP password
  10. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl/tls` also accepted
  11. $mail->Port = 25; // TCP port to connect to
  12.  
  13. //Recipients
  14. $mail->setFrom('[email protected]', 'BlackFirefly');
  15. $mail->addAddress('[email protected]', 'Steffen Barthel'); // Add a recipient
  16. // $mail->addAddress('[email protected]'); // Name is optional
  17. $mail->addReplyTo('[email protected]', 'BlackFirefly');
  18. // $mail->addCC('[email protected]');
  19. // $mail->addBCC('[email protected]');
  20.  
  21. //Attachments
  22. // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  23. // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  24.  
  25. //Content
  26. $mail->isHTML(true); // Set email format to HTML
  27. $mail->Subject = 'Here is the subject';
  28. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  29. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  30.  
  31. $mail->send();
  32. echo 'Message has been sent';
  33. } catch (Exception $e) {
  34. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment