Пример #1
0
 public static function sendMailDirect($destinationemail, $subject, $message)
 {
     $GLOBALS['smtpError'] = '';
     ## try to deliver directly, so that any error (eg subscriber not found) can be sent back to the
     ## subscriber, so they can fix it
     //TODO: fix this, now using PHPLIST_DEVELOPER_EMAIL
     //unset($GLOBALS['developer_email']);
     list($htmlmessage, $textmessage) = phpListMailer::constructSystemMail($message, $subject);
     $mail = new phpListMailer('systemmessage', $destinationemail, false, true);
     list($dummy, $domain) = explode('@', $destinationemail);
     #print_r ($mxhosts);exit;
     $smtpServer = phpListMailer::getTopSmtpServer($domain);
     $fromemail = Config::get('message_from_address');
     $fromname = Config::get('message_from_name');
     $mail->Host = $smtpServer;
     $mail->Helo = Config::get('website');
     $mail->Port = 25;
     $mail->Mailer = 'smtp';
     if (!empty($htmlmessage)) {
         $mail->addHtml($htmlmessage, $textmessage, Config::get('systemmessagetemplate'));
         $mail->addText($textmessage);
     }
     $mail->addText($textmessage);
     try {
         $mail->Send('', $destinationemail, $fromname, $fromemail, $subject);
     } catch (\Exception $e) {
         //TODO: replace globals
         $GLOBALS['smtpError'] = $e->getMessage();
         return false;
     }
     return true;
 }