function passwordForget($opt) { // PUEDEN EXISTIR 3 ESTADOS A LA OPERACION (status) // 0: OPERACION EXITOSA // 1: EL USUARIO YA EXISTE // 2: EXISTIO UN ERROR AL CREARLO POR DB // 3: NO SE PUDO ENVIAR EL EMAIL $dbo = $this->db; if ($dbo->isExists('users', 'email', $opt->email)) { $where['email'] = $opt->email; $matriz['opeToken'] = $this->getToken('users', 'opeToken'); if ($dbo->update('users', $matriz, $where)) { $email = new mail(); if ($email->sendForgotMail($opt->email, $matriz['opeToken'])) { $this->returnData(array("status" => 0)); } else { $this->returnData(array("status" => 3)); } } else { $this->returnData(array("status" => 2)); } } else { $this->returnData(array("status" => 1)); } }
function testEmail() { $email = new mail(); if ($email->send($_POST['email'], '测试用户', '这是一封测试邮件!', '这是一封测试邮件!你看到此邮件,说明你的邮箱已经配置好了。欢迎来到' . '<a href="' . __WEB__ . '">' . C('WEB_NAME') . '</a><br /><a href="http://www.houdunwang.com"><img src="http://bbs.houdunwang.com/static/image/common/logo.png" alt="后盾PHP培训" /></a>')) { $this->success('邮件发送成功'); } $this->success('邮件发送失败'); }
function executeQuery($query) { $result = mysql_query($query, $this->handler); if (!$result) { $mail = new mail(); $error = mysql_error(); $mail->send_error_mail($query, $error); } return $result; }
function send($email, $code) { $sendmail = new sendmail(); $mail = new mail(); $mail->setSmtpemailto($email); $mail->setMailsubject("邮箱验证"); $mail->setMailbody("感谢你的支持,你的验证码为:" . $code); $rs = $sendmail->send($mail); return $rs; }
public function unsubscribe() { $mail_configs['appid'] = $this->appid; $mail_configs['appkey'] = $this->appkey; if ($this->sign_type != '') { $mail_configs['sign_type'] = $this->sign_type; } $addressbook = new mail($mail_configs); return $addressbook->unsubscribe($this->buildRequest()); }
public function execute($function) { if (is_callable(array($this, $function))) { try { $this->{$function}(); } catch (Error_Cron $e) { $mail = new mail(def::notify('mail')); $mail->text(serialize($e))->send(); } } }
function shutdown_handler() { $error = error_get_last(); if ($error && ($error['type'] == E_ERROR || $error['type'] == E_PARSE || $error['type'] == E_COMPILE_ERROR)) { if (strpos($error['message'], 'Allowed memory size') === 0) { ob_end_clean(); $mail = new mail(def::notify('mail')); $mail->text(serialize(query::$url) . serialize($error))->send(); } else { ob_end_clean(); $mail = new mail(def::notify('mail')); $mail->text(serialize(query::$url) . serialize($error))->send(); } } }
/** * 回复留言信息 */ function do_edit($id) { //权限检查 得到所有可管理站点ID列表 role::check('contact_us_manage'); if (!$id) { remind::set(Kohana::lang('o_global.bad_request'), 'user/contact_us'); } if ($_POST) { //获取留言信息,发邮件 $contact_us = Mycontact_us::instance($id)->get(); $email_flag = 'contact_us'; $title_param = array(); $content_param = array(); $content_param['{message}'] = strip_tags($_POST['return_message']); if (mail::send_mail($email_flag, $contact_us['email'], $from_email = '', $title_param, $content_param)) { $is_receive = 1; remind::set(Kohana::lang('o_global.mail_send_success'), '', 'success'); } else { $is_receive = 0; remind::set(Kohana::lang('o_global.mail_send_error'), '', 'error'); } $data = $_POST; $data['active'] = 0; $data['is_receive'] = $is_receive; if (Mycontact_us::instance($id)->edit($data)) { remind::set(Kohana::lang('o_user.message_handle_success'), request::referrer(), 'success'); } else { remind::set(Kohana::lang('o_user.message_handle_error'), request::referrer(), 'error'); } } }
function send() { global $tpl, $opt, $login; if (!$this->template_exists($this->name . '.tpl')) { $tpl->error(ERROR_MAIL_TEMPLATE_NOT_FOUND); } $this->assign('template', $this->name); $optn['mail']['contact'] = $opt['mail']['contact']; $optn['page']['absolute_url'] = $opt['page']['absolute_url']; $optn['format'] = $opt['locale'][$opt['template']['locale']]['format']; $this->assign('opt', $optn); $this->assign('to', $this->to); $this->assign('from', $this->from); $this->assign('subject', $this->subject); $llogin['username'] = isset($login) ? $login->username : ''; $this->assign('login', $llogin); $body = $this->fetch($this->main_template . '.tpl', '', $this->get_compile_id()); // check if the target domain exists if the domain does not // exist, the mail is sent to the own domain (?!) $domain = mail::getToMailDomain($this->to); if (mail::is_existent_maildomain($domain) == false) { return false; } $aAddHeaders = array(); $aAddHeaders[] = 'From: "' . $this->from . '" <' . $this->from . '>'; if ($this->replyTo !== null) { $aAddHeaders[] = 'Reply-To: ' . $this->replyTo; } if ($this->returnPath !== null) { $aAddHeaders[] = 'Return-Path: ' . $this->returnPath; } $mailheaders = implode("\n", array_merge($aAddHeaders, $this->headers)); return mb_send_mail($this->to, $opt['mail']['subject'] . $this->subject, $body, $mailheaders); }
public static function update($argv) { global $_cache, $_user, $_db; $result = 'succeed'; if (!$_user->user_id) { return false; } if ($argv['password'] != '') { if ($argv['repeat_password'] == '' || $argv['password'] != $argv['repeat_password']) { return false; } } session_start(); $cache_key = md5("activate_{$_user->user_id}"); $email = filter_var($argv['email'], FILTER_VALIDATE_EMAIL); unset($argv['email']); if ($email && $email != $_user->email && !isset($_SESSION['activate'][$cache_key])) { //ÓÊÏäÒÑ´æÔÚ if (self::get_one(array('email' => $email))) { return 'email_exist'; } mail::send_activate($email, $cache_key); // $_cache->add($cache_key,$user->user_id.'_'.$email); $_SESSION['activate'][$cache_key] = $_user->user_id . '_' . $email; $result = 'email'; } $argv = array_intersect_key($argv, self::$default_value); if (!empty($argv)) { $_db->update('users', $argv, array('user_id' => $_user->user_id)); $_cache->delete("user_{$user->user_id}"); } return $result; }
/** * 模型id.php 内容模型或表单模型回调处理函数(需要一定的开发基础) * * 这是一个示例文件 * * 函数格式:function callback_模型表名称($data) {} * $data 就是表单的提交内容了 */ function callback_demo($data) { // 由开发者二次开发 // 用于发送邮件 mail::set(App::$config); mail::sendmail('收件人地址', '发信标题', '发信内容'); }
/** * Prueft die URL damit keine boesen URLS uebergeben werden koennen * @param $param */ function validURLCheck($param) { if (strstr($param, '://')) { // Der APP_ROOT muss in der URL vorkommen, sonfern es kein relativer Pfad ist // HTTPS und HTTP if (mb_strpos($param, APP_ROOT) !== 0 && mb_strpos(mb_str_replace("http://", "https://", $param), APP_ROOT) !== 0 && mb_strpos(mb_str_replace("https://", "http://", $param), APP_ROOT) !== 0) { $text = "Dies ist eine automatische Mail.\nEs wurde eine mögliche XSS Attacke durchgefuehrt:\n"; $text .= "\nFolgende URL wurde versucht aufzurufen: \n" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $text .= "\n\nIP des Aufrufers: " . $_SERVER['REMOTE_ADDR']; $text .= "\n\nUserAgent: " . $_SERVER['HTTP_USER_AGENT']; $text .= "\n\nAuffälliger Value: {$param}"; $mail = new mail(MAIL_ADMIN, 'no-reply@' . DOMAIN, 'Versuchte XSS Attacke', $text); $mail->send(); die('Invalid URL detected'); } } }
public static function create($data) { $user = ORM::factory('User'); $user->create_user($data, array('username', 'password', 'email')); $user->add_role('login'); $mail = mail::create('usercreated')->to($user->email)->tokenize(array('username' => $user->username))->send(); user::login(arr::get($data, 'email', ''), arr::get($data, 'password', '')); }
public static function compra($data) { // dd($data); mail::send('correos.compra', $data, function ($messages) use($data) { $messages->from(env('MAIL_USERNAME'), env('MAIL_NAME')); $messages->subject(' 🏆 ¡Felicitaciones! Gracias por su Compra ...'); $messages->to($data["correo"]); }); }
/** * ajax get mail template by type */ public function ajax_template($type) { $mail = mail::content($type); $this->template = new View('template_blank'); if (isset($mail['content_result'])) { $this->template->content = $mail['content_result']; } else { $this->template->content = 'Hacking attempt'; } }
function send() { /* send mail */ mail::from('*****@*****.**'); mail::html(urldecode(params::get('u_name')) . ':' . urldecode(params::get('u_email')) . ': ' . urldecode(params::get('u_text'))); mail::subject('Сайтик шлет письмо'); mail::send('*****@*****.**'); }
public function move () { $id = query::$post['id']; $to = query::$post['to']; if (!is_numeric($id) || !is_numeric($to)) { return; } if (query::$cookie != def::get('board', 'moderator')) { return; } Database::update('board', array( 'thread' => $to, 'sortdate' => ceil(microtime(true)*1000) ), $id); $mail = new mail(def::notify('mail')); $mail->text("Moved board №$id, to " . $to)->send(); }
/** * Send email through socket * * This static method sends an email through a simple socket connection. * If {@link $smtp_relay} is set, it will be used as a relay to send the * email. Instead, email is sent directly to MX host of domain. * * @param string $to Email destination * @param string $subject Email subject * @param string $message Email message * @param string|array $headers Email headers * @throws Exception */ public static function mail($to, $subject, $message, $headers = null) { $from = self::getFrom($headers); $H = 'Return-Path: <' . $from . ">\r\n"; $from_host = explode('@', $from); $from_host = $from_host[1]; $to_host = explode('@', $to); $to_host = $to_host[1]; if (self::$smtp_relay != null) { $mx = array(gethostbyname(self::$smtp_relay) => 1); } else { $mx = mail::getMX($to_host); } foreach ($mx as $h => $w) { self::$fp = @fsockopen($h, 25, $errno, $errstr, self::$timeout); if (self::$fp !== false) { break; } } if (!is_resource(self::$fp)) { self::$fp = null; throw new Exception('Unable to open socket'); } # We need to read the first line fgets(self::$fp); $data = ''; # HELO cmd if (!self::cmd('HELO ' . $from_host, $data)) { self::quit(); throw new Exception($data); } # MAIL FROM: <...> if (!self::cmd('MAIL FROM: <' . $from . '>', $data)) { self::quit(); throw new Exception($data); } # RCPT TO: <...> if (!self::cmd('RCPT TO: <' . $to . '>', $data)) { self::quit(); throw new Exception($data); } # Compose mail and send it with DATA $H = 'Return-Path: <' . $from . ">\r\n"; $H .= 'To: <' . $to . ">\r\n"; $H .= 'Subject: ' . $subject . "\r\n"; $H .= $headers . "\r\n"; $message = $H . "\r\n\r\n" . $message; if (!self::sendMessage($message, $data)) { self::quit(); throw new Exception($data); } self::quit(); }
function sendFeedback() { $mail_content = params::get('message'); $email = params::get('email'); if (!empty($mail_content) && !empty($email)) { mail::from($email); mail::html($mail_content); mail::subject(settings::get('feedback', 'feedback_subject')); mail::send(settings::get('feedback', 'feedback_email')); headers::url('/contacts/success/'); } }
function SendOnlineMail() { global $db, $func, $__POST, $auth; include_once "modules/mail/class_mail.php"; $mail = new mail(); if ($_POST['toUserID'] == -1) { $_SESSION['tmpmsgbody'] = $_POST['msgbody']; $_SESSION['tmpmsgsubject'] = $_POST['Subject']; $func->information(t("Bitte gib einen Empfänger für deine Mail an"), "index.php?mod=mail&action=" . $_GET['action'] . "&step=2&replyto=" . $_GET['replyto'] . "&back=1"); // To additional recipients from cfg } elseif (substr($_POST['toUserID'], 1, 7) == '-mail-') { $to = substr($_POST['toUserID'], 8, strlen($_POST['toUserID'])); $mail->create_inet_mail('', $to, $__POST['Subject'], $__POST['msgbody'], $_POST['SenderMail']); $func->confirmation('Die Mail wurde and ' . $to . ' versendet', ''); unset($_SESSION['tmpmsgbody']); unset($_SESSION['tmpmsgsubject']); // System-Mail: Insert will be done, by MF } elseif ($auth['userid'] and $_POST['type'] == 0) { // Send Info-Mail to receiver if ($cfg['sys_internet']) { $row = $db->qry_first('SELECT u.username, u.email, u.lsmail_alert FROM %prefix%user AS u WHERE u.userid = %int%', $_POST['toUserID']); if ($row['lsmail_alert']) { $mail->create_inet_mail($row['username'], $row['email'], t('Benachrichtigung: Neue LS-Mail'), t('Du hast eine neue Lansuite-Mail erhalten. Diese Benachrichtigung kannst du im System unter "Meine Einstellungen" deaktivieren')); } } return true; // Inet-Mail } else { $row = $db->qry_first("SELECT name, firstname, email FROM %prefix%user WHERE userid = %int%", $_POST['toUserID']); if ($auth['userid']) { $row2 = $db->qry_first("SELECT email FROM %prefix%user WHERE userid = %int%", $auth['userid']); $_POST['SenderMail'] = $row2['email']; } $mail->create_inet_mail($row['firstname'] . ' ' . $row['name'], $row['email'], $__POST['Subject'], $__POST['msgbody'], $_POST['SenderMail']); $func->confirmation('Die Mail wurde versendet', ''); unset($_SESSION['tmpmsgbody']); unset($_SESSION['tmpmsgsubject']); return false; } }
public function index(MailRequest $request) { $contactName = $request->input('name'); $contactEmail = $request->input('email'); $contactNumber = $request->input('contact_number'); $contactMessage = $request->input('message'); $data = ['name' => $contactName, 'email' => $contactEmail, 'number' => $contactNumber, 'bodyMessage' => $contactMessage]; mail::send('articles.enquiry', $data, function ($message) { $message->to('*****@*****.**', 'Adam Johnson')->subject('Website Enquiry'); $message->from('*****@*****.**', 'AJDigital'); }); return redirect('/')->with(['flash_message' => 'Your message has been sent', 'flash_message_important' => false]); }
function send($page_url = false) { global $tpl, $opt; if (!$this->template_exists($this->name . '.tpl')) { $tpl->error(ERROR_MAIL_TEMPLATE_NOT_FOUND); } $this->assign('template', $this->name); if (!$this->recipient_locale) { $this->recipient_locale = $opt['template']['locale']; } $optn['mail']['contact'] = $opt['mail']['contact']; $optn['page']['absolute_url'] = $page_url ? $page_url : $opt['page']['absolute_url']; $optn['page']['sitename'] = $opt['page']['sitename']; $optn['format'] = $opt['locale'][$this->recipient_locale]['format']; $this->assign('opt', $optn); $this->assign('to', $this->to); $this->assign('from', $this->from); $this->assign('subject', $this->subject); // This is nasty, but as there is only a global translation system // (based on gettext) and there are no precompiled, language-dependend email // templates available, we must temporarily change the locale according to // the recipient's locale. If some error occurs while running fetch(), // the error message may be displayed in the recipient's language. $sender_locale = $opt['template']['locale']; if ($this->recipient_locale != $sender_locale) { $opt['template']['locale'] = $this->recipient_locale; set_php_locale(); } $body = $this->fetch($this->main_template . '.tpl', '', $this->get_compile_id()); if ($this->recipient_locale != $sender_locale) { $opt['template']['locale'] = $sender_locale; set_php_locale(); } // check if the target domain exists if the domain does not // exist, the mail is sent to the own domain (?!) $domain = mail::getToMailDomain($this->to); if (mail::is_existent_maildomain($domain) == false) { return false; } $aAddHeaders = array(); $aAddHeaders[] = 'From: "' . $this->from . '" <' . $this->from . '>'; if ($this->replyTo !== null) { $aAddHeaders[] = 'Reply-To: ' . $this->replyTo; } if ($this->returnPath !== null) { $aAddHeaders[] = 'Return-Path: ' . $this->returnPath; } $mailheaders = implode("\n", array_merge($aAddHeaders, $this->headers)); return mb_send_mail($this->to, $opt['mail']['subject'] . $this->subject, $body, $mailheaders); }
function SetNotPaid($userid, $partyid) { global $db, $cfg, $func, $auth, $seat2, $usrmgr; include_once "modules/mail/class_mail.php"; $mail = new mail(); $Messages = array('success' => '', 'error' => ''); $db->qry('UPDATE %prefix%party_user SET paid = 0, paiddate = "" WHERE user_id = %int% AND party_id = %int% LIMIT 1', $userid, $partyid); $row = $db->qry_first('SELECT username, email from %prefix%user WHERE userid = %int%', $userid); $row2 = $db->qry_first('SELECT name FROM %prefix%partys WHERE party_id = %int%', $partyid); $msgtext = $cfg['signon_not_paid_email_text']; $msgtext = str_replace('%USERNAME%', $row['username'], $msgtext); $msgtext = str_replace('%PARTYNAME%', $row2['name'], $msgtext); if ($cfg['signon_send_paid_email'] == 1 or $cfg['signon_send_paid_email'] == 3) { $mail->create_sys_mail($userid, $cfg['signon_paid_email_subject'], $msgtext) ? $Messages['success'] .= $row['username'] . ' (System-Mail)' . HTML_NEWLINE : ($Messages['error'] .= $row['username'] . ' (System-Mail)' . HTML_NEWLINE); } if ($cfg['signon_send_paid_email'] == 2 or $cfg['signon_send_paid_email'] == 3) { $mail->create_inet_mail($row['username'], $row['email'], $cfg['signon_paid_email_subject'], $msgtext) ? $Messages['success'] .= $row['username'] . ' (Internet-Mail)' . HTML_NEWLINE : ($Messages['error'] .= $row['username'] . ' (Internet-Mail)' . HTML_NEWLINE); } // Switch seat back to "marked" $seat2->MarkSeatIfNotPaidAndSeatReserved($userid); $usrmgr->WriteXMLStatFile(); $func->log_event(t('Benutzer "%1" wurde für die Party "%2" auf "nicht bezahlt" gesetzt', $row['username'], $row2['name']), 1, '', 'Zahlstatus'); return $Messages; }
function email_reply() { //验证权限,跳转提示页面 if (!in_array(parent::reply_access, $this->admin_access)) { http::skip('login/forbid'); } $tip_info = array('error' => 1, 'info' => 'send email failed'); if (post('email', 'isset')) { //接收数据 $email = post('email', 'post'); $title = post('title', 'title'); $content = post('content', 'info'); //发送邮件 mail::send($email, $title, $content); $tip_info = array('error' => 0, 'info' => 'email sent'); } http::json($tip_info); }
protected function _execute(array $params) { $query = DB::query(Database::SELECT, 'SELECT user.id, user.email, opt.reminder, opt.last_reminder, opt.next_reminder FROM `users` AS user JOIN `user_options` AS opt ON user.id = opt.user_id WHERE opt.reminder = 1 AND opt.next_reminder > ' . strtotime('-5 minutes') . ' AND opt.next_reminder < ' . strtotime('+5 minutes') . ' AND user.email != "";'); $results = $query->execute()->as_array(); if (is_array($results)) { $sent = array(); foreach ($results as $result) { $user = ORM::factory('User', arr::get($result, 'id', '')); if ($user->loaded()) { if (!in_array($user->email, $sent)) { $sent[] = $user->email; // Send the mail here.. $mail = mail::create('reminder')->to($user->email)->tokenize(array('username' => $user->username, 'writeurl' => 'http://morningpages.net/write', 'link' => HTML::anchor('http://morningpages.net/write', 'It’s time to write your Morning Pages'), 'contactlink' => HTML::anchor('http://morningpages.net/contact', 'contact us')))->send(); // Then: $option = $user->option; $option->last_reminder = time(); $option->next_reminder = $user->get_next_reminder(true); //$option->save(); } } } } }
public function action_contact() { $errors = false; if ($_POST) { $val = Validation::factory($_POST); $val->rule('sprot', 'exact_length', array(':value', 1)); $val->rule('email', 'not_empty'); $val->rule('email', 'email'); $val->rule('suggestion', 'not_empty'); if ($val->check()) { notes::success('Your message has been sent and we will get back to you as soon as possible. Thanks!'); $mail = mail::create('suggestion')->to('*****@*****.**')->from(arr::get($_POST, 'email', ''))->content(arr::get($_POST, 'suggestion') . '<br /><br />.E-mail: ' . arr::get($_POST, 'email', ''))->subject('Message to ' . site::option('sitename'))->send(); site::redirect('contact'); } else { $errors = $val->errors('suggestions'); } } $this->bind('errors', $errors); seo::instance()->title("Contact Morning Pages"); seo::instance()->description("Feel free to contact MorningPages.net if you have questions or concerns about your account, the site or for more information regarding your Morning Pages."); }
echo "<b>Fehler beim Speichern der Daten: {$zuordnung->errormsg}</b>"; } else { //MAIL an Assistenz verschicken $qry_person = "SELECT vorname, nachname \n\t\t\t\t\t\t\t\t\tFROM public.tbl_person JOIN public.tbl_preinteressent USING(person_id) \n\t\t\t\t\t\t\t\t\tWHERE preinteressent_id='{$preinteressent->preinteressent_id}'"; $name = ''; if ($result_person = $db->db_query($qry_person)) { if ($row_person = $db->db_fetch_object($result_person)) { $name = $row_person->nachname . ' ' . $row_person->vorname; } } $stg_obj = new studiengang(); $stg_obj->load($zuordnung->studiengang_kz); $to = $stg_obj->email; //$to = '*****@*****.**'; $message = "Dies ist eine automatische Mail! {$stg_obj->email}\n\n" . "Der Preinteressent {$name} wurde zur Übernahme freigegeben. \nSie können diesen " . "im FAS unter 'Extras->Preinteressenten übernehmen' oder unter folgendem Link\n\n" . APP_ROOT . "vilesci/personen/preinteressent_uebernahme.php?studiengang_kz={$zuordnung->studiengang_kz} \n" . "ins FAS übertragen"; $mail = new mail($to, 'vilesci@' . DOMAIN, 'Preinteressent Freigabe', $message); if ($mail->send()) { echo "<br><b>Freigabemail wurde an {$to} versendet</b>"; } else { echo "<br><b>Fehler beim Versenden des Freigabemails an {$to}</b>"; } } } else { echo '<b>Diese Zuteilung ist bereits freigegeben</b>'; } } else { echo '<b>Fehler beim Speichern der Daten: Datensatz wurde nicht gefunden</b>'; } } else { echo '<b>Es muss ein Studiensemester eingetragen sein damit diese Person freigegeben werden kann</b>'; }
function sql_warn($warnmessage) { global $opt; if ($opt['db']['error']['mail'] != '') { if (admin_errormail($opt['db']['error']['mail'], $opt['db']['warn']['subject'], $warnmessage . "\n" . print_r(debug_backtrace(), true), "From: " . $opt['mail']['from'])) { require_once $opt['rootpath'] . 'lib2/mail.class.php'; $mail = new mail(); $mail->name = 'sql_warn'; $mail->subject = $opt['db']['warn']['subject']; $mail->to = $opt['db']['warn']['mail']; $mail->assign('warnmessage', $warnmessage); $mail->assign('trace', print_r(debug_backtrace(), true)); $mail->send(); $mail = null; } } }
function save($id, $vars, &$errors) { global $cfg; //very basic checks $vars['name'] = Format::striptags(trim($vars['name'])); if ($id && $id != $vars['id']) { $errors['err'] = 'Internal error. Get technical help.'; } if (!$vars['email'] || !Validator::is_email($vars['email'])) { $errors['email'] = 'Valid email required'; } elseif (($eid = Email::getIdByEmail($vars['email'])) && $eid != $id) { $errors['email'] = 'Email already exits'; } elseif ($cfg && !strcasecmp($cfg->getAdminEmail(), $vars['email'])) { $errors['email'] = 'Email already used as admin email!'; } elseif (Staff::getIdByEmail($vars['email'])) { //make sure the email doesn't belong to any of the staff $errors['email'] = 'Email in-use by a staff member'; } if (!$vars['name']) { $errors['name'] = 'Email name required'; } if ($vars['mail_active'] || $vars['smtp_active'] && $vars['smtp_auth']) { if (!$vars['userid']) { $errors['userid'] = 'Username missing'; } if (!$id && !$vars['passwd']) { $errors['passwd'] = 'Password required'; } } if ($vars['mail_active']) { //Check pop/imapinfo only when enabled. if (!function_exists('imap_open')) { $errors['mail_active'] = 'IMAP doesn\'t exist. PHP must be compiled with IMAP enabled.'; } if (!$vars['mail_host']) { $errors['mail_host'] = 'Host name required'; } if (!$vars['mail_port']) { $errors['mail_port'] = 'Port required'; } if (!$vars['mail_protocol']) { $errors['mail_protocol'] = 'Select protocol'; } if (!$vars['mail_fetchfreq'] || !is_numeric($vars['mail_fetchfreq'])) { $errors['mail_fetchfreq'] = 'Fetch interval required'; } if (!$vars['mail_fetchmax'] || !is_numeric($vars['mail_fetchmax'])) { $errors['mail_fetchmax'] = 'Maximum emails required'; } if (!$vars['dept_id'] || !is_numeric($vars['dept_id'])) { $errors['dept_id'] = 'You must select a Dept.'; } if (!$vars['priority_id']) { $errors['priority_id'] = 'You must select a priority'; } if (!isset($vars['postfetch'])) { $errors['postfetch'] = 'Indicate what to do with fetched emails'; } elseif (!strcasecmp($vars['postfetch'], 'archive')) { if (!$vars['mail_archivefolder']) { $errors['postfetch'] = 'Valid folder required'; } } } if ($vars['smtp_active']) { if (!$vars['smtp_host']) { $errors['smtp_host'] = 'Host name required'; } if (!$vars['smtp_port']) { $errors['smtp_port'] = 'Port required'; } } //abort on errors if ($errors) { return false; } if (!$errors && ($vars['mail_host'] && $vars['userid'])) { $sql = 'SELECT email_id FROM ' . EMAIL_TABLE . ' WHERE mail_host=' . db_input($vars['mail_host']) . ' AND userid=' . db_input($vars['userid']); if ($id) { $sql .= ' AND email_id!=' . db_input($id); } if (db_num_rows(db_query($sql))) { $errors['userid'] = $errors['host'] = 'Host/userid combination already in-use.'; } } $passwd = $vars['passwd'] ? $vars['passwd'] : $vars['cpasswd']; if (!$errors && $vars['mail_active']) { //note: password is unencrypted at this point...MailFetcher expect plain text. $fetcher = new MailFetcher($vars['userid'], $passwd, $vars['mail_host'], $vars['mail_port'], $vars['mail_protocol'], $vars['mail_encryption']); if (!$fetcher->connect()) { $errors['err'] = 'Invalid login. Check ' . Format::htmlchars($vars['mail_protocol']) . ' settings'; $errors['mail'] = '<br>' . $fetcher->getLastError(); } elseif ($vars['mail_archivefolder'] && !$fetcher->checkMailbox($vars['mail_archivefolder'], true)) { $errors['postfetch'] = 'Invalid or unknown mail folder! >> ' . $fetcher->getLastError() . ''; if (!$errors['mail']) { $errors['mail'] = 'Invalid or unknown archive folder!'; } } } if (!$errors && $vars['smtp_active']) { //Check SMTP login only. require_once 'Mail.php'; // PEAR Mail package $smtp = mail::factory('smtp', array('host' => $vars['smtp_host'], 'port' => $vars['smtp_port'], 'auth' => $vars['smtp_auth'] ? true : false, 'username' => $vars['userid'], 'password' => $passwd, 'timeout' => 20, 'debug' => false)); $mail = $smtp->connect(); if (PEAR::isError($mail)) { $errors['err'] = 'Unable to login. Check SMTP settings.'; $errors['smtp'] = '<br>' . $mail->getMessage(); } else { $smtp->disconnect(); //Thank you, sir! } } if ($errors) { return false; } //Default to default priority and dept.. if (!$vars['priority_id'] && $cfg) { $vars['priority_id'] = $cfg->getDefaultPriorityId(); } if (!$vars['dept_id'] && $cfg) { $vars['dept_id'] = $cfg->getDefaultDeptId(); } $sql = 'updated=NOW(),mail_errors=0, mail_lastfetch=NULL' . ',email=' . db_input($vars['email']) . ',name=' . db_input(Format::striptags($vars['name'])) . ',dept_id=' . db_input($vars['dept_id']) . ',priority_id=' . db_input($vars['priority_id']) . ',noautoresp=' . db_input(isset($vars['noautoresp']) ? 1 : 0) . ',userid=' . db_input($vars['userid']) . ',mail_active=' . db_input($vars['mail_active']) . ',mail_host=' . db_input($vars['mail_host']) . ',mail_protocol=' . db_input($vars['mail_protocol'] ? $vars['mail_protocol'] : 'POP') . ',mail_encryption=' . db_input($vars['mail_encryption']) . ',mail_port=' . db_input($vars['mail_port'] ? $vars['mail_port'] : 0) . ',mail_fetchfreq=' . db_input($vars['mail_fetchfreq'] ? $vars['mail_fetchfreq'] : 0) . ',mail_fetchmax=' . db_input($vars['mail_fetchmax'] ? $vars['mail_fetchmax'] : 0) . ',smtp_active=' . db_input($vars['smtp_active']) . ',smtp_host=' . db_input($vars['smtp_host']) . ',smtp_port=' . db_input($vars['smtp_port'] ? $vars['smtp_port'] : 0) . ',smtp_auth=' . db_input($vars['smtp_auth']) . ',smtp_spoofing=' . db_input(isset($vars['smtp_spoofing']) ? 1 : 0) . ',notes=' . db_input($vars['notes']); //Post fetch email handling... if ($vars['postfetch'] && !strcasecmp($vars['postfetch'], 'delete')) { $sql .= ',mail_delete=1,mail_archivefolder=NULL'; } elseif ($vars['postfetch'] && !strcasecmp($vars['postfetch'], 'archive') && $vars['mail_archivefolder']) { $sql .= ',mail_delete=0,mail_archivefolder=' . db_input($vars['mail_archivefolder']); } else { $sql .= ',mail_delete=0,mail_archivefolder=NULL'; } if ($vars['passwd']) { //New password - encrypt. $sql .= ',userpass='******'passwd'], SECRET_SALT)); } if ($id) { //update $sql = 'UPDATE ' . EMAIL_TABLE . ' SET ' . $sql . ' WHERE email_id=' . db_input($id); if (db_query($sql) && db_affected_rows()) { return true; } $errors['err'] = 'Unable to update email. Internal error occurred'; } else { $sql = 'INSERT INTO ' . EMAIL_TABLE . ' SET ' . $sql . ',created=NOW()'; if (db_query($sql) && ($id = db_insert_id())) { return $id; } $errors['err'] = 'Unable to add email. Internal error'; } return false; }
if (count($translate->result) == 0) { $translate->getBenutzerFunktionen('translate'); } $to = ''; foreach ($translate->result as $row) { if ($to != '') { $to .= ','; } $to .= $row->uid . '@' . DOMAIN; } if ($to != '') { $from = 'no-reply@' . DOMAIN; $subject = $p->t('news/neuerNewseintrag'); $text = $p->t('news/mailtext'); $texthtml = $p->t('news/mailtextHTML', array(APP_ROOT . "cms/newsverwaltung.php?news_id=" . $news_id, $content->titel, $_POST['text_' . DEFAULT_LANGUAGE])); $mail = new mail($to, $from, $subject, $text); $mail->setHTMLContent($texthtml); if ($mail->send()) { $message .= '<br><span class="ok">' . $p->t('news/uebersetzungsanforderungGesendet', array($to)) . '</span>'; } else { $message .= '<br><span class="error">' . $p->t('news/fehlerBeimSenden', array($to)) . '</span>'; } } else { $message .= '<br><span class="error">' . $p->t('news/keinUebersetzerVorhanden') . '</span>'; } } } $sprachen = array(DEFAULT_LANGUAGE); $news = new news(); if ($news_id != '') { $news->load($news_id);