Advertisement
sb2014

phpmailer

Feb 23rd, 2019
244
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 = 'no-reply@blackfirefly.org'; // 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('no-reply@blackfirefly.org', 'BlackFirefly');
  15. $mail->addAddress('sb2014@hotmail.de', 'Steffen Barthel'); // Add a recipient
  16. // $mail->addAddress('ellen@example.com'); // Name is optional
  17. $mail->addReplyTo('support@blackfirefly.org', 'BlackFirefly');
  18. // $mail->addCC('cc@example.com');
  19. // $mail->addBCC('bcc@example.com');
  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
Advertisement