Guest User

PHP mailer

a guest
Feb 2nd, 2018
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. require_once "vendor/autoload.php";
  4.  
  5. //PHPMailer Object
  6. $mail = new PHPMailer;
  7.  
  8. //From email address and name
  9. $mail->From = "from@yourdomain.com";
  10. $mail->FromName = "Full Name";
  11.  
  12. //To address and name
  13. $mail->addAddress("recepient1@example.com", "Recepient Name");
  14. $mail->addAddress("recepient1@example.com"); //Recipient name is optional
  15.  
  16. //Address to which recipient will reply
  17. $mail->addReplyTo("reply@yourdomain.com", "Reply");
  18.  
  19. //CC and BCC
  20. $mail->addCC("cc@example.com");
  21. $mail->addBCC("bcc@example.com");
  22.  
  23. //Send HTML or Plain Text email
  24. $mail->isHTML(true);
  25.  
  26. $mail->Subject = "Subject Text";
  27. $mail->Body = "<i>Mail body in HTML</i>";
  28. $mail->AltBody = "This is the plain text version of the email content";
  29.  
  30. if(!$mail->send())
  31. {
  32. echo "Mailer Error: " . $mail->ErrorInfo;
  33. }
  34. else
  35. {
  36. echo "Message has been sent successfully";
  37. }
Add Comment
Please, Sign In to add comment