/
bear
/
opencorpora
Обзор
Документация
Войти
/
bear
/
opencorpora
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lib/lib_mail.php
24 строки
958 B
Dmitry Granovsky
use smtp for sending mails, closes #85
17 сен 2014, 20:17
17 сен 2014, 20:17
e9c7f35
Код
Авторство
О чём код?
<?php function send_email($to, $header, $body) { //$to may be either an array or a comma-separated string if (!is_array($to)) $to = explode(',', $to); // Create the message $message = Swift_Message::newInstance() // Give the message a subject ->setSubject($header) // Set the From address with an associative array ->setFrom(array('robot@opencorpora.org' => 'OpenCorpora')) // Set the To addresses with an associative array ->setTo($to) // Give it a body ->setBody($body); // Create the Transport global $config; $transport = Swift_SmtpTransport::newInstance($config['mail']['host'], $config['mail']['port'], $config['mail']['encrypt']) ->setUsername($config['mail']['user']) ->setPassword($config['mail']['password']); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); return $mailer->send($message); }