public function email() { $smtpemailto = "*****@*****.**"; //发送给谁 $mailsubject = "Test Subject"; //邮件主题 $mailbody = "<h1>This is a test mail</h1>"; //邮件内容 $mailtype = "HTML"; //邮件格式(HTML/TXT),TXT为文本邮件 $smtp = new MailHandler(true); //这里面的一个true是表示使用身份验证,否则不使用身份验证. echo $smtp->sendmail($smtpemailto, $mailsubject, $mailbody, $mailtype); }
#!/usr/bin/env php <?php /* * StatusNet - the distributed open-source microblogging tool * Copyright (C) 2008, 2009, StatusNet, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $helptext = <<<END_OF_HELP Script for converting mail messages into notices. Takes message body as STDIN. END_OF_HELP; require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/lib/mailhandler.php'; if (common_config('emailpost', 'enabled')) { $mh = new MailHandler(); $mh->handle_message(file_get_contents('php://stdin')); }
// SET WORK ORDER $getWorkOrder = new Table; $getWorkOrder->setSQLType($fms_db->getSQLType()); $getWorkOrder->setInstance($fms_db->getInstance()); $getWorkOrder->setView("v_workordermaster"); $getWorkOrder->setParam("WHERE woReferenceNo = '$id'"); $getWorkOrder->doQuery("query"); $row_getWorkOrder = $getWorkOrder->getLists(); if($status == 1 && $isSent == 0){ $mailFrom = array("name" => "no-reply", "email" => "*****@*****.**"); $mailTo = array("name" => $immediateHead, "email" => $immediateEmailAddr); $mail = new MailHandler; $mail->setMailFrom($mailFrom); $mail->setMailTo($mailTo); $mail->setWO($row_getWorkOrder[0]); $mail->setWONotification($row_getWorkOrder[0]); if($mail->sendMail()){ // SET WORK ORDER $workorder = new Table; $workorder->setSQLType($fms_db->getSQLType()); $workorder->setInstance($fms_db->getInstance()); $workorder->setTable("workordermaster"); $workorder->setValues("isSent = '1'"); $workorder->setParam("WHERE woReferenceNo = '$id'"); $workorder->doQuery("update"); }
/** * Sends a confirmation link to email address given * * @return unknown */ public function sendConfirmationLink($StLogin) { $this->execSQL("\nSELECT\n count(*) as ItCount\nFROM\n " . DBPREFIX . "User\nWHERE\n StEmail = '{$StLogin}'"); $ArResult = $this->getResult('num'); if ($ArResult[0][0] != 1) { throw new ErrorHandler(EXC_USER_WRONGUSER); } $StLink = $this->generateConfirmationLink($StLogin); $ArMsg = $this->generateMessage($StLink); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); $BoResult = $MailHandler->sendMail($StLogin, LNG_PASSREM_SUBJ, $ArMsg[0], $ArMsg[1]); return $BoResult; }
/** * send an email to admins alerting about an error * * @author Dimitri Lameri <*****@*****.**> * */ private function _adviseAdmins() { $ArAdmins = $this->_getAdminsMail(); $Text = $this->_getErrorAsHTML(false); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); if (is_array($ArAdmins)) { $MailHandler->sendMail($ArAdmins, ERR_MAIL_SUBJ, $Text, 'content-type:text/html;utf-8'); } }
$message = file_get_contents('response_mail.html'); $message = str_replace("<CASE_NUMBER>", $encodedId, $message); $message = str_replace("<HILLCREST_THREAD_IDENTIFIER>", "<--hclabs:" . $encodedId . ":hclabs-->", $message); $message = str_replace("<CASE_SUBJECT>", $subject, $message); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->Host = "mail.rinkes.us"; $mail->Port = 26; $mail->Username = "******"; $mail->Password = "******"; $mail->SetFrom('*****@*****.**', 'Hillcrest Customer Support'); $mail->AddReplyTo('*****@*****.**', 'Hillcrest Customer Support'); $mail->Subject = "Hillcrest Laboratories Support Request - ID:" . $encodedId . " - " . $subject; $mail->AltBody = "Top view the message, please use an HTML compatible e-mail viewer!"; $mail->MsgHTML($message); $mail->AddAddress($email_address, $email_address); if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } } } $mailhandler = new MailHandler(); $mailhandler->setMailbox("mail.rinkes.us", 110, "*****@*****.**", "supportpw123", "pop3", false, "INBOX", true); $mailhandler->setDatabase("localhost", "root", "", "hillcrest_projects"); $mailhandler->checkMail(); $mailhandler->storeMail(); $mailhandler->deleteNewMessages(); ?>
<?php /* * jQuery File Upload Plugin PHP Example 5.14 * https://github.com/blueimp/jQuery-File-Upload * * Copyright 2010, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ error_reporting(E_ALL | E_STRICT); require_once 'MetadataHandler.php'; require_once 'UploadHandler.php'; require_once 'MailHandler.php'; if (isset($_GET["payload"]) && trim($_GET["payload"]) === 'metadata') { $metadata_handler = new MetadataHandler(); $id = $metadata_handler->saveMetadata($_POST["title"], $_POST["description"], $_POST["author"], $_POST["email"], $_POST["time"], $_POST["geo"], $_POST["source"]); try { $mail_handler = new MailHandler(); $mail_handler->notifyAdmins($id, $_POST["title"], $_POST["description"], $_POST["author"], $_POST["email"], $_POST["time"], $_POST["geo"], $_POST["source"]); } catch (Exception $e) { error_log("Couldn't send email" . $e->getMessage()); } echo json_encode('{"id":' . $id . '}'); } else { $upload_handler = new UploadHandler(); $upload_handler->initialize(); }
/** * Send an email to all users related to the ticket given for each new message. * * @param int $IDTicket * @return Boolean */ public function _sendNotifyMessage($IDTicket) { $ArUsersDepartment = array(); $ArUsersDepartmentReader = array(); # # Preparing mail header # $ArEmails = $ArUsersDepartment = $ArUsersDepartmentReader = array(); $MailHandler = new MailHandler(); $MailHandler->setHTMLBody(true); $StHeaders = "MIME-Version: 1.0\r\n"; $StHeaders .= "Content-type: text/html; charset=utf-8\r\n"; # # Get the users related with the ticket # $ArRecipients = $this->getTicketDestination($IDTicket); $ArReaders = $this->getTicketReaders($IDTicket); $StSQL = ' SELECT StEmail, BoNotify FROM ' . DBPREFIX . 'User U LEFT JOIN ' . DBPREFIX . "Ticket T ON (T.IDUser = U.IDUser)\nWHERE\n T.IDTicket = {$IDTicket}"; $this->execSQL($StSQL); $ArResult = $this->getResult('string'); # # Get the department related with the ticket and his supporters # $ArDepartment = array_shift($this->getTicketDepartments($IDTicket)); $ArDepartmentReaders = array_shift($this->getTicketDepartmentsReader($IDTicket)); if (isset($ArDepartment['IDDepartment']) && isset($ArDepartmentReaders['IDDepartment'])) { $ArUsersDepartment = F1DeskUtils::getDepartmentSupporters($ArDepartment['IDDepartment']); $ArUsersDepartmentReader = F1DeskUtils::getDepartmentSupporters($ArDepartmentReaders['IDDepartment']); } # # Merging all users in one array # $ArUsers = array_merge($ArRecipients, $ArReaders); $ArUsersDepart = array_merge($ArUsersDepartment, $ArUsersDepartmentReader); $ArFinal = array_merge($ArUsers, $ArUsersDepart); $ArFinal = array_merge($ArFinal, $ArResult); # # Insert Message and Subject and strip the emails that already are in array # foreach ($ArFinal as $User) { if ($User['BoNotify']) { if (array_search($User['StEmail'], $ArEmails) === false) { $ArEmails[] = $User['StEmail']; } } } $StSubject = str_replace('###TKTNUM###', $IDTicket, NOTIFY_SUBJ); $StMessage = str_replace('###TKTNUM###', $IDTicket, NOTIFY_MESSAGE); $BoResult = $MailHandler->sendMail($ArEmails, $StSubject, $StMessage, $StHeaders); return $BoResult; }
$error .= 'Por favor proporcione un título.<br />'; } // Check message (length) if (!$message || strlen($message) < 3) { $error .= "Por favor ingrese un mensaje, el mensaje debe contener al menos 3 caracteres.<br />"; } // Check captcha if (strlen($captcha) == 0) { $error .= " Su validacion contra robots no es valida.<br />"; } // Check timer if (isset($_SESSION['secure']['time']) && time() - $_SESSION['nonce']['time'] < 30) { $error .= "Esta muy rapido, no parece humano!<br />"; } if (!$error) { $em = new MailHandler(); $mail = $em->send_email_msg(WEBMASTER_EMAIL, $email, $firstname, $lastname, $message, $suscribirme); //$mail = mail( WEBMASTER_EMAIL, $subject, $message, // "From: ". $name ." <".$email.">\r\n" //."Reply-To: ".$email."\r\n" //."X-Mailer: PHP/" . phpversion() ); if ($mail) { if ($suscribirme == "Si") { registrar_email_en_mailchimp($email, $firstname, $lastname); } echo 'OK'; } else { echo $mail; } } else { echo $error;
function send_mail($to,$subject,$message,$nickname='',$email='',$attachments=array(),$priority=3,$html=true,$smtp_config=array()) { if(!($nickname && $email)) { $sys_config = ConfigHandler::get(); $nickname = $sys_config['site_name']; $email = $sys_config['site_admin_email']; } $smtp_config = $smtp_config ? $smtp_config : ConfigHandler::get('smtp'); if($smtp_config['enable']) { if($nickname && $email) $smtp_config['email_from'] = "{$nickname} <{$email}>"; return _send_mail_by_smtp($to,$subject,$message,$smtp_config,$html); } else { static $MailHandler=null; if(is_null($MailHandler)!=false) { $MailHandler=new MailHandler($email,$nickname,true); } if(is_array($attachments) and count($attachments)>=1) { $boundary="----_NextPart_".md5(uniqid(time()))."_000"; $MailHandler->SetHeader('Content-Type: multipart/mixed;boundary="'.$boundary.'"'); $body="--".$boundary."".NEW_LINE.""; $body.="Content-Type: text/html; charset=\"GB2312\"".NEW_LINE.""; $body.="Content-Transfer-Encoding: base64".NEW_LINE."".NEW_LINE.""; $body.=chunk_split(base64_encode($message))."".NEW_LINE.""; foreach($attachments as $attachment) { $body.="--".$boundary."".NEW_LINE.""; $body.="Content-Type: application/octet-stream;".NEW_LINE."\t\tname=\"{$attachment['name']}\"".NEW_LINE.""; $body.="Content-Transfer-Encoding: base64".NEW_LINE.""; $body.="Content-Disposition: attachment;".NEW_LINE."\t\tFileName=\"{$attachment['name']}\"".NEW_LINE."".NEW_LINE.""; $body.=chunk_split(base64_encode(file_get_contents($attachment['path'])))."".NEW_LINE."";; } $message=$body; } else { if(false!=$html) { $MailHandler->SetHeader('Content-Type: text/html; charset=gb2312'); } } $MailHandler->SetSenderName($nickname); $MailHandler->SetSenderMail($email); $MailHandler->SetSendMailFrom($email); $MailHandler->SetUseHtml($html); $MailHandler->SetHeader("Return-Path: {$email}"); $MailHandler->SetHeader("MIME-Version: 1.0"); $MailHandler->SetHeader("X-Priority: $priority"); $MailHandler->SetHeader("Sender: {$email}"); $MailHandler->SetRecipient($to); $MailHandler->SetSubject($subject); $MailHandler->SetMessage($message); Return $MailHandler->doSend(); } }