Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function email($to, $subject, $body) {
- require_once('_swiftmailer/lib/swift_required.php');
- try {
- $transport = Swift_SmtpTransport::newInstance('localhost');
- $mailer = Swift_Mailer::newInstance($transport);
- // change hostname and port
- $mailer->getTransport()
- ->setHost('smtp.domain.com')
- ->setPort(666);
- $message = Swift_Message::newInstance()
- ->setFrom('from@domain.com', 'From name')
- ->setTo($to)
- ->setSubject($subject)
- ->setBody($body, 'text/html')
- ;
- return $mailer->send($message);
- } catch (Exception $e) {
- return false;
- }
- }
- email('send@mail.to', 'subject', 'body');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement