function SendNotify($Rcpts = array(), $Subject = "", $Body = "") { require_once agEGW_APPLICATION_PATH . '/phpgwapi/inc/class.phpmailer.inc.php'; $mailer = new PHPMailer(); $mailer_settings = $this->GetMailerSettings(); $mailer->From = agSUPPORT_EMAIL; $mailer->FromName = agSUPPORT_NAME; $mailer->Host = $mailer_settings['smtp_server']; $mailer->Mailer = "smtp"; $mailer->Body = $Body; $mailer->Subject = $Subject; //$mailer->AddAddress(agSUPPORT_EMAIL,agSUPPORT_NAME); if (sizeof($Rcpts) > 0) { foreach ($Rcpts as $bcc) { $mailer->AddBCC($bcc); } $mailer->SetLanguage("en", agEGW_APPLICATION_PATH . '/phpgwapi/setup/'); if (!$mailer->Send()) { // echo "<!--There has been a mail error sending: \n".$mailer->ErrorInfo."-->"; return False; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); } return True; }
function sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message, $type = "plain", $cc = "", $bcc = "") { global $settings, $locale; require_once INCLUDES . "class.phpmailer.php"; $mail = new PHPMailer(); if (file_exists(INCLUDES . "language/phpmailer.lang-" . $locale['phpmailer'] . ".php")) { $mail->SetLanguage($locale['phpmailer'], INCLUDES . "language/"); } else { $mail->SetLanguage("en", INCLUDES . "language/"); } if (!$settings['smtp_host']) { $mail->IsMAIL(); } else { $mail->IsSMTP(); $mail->Host = $settings['smtp_host']; $mail->Port = $settings['smtp_port']; $mail->SMTPAuth = $settings['smtp_auth'] ? true : false; $mail->Username = $settings['smtp_username']; $mail->Password = $settings['smtp_password']; } $mail->CharSet = $locale['charset']; $mail->From = $fromemail; $mail->FromName = $fromname; $mail->AddAddress($toemail, $toname); $mail->AddReplyTo($fromemail, $fromname); if ($cc) { $cc = explode(", ", $cc); foreach ($cc as $ccaddress) { $mail->AddCC($ccaddress); } } if ($bcc) { $bcc = explode(", ", $bcc); foreach ($bcc as $bccaddress) { $mail->AddBCC($bccaddress); } } if ($type == "plain") { $mail->IsHTML(false); } else { $mail->IsHTML(true); } $mail->Subject = $subject; $mail->Body = $message; if (!$mail->Send()) { $mail->ErrorInfo; $mail->ClearAllRecipients(); $mail->ClearReplyTos(); return false; } else { $mail->ClearAllRecipients(); $mail->ClearReplyTos(); return true; } }
function PHPlistMailer($messageid, $email) { # parent::PHPMailer(); parent::SetLanguage('en', dirname(__FILE__) . '/phpmailer/language/'); $this->addCustomHeader("X-Mailer: phplist v" . VERSION); $this->addCustomHeader("X-MessageID: {$messageid}"); $this->addCustomHeader("X-ListMember: {$email}"); # $this->addCustomHeader("Precedence: bulk"); #http://mantis.phplist.com/view.php?id=15562 $this->CharSet = getConfig("html_charset"); if (defined('PHPMAILERHOST') && PHPMAILERHOST != '') { //logEvent('Sending email via '.PHPMAILERHOST); $this->SMTPAuth = true; $this->Helo = getConfig("website"); $this->Host = PHPMAILERHOST; if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '' && isset($GLOBALS['phpmailer_smtppassword']) && $GLOBALS['phpmailer_smtppassword']) { $this->Username = $GLOBALS['phpmailer_smtpuser']; $this->Password = $GLOBALS['phpmailer_smtppassword']; } $this->Mailer = "smtp"; } else { # logEvent('Sending via mail'); $this->Mailer = "mail"; } //$ip = gethostbyname($this->Host); if ($GLOBALS["message_envelope"]) { $this->Sender = $GLOBALS["message_envelope"]; $this->addCustomHeader("Errors-To: " . $GLOBALS["message_envelope"]); } }
function PHPlistMailer($messageid, $email) { # parent::PHPMailer(); parent::SetLanguage('en', 'phpmailer/language/'); $this->addCustomHeader("X-Mailer: phplist v" . VERSION); $this->addCustomHeader("X-MessageID: {$messageid}"); $this->addCustomHeader("X-ListMember: {$email}"); $this->addCustomHeader("Precedence: bulk"); $this->Host = PHPMAILERHOST; $this->Helo = getConfig("website"); $this->CharSet = getConfig("html_charset"); if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '') { $this->SMTPAuth = true; $this->Username = $GLOBALS['phpmailer_smtpuser']; $this->Password = $GLOBALS['phpmailer_smtppassword']; # logEvent('Sending authenticated email via '.PHPMAILERHOST); } $ip = gethostbyname($this->Host); if ($GLOBALS["message_envelope"]) { $this->Sender = $GLOBALS["message_envelope"]; $this->addCustomHeader("Errors-To: " . $GLOBALS["message_envelope"]); } if (!$this->Host || $ip == $this->Host) { $this->Mailer = "mail"; # logEvent('Sending via mail'); } else { $this->Mailer = "smtp"; # logEvent('Sending via smtp'); } }
/** * Test language files for missing and excess translations * All languages are compared with English */ function test_Translations() { $this->Mail->SetLanguage('en'); $definedStrings = $this->Mail->GetTranslations(); $err = ''; foreach (new DirectoryIterator('../language') as $fileInfo) { if ($fileInfo->isDot()) { continue; } $matches = array(); //Only look at language files, ignore anything else in there if (preg_match('/^phpmailer\\.lang-([a-z_]{2,})\\.php$/', $fileInfo->getFilename(), $matches)) { $lang = $matches[1]; //Extract language code $PHPMAILER_LANG = array(); //Language strings get put in here include $fileInfo->getPathname(); //Get language strings $missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG)); $extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings)); if (!empty($missing)) { $err .= "\nMissing translations in {$lang}: " . implode(', ', $missing); } if (!empty($extra)) { $err .= "\nExtra translations in {$lang}: " . implode(', ', $extra); } } } $this->assertEmpty($err, $err); }
function sendEmail($senderName, $senderEmail, $name, $email, $subject, $message) { include_once ROOT . "/library/contrib/phpmailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->SetLanguage('en', ROOT . "/library/contrib/phpmailer/language/"); $mail->IsHTML(true); $mail->CharSet = 'utf-8'; $mail->From = $senderEmail; $mail->FromName = $senderName; $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = 'To view this email message, open the email with html enabled mailer.'; $mail->AddAddress($email, $name); if (!Setting::getServiceSettingGlobal('useCustomSMTP', 0)) { $mail->IsMail(); } else { $mail->IsSMTP(); $mail->Host = Setting::getServiceSettingGlobal('smtpHost', '127.0.0.1'); $mail->Port = Setting::getServiceSettingGlobal('smtpPort', 25); } ob_start(); $ret = $mail->Send(); ob_clean(); if (!$ret) { return array(false, $mail->ErrorInfo); } return true; }
/** * Inner mailer initialization from set variables * * @return void */ protected function initMailFromSet() { $this->mail->SetLanguage($this->get('langLocale'), $this->get('langPath')); $this->mail->CharSet = $this->get('charset'); $this->mail->From = $this->get('from'); $this->mail->FromName = $this->get('from'); $this->mail->Sender = $this->get('from'); $this->mail->ClearAllRecipients(); $this->mail->ClearAttachments(); $this->mail->ClearCustomHeaders(); $emails = explode(static::MAIL_SEPARATOR, $this->get('to')); foreach ($emails as $email) { $this->mail->AddAddress($email); } $this->mail->Subject = $this->get('subject'); $this->mail->AltBody = $this->createAltBody($this->get('body')); $this->mail->Body = $this->get('body'); // add custom headers foreach ($this->get('customHeaders') as $header) { $this->mail->AddCustomHeader($header); } if (is_array($this->get('images'))) { foreach ($this->get('images') as $image) { // Append to $attachment array $this->mail->AddEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']); } } }
function correoSMTP($para, $asunto, $mensaje, $html = true) { require_once 'php/class.phpmailer.php'; $Mail = new PHPMailer(); $Mail->IsHTML($html); $Mail->SetLanguage("es", 'php/language/'); $Mail->PluginDir = 'php/'; $Mail->Mailer = 'smtp'; $Mail->Host = "smtp.gmail.com"; $Mail->SMTPSecure = "ssl"; $Mail->Port = 465; $Mail->SMTPAuth = true; $Mail->Username = "******"; $Mail->Password = "******"; $Mail->CharSet = "utf-8"; $Mail->Encoding = "quoted-printable"; $Mail->FromName = PROY_MAIL_POSTMASTER_NOMBRE . PROY_MAIL_POSTMASTER; $Mail->Subject = $asunto; $Mail->Body = $mensaje; $Mail->AddAddress($para); $x = $Mail->Send(); if ($x) { return $x; } else { return correo($para, $asunto, $mensaje); } }
/** * Miscellaneous calls to improve test coverage and some small tests */ function test_Miscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->AddCustomHeader('SomeHeader: Some Value'); $this->Mail->ClearCustomHeaders(); $this->Mail->ClearAttachments(); $this->Mail->IsHTML(false); $this->Mail->IsSMTP(); $this->Mail->IsMail(); $this->Mail->IsSendMail(); $this->Mail->IsQmail(); $this->Mail->SetLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->CreateHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); //Test pathinfo $a = '/mnt/files/飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched'); $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched'); }
function SetLanguage($lang_type, $lang_path = null) { global $REX; if ($lang_path == null) { $lang_path = $REX['INCLUDE_PATH'] . '/addons/phpmailer/classes/language/'; } parent::SetLanguage($lang_type, $lang_path); }
function sendMail() { $cfg = new ini(); $cfg->setFileName('./include/config/account.ini'); $cfg->load(); $user_mail = $cfg->getElementByValue('user', 'email'); $mail = new PHPMailer(); $mail->IsSMTP(); //$mail->SMTPDebug= 2; //konfiguracja serwera $mail->PluginDir = "phpmailer/"; $mail->Mailer = "smtp"; $mail->Host = $cfg->getElementByValue('server-config', 'Host'); $mail->SMTPSecure = $cfg->getElementByValue('server-config', 'SMTPSecure'); $mail->Port = $cfg->getElementByValue('server-config', 'Port'); // $mail->SMTPKeepAlive = true; $mail->SMTPAuth = true; $mail->Username = $cfg->getElementByValue('server-config', 'Login'); $mail->Password = $cfg->getElementByValue('server-config', 'Passwort'); //koniec połączenia //baza danych $mydb = new DB(); $qwery = "SELECT `id`, `email` FROM mail_data Where sended=" . $checkbox_value; $request = mysql_query($qwery); if ($request === false) { die('Nie można było odebrać danych do bazy' . ' z powodu blendu:' . mysql_error()); } if (mysql_num_rows() == 0) { echo 'Brak danych w bazie'; exit(1); } while ($row = mysql_fetch_assoc($request)) { $id = $row['id']; $address = $row['email']; $mail->SetLanguage("pl", "phpmailer/language/"); $mail->CharSet = "UTF-8"; $mail->ContentType = "text/html"; $mail->isHTML(true); $mail->From = user_mail; $mail->FromName = "Kamil z webbooster"; $mail->Subject = "Tytuł wiadomości"; $mail->Body = ' To jest nowa testowa treść, z prawidłowo interpretowanymi polskimi znaczkami, a to jest <b>pogrubione</b>, a to jest <a href="http://www.example.com">link</a><br/> <div>trolololo</div> '; $mail->AddAddress($address); if ($mail->Send()) { return true; } else { throw new Exception('"E-mail nie mógł zostać wysłany, przyczyna :".$mail->ErrorInfo', 5); } } // $mail->SmtpClose(); //zamykamy połączeie }
/** * Sends the mail and returns whether that was successful. * * @return bool * * @global string The current language. * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The (X)HTML fragment that contains error messages. */ public function send() { global $sl, $plugin_cf, $plugin_tx, $e; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $type = strtolower($pcf['mail_type']); $this->mail->LE = $pcf['mail_line_ending_*nix'] ? "\n" : "\r\n"; $this->mail->set('CharSet', 'UTF-8'); $this->mail->SetLanguage($sl, $this->pluginFolder . 'phpmailer/language/'); $this->mail->set('WordWrap', 72); if (!$this->determineAddresses()) { return false; } if ($this->isConfirmation) { $this->mail->set('Subject', sprintf($ptx['mail_subject_confirmation'], $this->form->getTitle(), $_SERVER['SERVER_NAME'])); } else { $this->mail->set('Subject', sprintf($ptx['mail_subject'], $this->form->getTitle(), $_SERVER['SERVER_NAME'], $_SERVER['REMOTE_ADDR'])); } $this->mail->IsHtml($type != 'text'); if ($type == 'text') { $this->mail->set('Body', $this->getBody(false)); } else { $body = $this->getBody(true); $this->mail->MsgHTML($body); $this->mail->set('AltBody', $this->getBody(false)); } if (!$this->isConfirmation) { foreach ($this->form->getFields() as $field) { $field = Field::make($field); if ($field->getType() == 'file') { $name = 'advfrm-' . $field->getName(); $this->mail->AddAttachment($_FILES[$name]['tmp_name'], stsl($_FILES[$name]['name'])); } } } if (function_exists('advfrm_custom_mail')) { $customResult = advfrm_custom_mail($this->form->getName(), $this->mail, $this->isConfirmation); if ($customResult === false) { return true; } } $ok = $this->mail->Send(); if (!$this->isConfirmation) { if (!$ok) { $message = !empty($this->mail->ErrorInfo) ? XH_hsc($this->mail->ErrorInfo) : $ptx['error_mail']; $e .= '<li>' . $message . '</li>' . PHP_EOL; } if (function_exists('XH_logMessage')) { $type = $ok ? 'info' : 'error'; $message = $ok ? $ptx['log_success'] : $ptx['log_error']; $message = sprintf($message, $this->mail->From); XH_logMessage($type, 'Advancedform', $this->form->getName(), $message); } } return $ok; }
public function set($subject = '', $body = '', $m_cfg) { date_default_timezone_set('Asia/Shanghai'); //设定时区东八区 import('ORG.Net.PHPMailer.PHPMailerAutoload'); //import('ORG.Net.PHPMailer.smtp'); $mail = new PHPMailer(); $this->mailObj = $mail; //new一个PHPMailer对象出来 $body = preg_replace("/\\*/", '', $body); //对邮件内容进行必要的过滤 $mail->CharSet = "UTF-8"; //设定邮件编码,默认ISO-8859-1 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 1; $mail->SetLanguage('zh_cn'); // 启用SMTP调试功能 $mail->IsError = 1; // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // 启用 SMTP 验证功能 if ($m_cfg['ssl']) { $ssl = true; } else { $ssl = false; } $mail->SMTPSecure = $ssl; // 安全协议 $mail->Host = $m_cfg['smtp']; // SMTP 服务器 $mail->Port = $m_cfg['port']; // SMTP服务器的端口号 $mail->Username = $m_cfg['email']; // SMTP服务器用户名 $mail->Password = $m_cfg['pwd']; // SMTP服务器密码 $mail->SetFrom($m_cfg['email'], $m_cfg['username']); $mail->AddReplyTo($m_cfg['email'], $m_cfg['username']); $mail->Subject = $subject; $mail->AltBody = ''; $mail->MsgHTML($body); //$mail->AddAttachment("images/phpmailer.gif"); // attachment if (!$mail->Send()) { return false; } else { return true; } }
function SendMail($toAddress, $toName, $subject, $messageBody, $bcc = NULL, $mailList = FALSE) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/Main.php"; if ($mailList) { require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService2.php"; } else { require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService.php"; } require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.phpmailer.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.pop3.php"; if ($MailServiceAuthPOP3) { $pop = new POP3(); $pop->Authorise($MailServicePOP3Addr, $MailServicePOP3Port, 30, $MailServiceSMTPUser, $MailServiceSMTPPass, $MailServicePOPDebug); } $mail = new PHPMailer(); if ($MailServiceMailerLang != "en") { $mail->SetLanguage($MailServiceMailerLang, $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/language/"); } $mail->IsSMTP(); $mail->SMTPDebug = $MailServiceSMTPDebug; $mail->Port = $MailServiceSMTPPort; $mail->SMTPSecure = $MailServiceEncrypt; $mail->Host = $MailServiceSMTPAddr; $mail->SMTPAuth = $MailServiceAuthSMTP; $mail->Username = $MailServiceSMTPUser; $mail->Password = $MailServiceSMTPPass; $mail->From = $MailServiceFromMail; $mail->FromName = $MailServiceFromName; $mail->AddAddress($toAddress, $toName); if ($bcc != NULL) { if (is_array($bcc)) { foreach ($bcc as $key => $value) { $mail->AddBCC($value); } } } $mail->WordWrap = 50; $mail->CharSet = $MailServiceMsgCharset; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $messageBody; if ($mail->Send()) { return true; } else { return $mail->ErrorInfo; } }
/** * Constructor. */ function __construct() { require_once PHPMAILER_CLASS; require_once PHPMAILER_SMTP; require_once PHPMAILER_POP3; // Inicializa la instancia PHPMailer. $mail = new \PHPMailer(); // Define el idioma para los mensajes de error. $mail->SetLanguage("es", PHPMAILER_LANGS); // Define la codificación de caracteres del mensaje. $mail->CharSet = "UTF-8"; // Define el ajuste de texto a un número determinado de caracteres en el cuerpo del mensaje. $mail->WordWrap = 50; // Define el tipo de gestor de correo switch (GOTEO_MAIL_TYPE) { default: case "mail": $mail->isMail(); // set mailer to use PHP mail() function. break; case "sendmail": $mail->IsSendmail(); // set mailer to use $Sendmail program. break; case "qmail": $mail->IsQmail(); // set mailer to use qmail MTA. break; case "smtp": $mail->IsSMTP(); // set mailer to use SMTP $mail->SMTPAuth = GOTEO_MAIL_SMTP_AUTH; // enable SMTP authentication $mail->SMTPSecure = GOTEO_MAIL_SMTP_SECURE; // sets the prefix to the servier $mail->Host = GOTEO_MAIL_SMTP_HOST; // specify main and backup server $mail->Port = GOTEO_MAIL_SMTP_PORT; // set the SMTP port $mail->Username = GOTEO_MAIL_SMTP_USERNAME; // SMTP username $mail->Password = GOTEO_MAIL_SMTP_PASSWORD; // SMTP password break; } $this->mail = $mail; }
function send_mail($mail_to, $mail_body, $mail_subject = 'No title', $mail_name = 'No name', $mail_from = '', $mail_priority = 3, $mail_wordwrap = 50, $mail_altbody = '') { global $GO_CONFIG; // $mail_to='*****@*****.**'; // $mail_from = '*****@*****.**'; // $mail_name = "333"; // $mail_subject = 'subject'; // $mail_body = '123456789'; // $mail_altbody = 'qqqqqqqqqqqqqqqq'; require $GO_CONFIG->class_path . "phpmailer/class.phpmailer.php"; require $GO_CONFIG->class_path . "phpmailer/class.smtp.php"; $mail = new PHPMailer(); $mail->PluginDir = $GO_CONFIG->class_path . 'phpmailer/'; $mail->SetLanguage($php_mailer_lang, $GO_CONFIG->class_path . 'phpmailer/language/'); switch ($GO_CONFIG->mailer) { case 'smtp': $mail->Host = $GO_CONFIG->smtp_server; $mail->Port = $GO_CONFIG->smtp_port; $mail->IsSMTP(); break; case 'qmail': $mail->IsQmail(); break; case 'sendmail': $mail->IsSendmail(); break; case 'mail': $mail->IsMail(); break; } $mail->Priority = $mail_priority; $mail->Sender = $mail_from; $mail->From = $mail_from; $mail->FromName = $mail_name; $mail->AddReplyTo($mail_from, $mail_name); $mail->WordWrap = $mail_wordwrap; // $mail->Encoding = "quoted-printable"; $mail->IsHTML(true); $mail->Subject = $mail_subject; $mail->AddAddress($mail_to); $mail->Body = $mail_body; $mail->AltBody = $mail_altbody; if (!$mail->Send()) { return '<p class="Error">' . $ml_send_error . ' ' . $mail->ErrorInfo . '</p>'; } }
/** * Miscellaneous calls to improve test coverage and some small tests */ function test_Miscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->AddCustomHeader('SomeHeader: Some Value'); $this->Mail->ClearCustomHeaders(); $this->Mail->ClearAttachments(); $this->Mail->IsHTML(false); $this->Mail->IsSMTP(); $this->Mail->IsMail(); $this->Mail->IsSendMail(); $this->Mail->IsQmail(); $this->Mail->SetLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->CreateHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); }
function send($to, $subject, $content, $sender) { //echo 'sendmail!!'; require_once ROOT . DS . 'library' . DS . 'class.phpmailer.php'; $mail = new PHPMailer(); $mail->CharSet = "UTF-8"; $mail->SetLanguage('vi', ROOT . DS . 'library' . '/phpmailer/language/'); $mail->IsSMTP(); $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier //$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server //$mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Host = $sender['smtp']; $mail->Port = $sender['port']; $mail->Username = $sender['email']; // GMAIL username $mail->Password = $sender['password']; // GMAIL password $from = $sender['email']; $mail->AddReplyTo('*****@*****.**', "Jobbid.vn Support"); $mail->From = $from; $mail->FromName = "Jobbid.vn Support"; $mail->Sender = $from; $mail->Subject = $subject; //$mail->AltBody = "Xin chao"; // optional, comment out and test //$mail->WordWrap = 50; // set word wrap $mail->MsgHTML($content); if (is_array($to)) { foreach ($to as $email) { $mail->addBCC($email); } } else { $mail->AddAddress($to); } $mail->IsHTML(true); // send as HTML if (!$mail->Send()) { return false; } $mail->SmtpClose(); return true; }
/** * 发送邮件 * * @param string $address 收件人,多个用 ";" 分开 * @param string $subject 主题 * @param string $body 内容 * @param string $attachment 附件文件,多个用 ";" 分开,要用绝对路径,如 "/tmp/a.zip;/tmp/b.zip" * @return unknown */ public function send($address, $subject, $body, $attachment = '') { $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->SetLanguage('zh_cn'); $mail->IsSMTP(); $mail->SMTPDebug = 1; $mail->SMTPAuth = $this->_config['auth']; $mail->Host = $this->_config['host']; $mail->Port = $this->_config['port']; $mail->Username = $this->_config['username']; $mail->Password = $this->_config['password']; $mail->SetFrom($this->_config['from'], $this->_config['fromname']); $mail->Subject = $subject; $mail->MsgHTML($body); $mail->SMTPSecure = $this->_config['secure']; // 收件人 $addrArr = explode(';', $address); foreach ($addrArr as $addr) { $mail->AddAddress($addr); } // 附件 if ($attachment != '') { $attaArr = explode(';', $attachment); foreach ($attaArr as $file) { $mail->AddAttachment($file); } } if (!$this->debug) { // 发送 if (!$mail->Send()) { $ret = $mail->ErrorInfo; } else { $ret = true; } } else { // 写日志 $message = $subject . PHP_EOL . $body; QP_Sys::log($message, 'email'); $ret = true; } return $ret; }
function pushToEmail($email, $fileName) { $mail = new PHPMailer(); //创建实例 //$mail->SMTPDebug=true; $mail->CharSet = 'utf-8'; //设置字符集 $mail->SetLanguage('en', 'libs/mail/language/'); //设置语言类型和语言文件所在目录 //$mail->IsSMTP(); //使用SMTP方式发送 $mail->IsSMTP(); $mail->SMTPAuth = true; //设置服务器是否需要SMTP身份验证 //$mail->Host = "smtp.gmail.com"; // 您的邮局域名 $mail->Host = smtp; //$mail->Port = '465'; // 端口 //$mail->SMTPSecure = "ssl"; //加密方式 $mail->From = email; //发件人EMAIL地址 $mail->FromName = email; //发件人在SMTP主机中的用户名 $mail->Username = email; //发件人的姓名 $mail->Password = emailpwd; //发件人在SMTP主机中的密码 $mail->Subject = 'kindle推送'; //邮件主题 $mail->Body = 'kindle'; //邮件内容做成 $mail->IsHTML(true); $mail->AddAddress($email, 'kindle user'); //收件人的地址和姓名 $mail->AddAttachment("./jae/{$fileName}", '1.mobi'); //附件的路径和附件名称 if (!$mail->Send()) { //发送邮件 //var_dump($mail -> ErrorInfo); //查看发送的错误信息 return 'error'; } else { return 'success'; } }
function send_email($subject, $body) { $recipient = $GLOBALS['practice_return_email_path']; if (empty($recipient)) { return; } $mail = new PHPMailer(); $mail->SetLanguage("en", $GLOBALS['fileroot'] . "/library/"); $mail->From = $recipient; $mail->FromName = 'In-House Pharmacy'; $mail->isMail(); $mail->Host = "localhost"; $mail->Mailer = "mail"; $mail->Body = $body; $mail->Subject = $subject; $mail->AddAddress($recipient); if (!$mail->Send()) { error_log(xl('There has been a mail error sending to', '', '', ' ') . $recipient . " " . $mail->ErrorInfo); } }
function sendEmail() { $secretkey = $_REQUEST['secretkey']; require_once 'lib/phpmailer/class.phpmailer.php'; $reply = array(); if ($_SESSION['email_secretkey'] && $secretkey == $_SESSION['email_secretkey']) { $_SESSION['email_secretkey'] = ''; $destination = $_REQUEST['destination']; $subject = $_REQUEST['subject']; $content = $_REQUEST['content']; $replyto = strip_tags($_SESSION['email_replyto']); $fromname = strip_tags($_SESSION['email_fromname']); $mail = new PHPMailer(); $mail->PluginDir = "lib/phpmailer/"; $mail->SetLanguage("en", "lib/phpmailer/language/"); $mail->CharSet = "UTF-8"; $mail->From = $replyto; $mail->FromName = $fromname; $mail->AddAddress($destination); if (SMTP_HOST) { $mail->Host = SMTP_HOST; $mail->Mailer = "smtp"; $mail->SMTPAuth = SMTP_LOGIN != ''; $mail->Username = SMTP_LOGIN; $mail->Password = SMTP_PASSWORD; } $mail->IsHTML(false); $mail->Subject = $subject; $mail->Body = $content; $rc = $mail->Send(); if (!$rc) { $reply['error'] = $mail->ErrorInfo; } else { save_email_address($this->link, db_escape_string($destination)); $reply['message'] = "UPDATE_COUNTERS"; } } else { $reply['error'] = "Not authorized."; } print json_encode($reply); }
function SifreGonder($EMail, $AdSoyad, $Sifre) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = false; $mail->SMTPAuth = true; $mail->Host = "MailHost"; $mail->Port = 587; $mail->IsHTML(true); $mail->SetLanguage("tr", "phpmailer/language"); $mail->CharSet = "utf-8"; $mail->Username = "******"; $mail->Password = "******"; $mail->SetFrom("*****@*****.**", "O mu Bu mu Ekibi"); $mail->AddAddress($EMail); $mail->Subject = "O mu Bu mu - Þfreniz Sýfýrlandý"; $mail->Body = "\n Merhaba <b>" . $AdSoyad . "</b><br/><br/>\n \n " . date("Y-m-d") . " tarihinde bir þifreniz sýfýrlandý. Eðer bu iþlemi sen gerçekleþtirmediysen <b><a href='mailto:uyelik@omubumuapp.com'>uyelik@omubumuapp.com</a></b> a mail atabilirsin.<br/><br/>\n \n <b>Yeni Þifreniz:</b> " . $Sifre . "<br/><br/>\n \n iyi günler Dileriz...<br/><br/>\n \n O mu Bu mu Ekibi\n "; if (!$mail->Send()) { return false; } else { return true; } }
function dbem_send_mail($subject = "no title", $body = "No message specified", $receiver = '') { global $smtpsettings, $phpmailer, $cformsSettings; if (file_exists(dirname(__FILE__) . '/class.phpmailer.php') && !class_exists('PHPMailer')) { require_once dirname(__FILE__) . '/class.phpmailer.php'; require_once dirname(__FILE__) . '/class.smtp.php'; } $mail = new PHPMailer(); $mail->ClearAllRecipients(); $mail->ClearAddresses(); $mail->ClearAttachments(); $mail->CharSet = 'utf-8'; $mail->SetLanguage('en', dirname(__FILE__) . '/'); $mail->PluginDir = dirname(__FILE__) . '/'; get_option('dbem_rsvp_mail_send_method') == 'qmail' ? $mail->IsQmail() : ($mail->Mailer = get_option('dbem_rsvp_mail_send_method')); $mail->Host = get_option('dbem_smtp_host'); $mail->port = get_option('dbem_rsvp_mail_port'); if (get_option('dbem_rsvp_mail_SMTPAuth') == '1') { $mail->SMTPAuth = TRUE; } $mail->Username = get_option('dbem_smtp_username'); $mail->Password = get_option('dbem_smtp_password'); $mail->From = get_option('dbem_mail_sender_address'); //$mail->SMTPDebug = true; $mail->FromName = get_option('dbem_mail_sender_name'); // This is the from name in the email, you can put anything you like here $mail->Body = $body; $mail->Subject = $subject; $mail->AddAddress($receiver); if (!$mail->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mail->ErrorInfo; // print_r($mailer); } else { // echo "Message has been sent"; } }
function emailSWIP($swip) { require_once "../class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SetLanguage("en", "../"); $mail->Host = EMAILSERVER; // SMTP server $mail->From = REGADMINEMAIL; $mail->FromName = "IP Plan"; $mail->AddAddress(REGEMAIL); $mail->IsHTML(false); $mail->Subject = "SWIP"; $mail->Body = $swip; $mail->AddReplyTo(REGADMINEMAIL); $mail->AddCustomHeader("X-Mailer: PHP/" . phpversion()); //$mail->AddCustomHeader("IPplan version goes here"); if (REGISTRY == "RIPE") { $mail->AddCustomHeader("X-NCC-regid: " . REGID); } if (!@$mail->Send()) { return $mail->ErrorInfo; } /* $header="From: ".REGADMINEMAIL."\n". "Reply-To: ".REGADMINEMAIL."\n". "X-Mailer: PHP/" . phpversion(); if(REGISTRY=="RIPE") { $header.="\nX-NCC-regid: ".REGID."\n"; } mail(REGEMAIL, "SWIP", $swip, $header); */ }
function _send() { $recipient = ''; $error = array(); $response = array(); $this->components = array('security'); $this->__initComponents(); if ($this->invalidToken) { $error[] = 'jQuery("#jr_inquiryTokenValidation").show();'; return json_encode(array('error' => $this->makeJS($error))); } // Required fields $fields = array('name', 'email', 'text'); // $fields = array('name','email','phone','text'); foreach ($fields as $id) { $input_id = '#jr_inquiry' . Inflector::camelize($id) . 'Validation'; if ($this->data['Inquiry'][$id] == '') { $error[] = 'jQuery("' . $input_id . '").show();'; } else { $reponse[] = 'jQuery("' . $input_id . '").hide();'; } } # Validate user's email $this->Listing->validateInput($this->data['Inquiry']['email'], "email", "email", __t("You must fill in a valid email address.", true), 1); # Validate security code if ($this->Access->showCaptcha()) { if (!isset($this->data['Captcha']['code'])) { $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true)); } elseif ($this->data['Captcha']['code'] == '') { $this->Listing->validateSetError("code", __t("You must fill in the security code.", true)); } else { if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) { $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true)); } } } # Process validation errors $validation = $this->Listing->validateGetErrorArray(); $validation = is_array($validation) ? implode("<br />", $validation) : ''; if (!empty($error) || $validation != '') { // Reissue form token if (isset($this->Security)) { $error[] = "jQuery('#jr_inquiryToken').val('" . $this->Security->reissueToken() . "');"; } if ($this->Access->showCaptcha()) { // Replace captcha with new instance $captcha = $this->Captcha->displayCode(); $error[] = "jQuery('#captcha').attr('src','{$captcha['src']}');"; $error[] = "jQuery('#jr_inquiryCode').val('');"; } if ($validation != '') { $error[] = "jQuery('#jr_inquiryCodeValidation').html('{$validation}').show();"; } return json_encode(array('error' => $this->makeJS($error))); } // Now we can send the email # Read cms mail config settings $configSendmailPath = cmsFramework::getConfig('sendmail'); $configSmtpAuth = cmsFramework::getConfig('smtpauth'); $configSmtpUser = cmsFramework::getConfig('smtpuser'); $configSmtpPass = cmsFramework::getConfig('smtppass'); $configSmtpHost = cmsFramework::getConfig('smtphost'); $configSmtpSecure = cmsFramework::getConfig('smtpsecure'); $configSmtpPort = cmsFramework::getConfig('smtpport'); $configMailFrom = cmsFramework::getConfig('mailfrom'); $configFromName = cmsFramework::getConfig('fromname'); $configMailer = cmsFramework::getConfig('mailer'); # Get the recipient email Configure::write('Cache.query', false); $listing = $this->Listing->findRow(array('fields' => array('User.email AS `Listing.email`'), 'conditions' => array('Listing.id = ' . (int) $this->data['Inquiry']['listing_id']))); $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true)); $link = '<a href="' . $url . '">' . $listing['Listing']['title'] . '</a>'; switch ($this->Config->inquiry_recipient) { case 'owner': $recipient = Sanitize::getString($listing['Listing'], 'email'); break; case 'admin': $recipient = $configMailFrom; break; case 'field': if (isset($listing['Field']['pairs'][$this->Config->inquiry_field])) { $recipient = $listing['Field']['pairs'][$this->Config->inquiry_field]['value'][0]; } break; } if ($recipient == '') { $recipient = $configMailFrom; } if (!class_exists('PHPMailer')) { App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer'); } $mail = new PHPMailer(); $mail->CharSet = cmsFramework::getCharset(); $mail->SetLanguage('en', S2_VENDORS . 'phpmailer' . DS . 'language' . DS); $mail->Mailer = $configMailer; // Mailer used mail,sendmail,smtp switch ($configMailer) { case 'smtp': $mail->Host = $configSmtpHost; $mail->SMTPAuth = $configSmtpAuth; $mail->Username = $configSmtpUser; $mail->Password = $configSmtpPass; $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : ''; $mail->Port = $configSmtpPort; break; case 'sendmail': $mail->Sendmail = $configSendmailPath; break; default: break; } $mail->isHTML(true); $mail->From = $configMailFrom; $mail->FromName = $configFromName; $mail->addReplyTo($this->data['Inquiry']['email']); $mail->AddAddress($recipient); $mail->Subject = sprintf(__t("New inquiry for: %s", true), $listing['Listing']['title']); $mail->Body = sprintf(__t("From: %s", true), Sanitize::getString($this->data['Inquiry'], 'name')) . "<br />"; $mail->Body .= sprintf(__t("Email: %s", true), Sanitize::getString($this->data['Inquiry'], 'email')) . "<br />"; // $mail->Body .= sprintf(__t("Phone number: %s",true),Sanitize::getString($this->data['Inquiry'],'phone')) . "<br />"; $mail->Body .= sprintf(__t("Listing: %s", true), $listing['Listing']['title']) . "<br />"; $mail->Body .= sprintf(__t("Listing link: %s", true), $link) . "<br />"; $mail->Body .= $this->data['Inquiry']['text']; if (!$mail->Send()) { unset($mail); $error[] = 'jQuery("#jr_inquiryTokenValidation").show();'; return json_encode(array('error' => $this->makeJS($error))); } $mail->ClearAddresses(); $bccAdmin = $this->Config->inquiry_bcc; if ($bccAdmin != '' && $bccAdmin != $recipient) { $mail->AddAddress($bccAdmin); $mail->Send(); } unset($mail); return json_encode(array('error' => $this->makeJS($response), 'html' => true)); }
function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient) { global $sSendType; global $sFromEmailAddress; global $sFromName; global $sLangCode; global $sLanguagePath; global $sSMTPAuth; global $sSMTPUser; global $sSMTPPass; global $sSMTPHost; global $sSERVERNAME; global $sUSER; global $sPASSWORD; global $sDATABASE; global $sSQL_ERP; global $sSQL_EMP; $iUserID = $_SESSION['iUserID']; // Retrieve UserID for faster access // Store these queries in variables. (called on every loop iteration) $sSQLGetEmail = 'SELECT * FROM email_recipient_pending_erp ' . "WHERE erp_usr_id='{$iUserID}' " . 'ORDER BY erp_num_attempt, erp_id LIMIT 1'; // Just run this one ahead of time to get the message subject and body $sSQL = 'SELECT * FROM email_message_pending_emp'; extract(mysql_fetch_array(RunQuery($sSQL))); // Keep track of how long this script has been running. To avoid server // and browser timeouts break out of loop every $sLoopTimeout seconds and // redirect back to EmailSend.php with meta refresh until finished. $tStartTime = time(); $mail = new PHPMailer(); // Set the language for PHPMailer $mail->SetLanguage($sLangCode, $sLanguagePath); if ($mail->IsError()) { echo 'PHPMailer Error with SetLanguage(). Other errors (if any) may not report.<br>'; } $mail->CharSet = 'utf-8'; $mail->From = $sFromEmailAddress; // From email address (User Settings) $mail->FromName = $sFromName; // From name (User Settings) if ($hasAttach) { $mail->AddAttachment("tmp_attach/" . $attachName); } if (strtolower($sSendType) == 'smtp') { $mail->IsSMTP(); // tell the class to use SMTP $mail->SMTPKeepAlive = true; // keep connection open until last email sent $mail->SMTPAuth = $sSMTPAuth; // Server requires authentication if ($sSMTPAuth) { $mail->Username = $sSMTPUser; // SMTP username $mail->Password = $sSMTPPass; // SMTP password } $delimeter = strpos($sSMTPHost, ':'); if ($delimeter === FALSE) { $sSMTPPort = 25; // Default port number } else { $sSMTPPort = substr($sSMTPHost, $delimeter + 1); $sSMTPHost = substr($sSMTPHost, 0, $delimeter); } if (is_int($sSMTPPort)) { $mail->Port = $sSMTPPort; } else { $mail->Port = 25; } $mail->Host = $sSMTPHost; // SMTP server name } else { $mail->IsSendmail(); // tell the class to use Sendmail } $bContinue = TRUE; $sLoopTimeout = 30; // Break out of loop if this time is exceeded $iMaxAttempts = 3; // Error out if an email address fails 3 times while ($bContinue) { // Three ways to get out of this loop // 1. We're finished sending email // 2. Time exceeds $sLoopTimeout // 3. Something strange happens // (maybe user tries to send from multiple sessions // causing counts and timestamps to 'misbehave' ) $tTimeStamp = date('Y-m-d H:i:s'); $mail->Subject = $sSubject; $mail->Body = $sMessage; if ($sRecipient == 'get_recipients_from_mysql') { $rsEmailAddress = RunQuery($sSQLGetEmail); // This query has limit one to pick up one recipient $aRow = mysql_fetch_array($rsEmailAddress); extract($aRow); $mail->AddAddress($erp_email_address); } else { $erp_email_address = $sRecipient; $mail->AddAddress($erp_email_address); $bContinue = FALSE; // Just sending one email } if (!$mail->Send()) { // failed- make a note in the log and the recipient record if ($sRecipient == 'get_recipients_from_mysql') { $sMsg = "Failed sending to: {$erp_email_address} "; $sMsg .= $mail->ErrorInfo; echo "{$sMsg}<br>\n"; AddToEmailLog($sMsg, $iUserID); // Increment the number of attempts for this message $erp_num_attempt++; $sSQL = 'UPDATE email_recipient_pending_erp ' . "SET erp_num_attempt='{$erp_num_attempt}' ," . " erp_failed_time='{$tTimeStamp}' " . "WHERE erp_id='{$erp_id}'"; RunQuery($sSQL); // Check if we've maxed out retry attempts if ($erp_num_attempt < $iMaxAttempts) { echo "Pausing 15 seconds after failure<br>\n"; AddToEmailLog('Pausing 15 seconds after failure', $iUserID); sleep(15); // Delay 15 seconds on failure // The mail server may be having a temporary problem } else { $_SESSION['sEmailState'] = 'error'; $bContinue = FALSE; $sMsg = 'Too many failures. Giving up. You may try to resume later.'; AddToEmailLog($sMsg, $iUserID); } } else { $sMsg = "Failed sending to: {$sRecipient} "; $sMsg .= $mail->ErrorInfo; echo "{$sMsg}<br>\n"; AddToEmailLog($sMsg, $iUserID); } } else { if ($sRecipient == 'get_recipients_from_mysql') { echo "<b>{$erp_email_address}</b> Sent! <br>\n"; $sMsg = "Email sent to: {$erp_email_address}"; AddToEmailLog($sMsg, $iUserID); // Delete this record from the recipient list $sSQL = 'DELETE FROM email_recipient_pending_erp ' . "WHERE erp_email_address='{$erp_email_address}'"; RunQuery($sSQL); } else { echo "<b>{$sRecipient}</b> Sent! <br>\n"; $sMsg = "Email sent to: {$erp_email_address}"; AddToEmailLog($sMsg, $iUserID); } } $mail->ClearAddresses(); $mail->ClearBCCs(); // Are we done? extract(mysql_fetch_array(RunQuery($sSQL_ERP))); // this query counts remaining recipient records if ($sRecipient == 'get_recipients_from_mysql' && $countrecipients == 0) { $bContinue = FALSE; $_SESSION['sEmailState'] = 'finish'; AddToEmailLog('Job Finished', $iUserID); } if (time() - $tStartTime > $sLoopTimeout) { // bail out of this loop if we've taken more than $sLoopTimeout seconds. // The meta refresh will reload this page so we can pick up where // we left off $bContinue = FALSE; } } if (strtolower($sSendType) == 'smtp') { $mail->SmtpClose(); } }
$message .= "\n" . $corps_message . "\n"; $sujet = $vocab["subject_mail1"] . " - " . $objet_message; error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); require 'phpmailer/PHPMailerAutoload.php'; define("GRR_FROM", Settings::get("grr_mail_from")); define("GRR_FROMNAME", Settings::get("grr_mail_fromname")); $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = Settings::get("grr_mail_smtp"); $mail->Port = 25; $mail->SMTPAuth = false; $mail->CharSet = 'UTF-8'; $mail->setFrom(GRR_FROM, GRR_FROMNAME); $mail->SetLanguage("fr", "./phpmailer/language/"); setlocale(LC_ALL, $locale); $tab_destinataire = explode(';', preg_replace("/ /", "", $destinataire)); foreach ($tab_destinataire as $item_email) { $mail->AddAddress($item_email); } $mail->Subject = $sujet; $mail->Body = $message; $mail->AddReplyTo($email_reponse); if (!$mail->Send()) { $message_erreur .= $mail->ErrorInfo; echo $message_erreur; } else { echo "<p style=\"text-align: center\">Votre message a été envoyé !</p>"; } break;
public static function sendmail($config) { if (empty($config)) { return false; } self::import(iPHP_LIB . '/PHPMailer/PHPMailerAutoload.php'); $mail = new PHPMailer(); $mail->SetLanguage('zh_cn', iPHP_LIB . '/PHPMailer/language/'); $mail->IsHTML(true); $mail->IsSMTP(); // telling the class to use SMTP $mail->CharSet = 'utf-8'; $mail->AltBody = 'text/html'; // optional, comment out and test $mail->SMTPDebug = 0; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = $config['secure']; // sets the prefix to the servier $mail->Host = $config['host']; // sets GMAIL as the SMTP server $mail->Port = $config['port']; // set the SMTP port for the GMAIL server $mail->Username = $config['username']; // GMAIL username $mail->Password = $config['password']; // GMAIL password $mail->SetFrom($config['setfrom'], $config['title']); $mail->AddReplyTo($config['replyto'], $config['title']); $mail->Subject = $config['subject']; $mail->MsgHTML($config['body']); foreach ((array) $config['address'] as $key => $value) { $mail->AddAddress($value[0], $value[1]); } //function_exists('date_default_timezone_set') && date_default_timezone_set('Asia/Chongqing'); //$H=date("H"); //if(in_array($H,array("23","00","01","02","03","04","05","06","07"))){ // $mail->AddAddress("*****@*****.**", "13599438781"); // $mail->AddAddress("*****@*****.**", "13338433013"); //} if (!$mail->Send()) { return "Mailer Error: " . $mail->ErrorInfo; } else { return true; } }
/** * This function mails a text $body to the recipient $to. * You can use more than one recipient when using a semikolon separated string with recipients. * * @param string $body Body text of the email in plain text or HTML * @param mixed $subject Email subject * @param mixed $to Array with several email addresses or single string with one email address * @param mixed $from * @param mixed $sitename * @param mixed $ishtml * @param mixed $bouncemail * @param mixed $attachment * @return bool If successful returns true */ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml = false, $bouncemail = null, $attachments = null, $customheaders = "") { global $maildebug, $maildebugbody; $emailmethod = Yii::app()->getConfig('emailmethod'); $emailsmtphost = Yii::app()->getConfig("emailsmtphost"); $emailsmtpuser = Yii::app()->getConfig("emailsmtpuser"); $emailsmtppassword = Yii::app()->getConfig("emailsmtppassword"); $emailsmtpdebug = Yii::app()->getConfig("emailsmtpdebug"); $emailsmtpssl = Yii::app()->getConfig("emailsmtpssl"); $defaultlang = Yii::app()->getConfig("defaultlang"); $emailcharset = Yii::app()->getConfig("emailcharset"); if ($emailcharset != 'utf-8') { $body = mb_convert_encoding($body, $emailcharset, 'utf-8'); $subject = mb_convert_encoding($subject, $emailcharset, 'utf-8'); $sitename = mb_convert_encoding($sitename, $emailcharset, 'utf-8'); } if (!is_array($to)) { $to = array($to); } if (!is_array($customheaders) && $customheaders == '') { $customheaders = array(); } if (Yii::app()->getConfig('demoMode')) { $maildebug = gT('Email was not sent because demo-mode is activated.'); $maildebugbody = ''; return false; } if (is_null($bouncemail)) { $sender = $from; } else { $sender = $bouncemail; } require_once APPPATH . '/third_party/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); if (!$mail->SetLanguage($defaultlang, APPPATH . '/third_party/phpmailer/language/')) { $mail->SetLanguage('en', APPPATH . '/third_party/phpmailer/language/'); } $mail->CharSet = $emailcharset; if (isset($emailsmtpssl) && trim($emailsmtpssl) !== '' && $emailsmtpssl !== 0) { if ($emailsmtpssl === 1) { $mail->SMTPSecure = "ssl"; } else { $mail->SMTPSecure = $emailsmtpssl; } } $fromname = ''; $fromemail = $from; if (strpos($from, '<')) { $fromemail = substr($from, strpos($from, '<') + 1, strpos($from, '>') - 1 - strpos($from, '<')); $fromname = trim(substr($from, 0, strpos($from, '<') - 1)); } $sendername = ''; $senderemail = $sender; if (strpos($sender, '<')) { $senderemail = substr($sender, strpos($sender, '<') + 1, strpos($sender, '>') - 1 - strpos($sender, '<')); $sendername = trim(substr($sender, 0, strpos($sender, '<') - 1)); } switch ($emailmethod) { case "qmail": $mail->IsQmail(); break; case "smtp": $mail->IsSMTP(); if ($emailsmtpdebug > 0) { $mail->SMTPDebug = $emailsmtpdebug; } if (strpos($emailsmtphost, ':') > 0) { $mail->Host = substr($emailsmtphost, 0, strpos($emailsmtphost, ':')); $mail->Port = substr($emailsmtphost, strpos($emailsmtphost, ':') + 1); } else { $mail->Host = $emailsmtphost; } $mail->Username = $emailsmtpuser; $mail->Password = $emailsmtppassword; if (trim($emailsmtpuser) != "") { $mail->SMTPAuth = true; } break; case "sendmail": $mail->IsSendmail(); break; default: //Set to the default value to rule out incorrect settings. $emailmethod = "mail"; $mail->IsMail(); } $mail->SetFrom($fromemail, $fromname); $mail->Sender = $senderemail; // Sets Return-Path for error notifications foreach ($to as $singletoemail) { if (strpos($singletoemail, '<')) { $toemail = substr($singletoemail, strpos($singletoemail, '<') + 1, strpos($singletoemail, '>') - 1 - strpos($singletoemail, '<')); $toname = trim(substr($singletoemail, 0, strpos($singletoemail, '<') - 1)); $mail->AddAddress($toemail, $toname); } else { $mail->AddAddress($singletoemail); } } if (is_array($customheaders)) { foreach ($customheaders as $key => $val) { $mail->AddCustomHeader($val); } } $mail->AddCustomHeader("X-Surveymailer: {$sitename} Emailer (LimeSurvey.sourceforge.net)"); if (get_magic_quotes_gpc() != "0") { $body = stripcslashes($body); } if ($ishtml) { $mail->IsHTML(true); if (strpos($body, "<html>") === false) { $body = "<html>" . $body . "</html>"; } $mail->msgHTML($body, App()->getConfig("publicdir")); // This allow embedded image if we remove the servername from image } else { $mail->IsHTML(false); $mail->Body = $body; } // Add attachments if they are there. if (is_array($attachments)) { foreach ($attachments as $attachment) { // Attachment is either an array with filename and attachment name. if (is_array($attachment)) { $mail->AddAttachment($attachment[0], $attachment[1]); } else { // Or a string with the filename. $mail->AddAttachment($attachment); } } } $mail->Subject = $subject; if ($emailsmtpdebug > 0) { ob_start(); } $sent = $mail->Send(); $maildebug = $mail->ErrorInfo; if ($emailsmtpdebug > 0) { $maildebug .= '<li>' . gT('SMTP debug output:') . '</li><pre>' . strip_tags(ob_get_contents()) . '</pre>'; ob_end_clean(); } $maildebugbody = $mail->Body; //if(!$sent) var_dump($maildebug); return $sent; }