/** * Create an email message. The ppMailer plugin class is * basically a factory class that returns a ppMailer_Message object * that can be manipulated before being sent. * * @return object */ function create($to = '', $subject = '', $body = '', $fromemail = '', $fromname = '') { $this->_load(); $swift = new ppMailer_Message(); if (defined('SMTP_HOST') && SMTP_HOST != '') { require_once DIR_FS_PRONTO . DS . 'extlib' . DS . 'swift' . DS . 'Swift' . DS . 'Connection' . DS . 'SMTP.php'; $port = defined('SMTP_PORT') ? SMTP_PORT : 25; $mode = SWIFT_SMTP_ENC_OFF; if (defined('SMTP_ENC')) { switch (SMTP_ENC) { case 'TLS': $mode = SWIFT_SMTP_ENC_TLS; break; case 'SSL': $mode = SWIFT_SMTP_ENC_SSL; break; } } $conn = new Swift_Connection_SMTP(SMTP_HOST, $port, $mode); } else { require_once DIR_FS_PRONTO . DS . 'extlib' . DS . 'swift' . DS . 'Swift' . DS . 'Connection' . DS . 'NativeMail.php'; $conn = new Swift_Connection_NativeMail(); } if (defined('SMTP_USER') && SMTP_USER != '') { $conn->setUsername(SMTP_USER); $conn->setPassword(SMTP_PASS); } $swift->swift = new Swift($conn); $swift->message = new Swift_Message($subject); $swift->message->setCharset(defined('CHARSET') ? CHARSET : 'UTF-8'); if ($body) { $swift->add_text_part($body); } $swift->recipients = new Swift_RecipientList(); // we need a non-empty default $swift->set_from(defined('ADMIN_EMAIL') ? ADMIN_EMAIL : '*****@*****.**'); if ($fromemail) { $swift->set_from($fromemail, $fromname); } if (is_array($to)) { foreach ($to as $email => $name) { if (is_numeric($email)) { $swift->add_recipient($name); } else { $swift->add_recipient($email, $name); } } } else { if ($to) { $swift->add_recipient($to); } } return $swift; }