Advertisement
Guest User

How to send email from PHP without SMTP server installed

a guest
Mar 23rd, 2012
1,431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. $mail = new PHPMailer(true);
  4.  
  5. //Send mail using gmail
  6. if($send_using_gmail){
  7. $mail->IsSMTP(); // telling the class to use SMTP
  8. $mail->SMTPAuth = true; // enable SMTP authentication
  9. $mail->SMTPSecure = "ssl"; // sets the prefix to the servier
  10. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
  11. $mail->Port = 465; // set the SMTP port for the GMAIL server
  12. $mail->Username = "your-gmail-account@gmail.com"; // GMAIL username
  13. $mail->Password = "your-gmail-password"; // GMAIL password
  14. }
  15.  
  16. //Typical mail data
  17. $mail->AddAddress($email, $name);
  18. $mail->SetFrom($email_from, $name_from);
  19. $mail->Subject = "My Subject";
  20. $mail->Body = "Mail contents";
  21.  
  22. try{
  23. $mail->Send();
  24. echo "Success!";
  25. } catch(Exception $e){
  26. //Something went bad
  27. echo "Fail :(";
  28. }
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement