Advertisement
Guest User

Untitled

a guest
Nov 14th, 2013
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function email($to, $subject, $body) {
  2. require_once('_swiftmailer/lib/swift_required.php');
  3.  
  4. try {
  5. $transport = Swift_SmtpTransport::newInstance('localhost');
  6. $mailer = Swift_Mailer::newInstance($transport);
  7.  
  8. // change hostname and port
  9. $mailer->getTransport()
  10. ->setHost('smtp.domain.com')
  11. ->setPort(666);
  12.  
  13. $message = Swift_Message::newInstance()
  14. ->setFrom('from@domain.com', 'From name')
  15. ->setTo($to)
  16. ->setSubject($subject)
  17. ->setBody($body, 'text/html')
  18. ;
  19. return $mailer->send($message);
  20.  
  21. } catch (Exception $e) {
  22. return false;
  23. }
  24. }
  25.  
  26. email('send@mail.to', 'subject', 'body');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement