Guest User

Untitled

a guest
Jan 18th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. /* You need to download php-mailer class
  2. https://github.com/PHPMailer/PHPMailer */
  3.  
  4. print_r(send_mail('vinodyadavhhh4@gmail.com','Lorem Ipsum','anything....'));
  5.  
  6. function send_mail($email, $recipient_name, $message='')
  7. {
  8. require("phpmailer/class.phpmailer.php");
  9. require("phpmailer/class.smtp.php");
  10.  
  11. $mail = new PHPMailer();
  12.  
  13. $mail->CharSet="utf-8";
  14. $mail->IsSMTP(); // set mailer to use SMTP
  15. $mail->Host = "mail.example.com"; // specify main and backup server
  16. $mail->SMTPAuth = true; // turn on SMTP authentication
  17. $mail->Username = "myusername"; // SMTP username
  18. $mail->Password = "p@ssw0rd"; // SMTP password
  19.  
  20. $mail->From = "me@walalang.com";
  21. $mail->FromName = "System-Ad";
  22. $mail->AddAddress($email, $recipient_name);
  23.  
  24. $mail->WordWrap = 50; // set word wrap to 50 characters
  25. $mail->IsHTML(true); // set email format to HTML (true) or plain text (false)
  26.  
  27. $mail->Subject = "This is a Sampleenter code here Email";
  28. $mail->Body = $message;
  29. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  30. $mail->AddEmbeddedImage('images/logo.png', 'logo', 'logo.png');
  31. $mail->addAttachment('files/file.xlsx');
  32.  
  33. if(!$mail->Send())
  34. {
  35. echo "Message could not be sent. <p>";
  36. echo "Mailer Error: " . $mail->ErrorInfo;
  37. exit;
  38. }
  39.  
  40. echo "Message has been sent";
  41. }
Add Comment
Please, Sign In to add comment