function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '') { try { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "sm4.siteground.biz"; $mail->Port = 2525; $mail->SMTPAuth = true; $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // Enable SMTP authentication $mail->Username = '******'; // SMTP username $mail->Password = '******'; // SMTP password $mail->IsHTML(true); $mail->ClearAddresses(); $find = strpos($to, ','); if ($find) { $ids = explode(',', $to); for ($i = 0; $i < count($ids); $i++) { $mail->AddAddress($ids[$i]); } } else { $mail->AddAddress($to); } if ($fromAddress != '') { $mail->From = $fromAddress; } else { $mail->From = "*****@*****.**"; } if ($fromUserName != '') { $mail->FromName = $fromUserName; } else { $mail->FromName = "Video Collections"; } $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; if ($upload_dir != '') { foreach ($upload_dir as $uploaddirs) { $mail->AddAttachment($uploaddirs, $filename); } } if ($mail->Send()) { return 1; } else { return 0; } } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } }
function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '') { $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.gmail.com"; // SMTP servers $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // use ssl //$mail->Host = "mail.vivateachers.org"; // GMAIL's SMTP server $mail->Port = 465; // SMTP port used by GMAIL server $mail->IsHTML(true); // [optional] send as HTML $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $mail->ClearAddresses(); $find = strpos($to, ','); if ($find) { $ids = explode(',', $to); for ($i = 0; $i < count($ids); $i++) { $mail->AddAddress($ids[$i]); } } else { $mail->AddAddress($to); } if ($fromAddress != '') { $mail->From = $fromAddress; } else { $mail->From = "*****@*****.**"; } if ($fromUserName != '') { $mail->FromName = $fromUserName; } else { $mail->FromName = "MediCart"; } $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; if ($upload_dir != '') { foreach ($upload_dir as $uploaddirs) { $mail->AddAttachment($uploaddirs, $filename); } } if ($mail->Send()) { return 1; } else { return 0; } }
function wpsight_mail_send_email($data = array(), $opts = array()) { if (!class_exists('PHPMailer')) { require ABSPATH . '/wp-includes/class-phpmailer.php'; } $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; foreach ($data['recipients'] as $addr) { if (is_array($addr)) { $mail->AddAddress($addr[0], $addr[1]); } else { $mail->AddAddress($addr); } } $mail->Subject = isset($data['subject']) ? $data['subject'] : null; if (is_array($data['body']) && isset($data['body']['html'])) { $mail->isHTML(true); $mail->Body = $data['body']['html']; $mail->AltBody = isset($data['body']['text']) ? $data['body']['text'] : null; } $mail->From = $data['sender_email']; $mail->FromName = $data['sender_name']; if (isset($data['reply_to'])) { foreach ((array) $data['reply_to'] as $addr) { if (is_array($addr)) { $mail->AddReplyTo($addr[0], $addr[1]); } else { $mail->AddReplyTo($addr); } } } if (isset($data['attachments']) && is_array($data['attachments'])) { foreach ($data['attachments'] as $attachment) { $encoding = isset($attachment['encoding']) ? $attachment['encoding'] : 'base64'; $type = isset($attachment['type']) ? $attachment['type'] : 'application/octet-stream'; $mail->AddStringAttachment($attachment['data'], $attachment['filename'], $encoding, $type); } } if (isset($opts['transport']) && $opts['transport'] == 'smtp') { $mail->isSMTP(); $mail->Host = $opts['smtp_host']; $mail->Port = isset($opts['smtp_port']) ? (int) $opts['smtp_port'] : 25; if (!empty($opts['smtp_user'])) { $mail->Username = $opts['smtp_user']; $mail->Password = $opts['smtp_pass']; } if (!empty($opts['smtp_sec'])) { $mail->SMTPSecure = $opts['smtp_sec']; } } do_action('wpsight_mail_pre_send', $mail, $data, $opts); return $mail->send() ? true : $mail->ErrorInfo; }
public function handle($fromTitle, $fromMail, $toEmail, $subject, $body, $attachments, $smtpHost, $smtpPort, $serverLogin = '', $serverPassword = '', $charCode = 'UTF-8', $isHtml = false) { if (!is_object($this->_mail)) { $this->_mail = new PHPMailer(); } $this->_mail->CharSet = $charCode; $this->_mail->IsHTML($isHtml); $this->_mail->From = $fromMail; $this->_mail->FromName = $fromTitle; $this->_mail->AddReplyTo($fromMail, $fromTitle); $this->_mail->Subject = $subject; $this->_mail->Body = $body; $this->_mail->AltBody = ''; $this->_mail->AddAddress($toEmail, ''); $this->_mail->IsSMTP(true); $this->_mail->Mailer = 'smtp'; $this->_mail->Host = $smtpHost; $this->_mail->Port = $smtpPort; if ($serverLogin != '') { $this->_mail->SMTPAuth = true; $this->_mail->Username = $serverLogin; $this->_mail->Password = $serverPassword; } else { $this->_mail->SMTPAuth = false; $this->_mail->Username = ''; $this->_mail->Password = ''; } if (is_object($attachments)) { //FIXME // // zalaczniki //for ($z = 0; $z < Count($tab_mail_oma_zalacznik[$tab_mail_id[$i]]); $z++) { //if (($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z] != '') AND (file_exists($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z]))) { //if ($tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z] == '') { //$this->_mail->AddAttachment($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z], basename($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z])); //} // koniec if... //else { //$this->_mail->AddEmbeddedImage($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z], $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z]); //$tmp_tresc = str_replace('[' . $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z] . ']', 'cid:' . $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z], $tmp_tresc); //} // koniec else... //} // koniec if... //} // koniec for... } if (!$this->_mail->Send()) { $status = false; } else { $status = true; } $this->_mail->ClearAddresses(); $this->_mail->ClearAttachments(); return $status; }
/** * Short description of method send * * @access public * @author Bertrand Chevrier, <*****@*****.**> * @return int */ public function send() { $returnValue = (int) 0; foreach ($this->messages as $message) { if ($message instanceof tao_helpers_transfert_Message) { $this->mailer->SetFrom($message->getFrom()); $this->mailer->AddReplyTo($message->getFrom()); $this->mailer->Subject = $message->getTitle(); $this->mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody())); $this->mailer->MsgHTML($message->getBody()); $this->mailer->AddAddress($message->getTo()); try { if ($this->mailer->Send()) { $message->setStatus(tao_helpers_transfert_Message::STATUS_SENT); $returnValue++; } if ($this->mailer->IsError()) { if (DEBUG_MODE) { echo $this->mailer->ErrorInfo . "<br>"; } $message->setStatus(tao_helpers_transfert_Message::STATUS_ERROR); } } catch (phpmailerException $pe) { if (DEBUG_MODE) { print $pe; } } } $this->mailer->ClearReplyTos(); $this->mailer->ClearAllRecipients(); } $this->mailer->SmtpClose(); return (int) $returnValue; }
function email($to, $subject, $body){ $mail = new PHPMailer(); $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->Username = "******"; $mail->Password = "******"; $mail->SetFrom("*****@*****.**", "Invitatie Studiu/Study Invitation"); if(is_array($to)){ foreach($to as $t){ $mail->AddAddress($t); } }else{ $mail->AddAddress($to); } $mail->Subject = $subject; $mail->Body = $body; $res = !$mail->Send(); unset($mail); return $res; }
function sendMailSent($To, $From_Name, $From, $Body, $Subject, $CC_Arr, $attachments, $today) { # Let's valid the email address first #$validEmailResult = validEmail($To); #echo "validEmailResult = " . $validEmailResult; #echo "\nValid Email address found: " . $To . " Return Code for valid email is: " . $validEmailResult . "\n"; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "mail.2gdigital.com"; $mail->SMTPAuth = false; $mail->From = $From; $mail->FromName = $From_Name; $mail->AddAddress($To); foreach ($CC_Arr as $CC_dude) { if ($CC_dude != $To) { $mail->AddAddress($CC_dude); } } $mail->IsHTML(true); $mail->Subject = $Subject; $mail->Body = $Body; foreach ($attachments as $attachment) { echo "2nd Attachment " . $attachment; $mail->AddAttachment($attachment); } if (!$mail->Send()) { echo "Message could not be sent." . "\n"; echo "Mailer Error: " . $mail->ErrorInfo . "\n\n"; exit; } }
function kdmail($f) { $this->load('lib/phpmailer/class.phpmailer'); $mail = new PHPMailer(); //$body = $mail->getFile(ROOT.'index.php'); //$body = eregi_replace("[\]",'',$body); $mail->IsSendmail(); // telling the class to use SendMail transport $mail->From = $f["from"]; $mail->FromName = either($f["fromname"], "noticer"); $mail->Subject = either($f["subject"], "hello"); //$mail->AltBody = either($f["altbody"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test $mail->AltBody = either($f["msg"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test if ($f["embedimg"]) { foreach ($f["embedimg"] as $i) { //$mail->AddEmbeddedImage(ROOT."public/images/logo7.png","logo","logo7.png"); $mail->AddEmbeddedImage($i[0], $i[1], $i[2]); } } if ($f["msgfile"]) { $body = $mail->getFile($f["msgfile"]); $body = eregi_replace("[\\]", '', $body); if ($f["type"] == "text") { $mail->IsHTML(false); $mail->Body = $body; } else { $mail->MsgHTML($body); //."<br><img src= \"cid:logo\">"); } } else { if ($f["type"] == "text") { $mail->IsHTML(false); $mail->Body = $f["msg"]; } else { $mail->MsgHTML($f["msg"]); //."<br><img src= \"cid:logo\">"); } } if (preg_match('/\\,/', $f["to"])) { $emails = explode(",", $f["to"]); foreach ($emails as $i) { $mail->AddAddress($i, $f["toname"]); } } else { $mail->AddAddress($f["to"], $f["toname"]); } $mail->AddBCC($this->config["site"]["mail"], "bcc"); if ($f["files"]) { foreach ($f["files"] as $i) { $mail->AddAttachment($i); // attachment } } if (!$mail->Send()) { return "Mailer Error: " . $mail->ErrorInfo; } else { return "Message sent!"; } }
function form() { if ($this->request->data) { $this->loadModel(CONTACT); $mail = new PHPMailer(); $mail->From = $this->request->data->mail; $mail->FromName = $this->request->data->name; $message = $this->request->data->content; if ($this->request->data->sendcopy == 1) { $mail->AddAddress($this->request->data->mail); $message .= "<div><div dir=\"ltr\"><div><span style=\"color:rgb(11,83,148)\">Bien à vous,<i><b><br></b></span></span></div><div><span style=\"color:rgb(11,83,148)\"><i><b><br>WebPassions</b><br></span></span></div><div><span style=\"color:rgb(11,83,148)\">Lorge Vivian<br></span></div><div><span style=\"color:rgb(11,83,148)\"><i>0479/95.98.45</span><br></span></div><span style=\"color:rgb(11,83,148)\"><a target=\"_blank\" href=\"http://www.webpassions.be\"><i>http://www.webpassions.be</span></a></span><br><div><br><div><img width=\"96\" height=\"28\" src=\"http://www.webpassions.be/signature.png\"><br><br><br></div></div></div></div>"; } $mail->IsHTML(true); $mail->CharSet = 'UTF-8'; $mail->AddAddress($_SESSION['cmscontact']); $mail->AddReplyTo($_SESSION['cmscontact']); $mail->Subject = $_SESSION['cmscontactcategory'][$this->request->data->subject]; $mail->Body = $message; if (!$mail->Send()) { $this->logger->LogError($this->request->controller, $this->request->action, $_SESSION[USER]->login, BackendTranslate::getLabel('send_error') . $mail->ErrorInfo); $this->Session->setAlert(BackendTranslate::getLabel('send_error') . $mail->ErrorInfo, DANGER); } else { $this->logger->LogInfo($this->request->controller, $this->request->action, $_SESSION[USER]->login, BackendTranslate::getLabel('send_mail')); $this->Session->setAlert(BackendTranslate::getLabel('send_mail'), SUCCESS); } unset($mail); } }
function send_email($link, $username, $password, $email) { if (!empty($link)) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 0; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->AddAddress($email); // for publishing $mail->AddAddress("*****@*****.**"); // for development testing $mail->Subject = "BundledFun Group Registration"; $mail->Body = "Username:"******"\nPassword: "******"\n\nClick on the link to confirm. \n\n" . $link; $mail->WordWrap = 50; if (!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } } }
/** * send an email * * @access public * @static static method * @param string $type Email constant - check config.php * @param string $email * @param array $userData * @param array $data any associated data with the email * @throws Exception If failed to send the email */ public static function sendEmail($type, $email, $userData, $data) { $mail = new PHPMailer(); $mail->IsSMTP(); //good for debugging, otherwise keep it commented //$mail->SMTPDebug = EMAIL_SMTP_DEBUG; $mail->SMTPAuth = EMAIL_SMTP_AUTH; $mail->SMTPSecure = EMAIL_SMTP_SECURE; $mail->Host = EMAIL_SMTP_HOST; $mail->Port = EMAIL_SMTP_PORT; $mail->Username = EMAIL_SMTP_USERNAME; $mail->Password = EMAIL_SMTP_PASSWORD; $mail->SetFrom(EMAIL_FROM, EMAIL_FROM_NAME); $mail->AddReplyTo(EMAIL_REPLY_TO); switch ($type) { case EMAIL_EMAIL_VERIFICATION: $mail->Body = self::getEmailVerificationBody($userData, $data); $mail->Subject = EMAIL_EMAIL_VERIFICATION_SUBJECT; $mail->AddAddress($email); break; case EMAIL_PASSWORD_RESET: $mail->Body = self::getPasswordResetBody($userData, $data); $mail->Subject = EMAIL_PASSWORD_RESET_SUBJECT; $mail->AddAddress($email); break; case EMAIL_REPORT_BUG: $mail->Body = self::getReportBugBody($userData, $data); $mail->Subject = "[" . ucfirst($data["label"]) . "] " . EMAIL_REPORT_BUG_SUBJECT . " | " . $data["subject"]; $mail->AddAddress($email); break; } if (!$mail->Send()) { throw new Exception("Email couldn't be sent to " . $userData["id"] . " for type: " . $type); } }
function correo($email_remitente,$nombre_remitente,$email_destino,$nombre_destino,$asunto,$mensaje,$copia1,$copia2,$copia3){ require_once("class.phpmailer.php"); $mail = new PHPMailer(); $mail->From = $email_remitente; $mail->FromName = $nombre_remitente; $mail->AddAddress($email_destino, $nombre_destino); if($copia1!=""){ $mail->AddAddress($copia1); } if($copia2!=""){ $mail->AddAddress($copia2); } if($copia3!=""){ $mail->AddAddress($copia3); } $mail->WordWrap = 50; // set word wrap to 50 characters $mail->IsHTML(true); // set email format to HTML $mail->Subject = $asunto; $mail->Body = $mensaje; if(!$mail->Send()){ echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } /*echo "Message has been sent<br>";*/ }
function envia_email($messageText, $subject, $emailFrom, $nameFrom) { require 'resources/lib/phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); $mail->isSMTP(); // Define que a mensagem será SMTP $mail->Host = "smtp.gmail.com"; // Endereço do servidor SMTP $mail->SMTPAuth = true; // Autenticação $mail->Username = '******'; // Usuário do servidor SMTP $mail->Password = '******'; // Senha da caixa postal utilizada $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->From = $emailFrom; $mail->FromName = $nameFrom; $mail->AddAddress('*****@*****.**', "Noivos Tchutchucos"); $mail->AddAddress('*****@*****.**', "Noivo Sexy"); $mail->AddReplyTo($emailFrom, $nameFrom); $mail->isHTML(true); // Define que o e-mail será enviado como HTML $mail->CharSet = 'iso-8859-1'; // Charset da mensagem (opcional) $mail->Subject = $subject; // Assunto da mensagem $mail->Body = $messageText; return $mail->Send(); }
function enviarEmail($razon, $body, $proyecto, $whoSend = 0) { $con = mysqli_connect(DBhost, DBuser, DBpassword, DATABASE); $result = mysqli_query($con, "select * from proyecto_alumno_profesor where IDProyecto={$proyecto}"); $IDS = mysqli_fetch_array($result); $idAlumno = $IDS['IDAlumno']; $idProfesor = $IDS['IDProfesor']; $result2 = mysqli_query($con, "select * from profesores where IDProfesor={$idProfesor}"); $result3 = mysqli_query($con, "select * from alumnos where IDAlumno={$idAlumno}"); $result4 = mysqli_query($con, "select * from proyectos where IDProyecto={$proyecto}"); $alumnos = mysqli_fetch_array($result3); $profesores = mysqli_fetch_array($result2); $proyectos = mysqli_fetch_array($result4); $correoAlumno = $alumnos['Email']; $nombreAlumno = $alumnos['Nombre']; $correoProfesor = $profesores['Email']; $nombreProfesor = $profesores['Nombre']; $nombreProyecto = $proyectos['Descripcion']; $razonCompleta = $nombreProyecto . ": " . $razon; $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->IsSMTP(); // Usar SMTP para enviar $mail->SMTPDebug = 0; // habilita información de depuración SMTP (para pruebas) // 1 = errores y mensajes // 2 = sólo mensajes $mail->SMTPAuth = true; // habilitar autenticación SMTP $mail->Host = HOST; // establece el servidor SMTP $mail->Port = PORT; // configura el puerto SMTP utilizado $mail->Username = USER; // nombre de usuario UGR $mail->Password = PASSWORD; // contraseña del usuario UGR $mail->SetFrom(ENVIARDESDE, NOMBREDESDE); $mail->Subject = "{$razonCompleta}"; $mail->MsgHTML($body); // Fija el cuerpo del mensaje if ($whoSend == 0) { //envia el profesor al alumno $address = $correoAlumno; // Dirección del destinatario $mail->AddAddress($address, $nombreAlumno); } else { //envia alumno al tutor $address = $correoProfesor; // Dirección del destinatario $mail->AddAddress($address, $nombreProfesor); } $mail->Send(); //$mail->AddBCC("*****@*****.**","Soporte formación"); mysqli_close($con); //echo "$correoAlumno"; }
function Send() { $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->Host = $this->smtp['smtp_server']; $mail->Port = $this->smtp['smtp_port']; if ($this->smtp['smtp_enable']) { $mail->IsSMTP(); $mail->Username = $this->smtp['smtp_usr']; $mail->Password = $this->smtp['smtp_psw']; $mail->SMTPAuth = $this->smtp['smtp_auth'] ? true : false; } if ($this->smtp['smtp_from_email']) { $mail->SetFrom($this->smtp['smtp_from_email'], $this->smtp['smtp_from_name']); } else { $mail->SetFrom($this->smtp['smtp_server'], $this->smtp['smtp_usr']); } if (is_array($this->to)) { foreach ($this->to as $key => $val) { $name = is_numeric($key) ? "" : $key; $mail->AddAddress($val, $name); } } else { $mail->AddAddress($this->to, $this->to_name); } if (!empty($this->smtp['smtp_reply_email'])) { $mail->AddReplyTo($this->smtp['smtp_reply_email'], $this->smtp['smtp_reply_name']); } if ($this->cc) { if (is_array($this->cc)) { foreach ($this->cc as $keyc => $valcc) { $name = is_numeric($keyc) ? "" : $keyc; $mail->AddCC($valcc, $name); } } else { $mail->AddCC($this->cc, $this->cc_name); } } if ($this->attach) { if (is_array($this->attach)) { foreach ($this->attach as $key => $val) { $mail->AddAttachment($val); } } else { $mail->AddAttachment($this->attach); } } // $mail->SMTPSecure = 'ssl'; $mail->SMTPSecure = "tls"; $mail->WordWrap = 50; $mail->IsHTML($this->is_html); $mail->Subject = $this->subject; $mail->Body = $this->body; $mail->AltBody = ""; // return $mail->Body; return $mail->Send(); }
/** * * SendEmail.php * * @package core * @author John.meng <*****@*****.**> * @author 孟远螓 * @author QQ:3440895 * @version CVS: $Id: SendEmail.php,v 1.2 2006/10/25 23:49:52 arzen Exp $ */ function sendEmail($recipients, $from, $from_name, $reply, $subject, $text, $html_body, $attach = "") { global $SMTP_Host, $SMTP_UserName, $SMTP_PassWord, $SMTP_Auth, $i18n; require_once "phpmailer/class.phpmailer.php"; $charset = $i18n->getCharset(); $html = <<<EOD <html><head> <meta http-equiv="Content-Type" content="text/html; charset={$charset}"></head> <body>\t\t {$html_body} </body> </html> EOD; $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Host = $SMTP_Host; // specify main and backup server $mail->SMTPAuth = $SMTP_Auth; // turn on SMTP authentication $mail->Username = $SMTP_UserName; // SMTP username $mail->Password = $SMTP_PassWord; // SMTP password $mail->CharSet = $charset; $mail->Encoding = "base64"; $mail->From = $from; $mail->FromName = $from_name ? $from_name : $from; if (is_array($recipients)) { foreach ($recipients as $key => $value) { $mail->AddAddress($value); } } else { $mail->AddAddress($recipients); } $mail->AddReplyTo($reply ? $reply : $from); $mail->WordWrap = 50; // set word wrap to 50 characters // $mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments // $mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name $mail->IsHTML(true); // set email format to HTML $mail->Subject = $subject; $mail->Body = $html; $mail->AltBody = $text; $data = array(); if (!$mail->Send()) { $data['flag'] = true; $data['msg'] = $i18n->_("Message could not be sent.") . $mail->ErrorInfo; return $data; exit; } $data['flag'] = true; $data['msg'] = $i18n->_("Message has been sent"); return $data; }
function sendMailAlert() { $mail = new PHPMailer(); $mail->AddAddress(EMAIL_LOG_TO); $mail->AddAddress(EMAIL_LOG_TO_2); $mail->From = EMAIL_LOG_FROM; $mail->FromName = EMAIL_LOG_SUBJECT; $mail->Subject = EMAIL_LOG_SUBJECT; $mail->Body = "Caro Amministratore,\r\nil processo di esportazione dati da VisionERP è già partito ed è ancora in esecuzione. Aspettare la mail di fine processo prima di rilanciarlo.\r\n\r\n"; $mail->Send(); }
function sendmails($config, $address, $body, $altbody = '请使用兼容HTML格式邮箱') { $mail = new PHPMailer(); $mail->IsSMTP(); //设置PHPMailer应用SMTP发送Email //$mail->CharSet = 'UTF-8'; $mail->CharSet = $config['mail']['charset']; //$mail->Host = 'smtp.126.com'; // 指定邮件服务器 $mail->Host = $config['mail']['host']; // 指定邮件服务器 //$mail->Port = 25; //指定邮件服务器端口 $mail->Port = $config['mail']['port']; //指定邮件服务器端口 $mail->SMTPAuth = true; // 开启 SMTP验证 //设置SMTP用户名和密码 //$mail->Username = '******'; $mail->Username = $config['mail']['username']; //$mail->Password = '******'; $mail->Password = $config['mail']['password']; //$mail->From = '*****@*****.**'; //指定发送邮件地址 $mail->From = $config['mail']['fromaddress']; //指定发送邮件地址 //$mail->FromName = '想学网测试服务器'; //为发送邮件地址命名 $mail->FromName = $config['mail']['fromname']; //为发送邮件地址命名 //这里为批量发送邮件 if (is_array($address)) { foreach ($address as $val) { $mail->AddAddress($val); } } else { $mail->AddAddress($address); } $mail->AddReplyTo('*****@*****.**', '大众影评网'); $mail->WordWrap = 50; // 设置自动换行的字符长度为 50 $mail->IsHTML(true); // 设置Email格式为HTML $mail->Subject = $config['mail']['subject']; $mail->Body = $body; $mail->AltBody = $altbody; //当收件人客户端不支持接收HTML格式email时的可替代内容; //发送邮件。 if (!$mail->Send()) { $mail->ErrorInfo; return false; //throw_exception("Mailer Error: " . $mail->ErrorInfo);提示邮箱发送不成功的错误信息 } else { return true; } }
/** * 发送邮件 * @param string $sendto_email 收件人的Email * @param string $subject 主题 * @param string $body 正文 * @param array $senderInfo 发件人信息 array('email_sender_name'=>'发件人姓名', 'email_account'=>'发件人Email地址') * @return boolean 是否发送邮件成功 */ public function send_email($sendto_email, $subject, $body, $senderInfo = '') { $mail = new PHPMailer(); if (empty($senderInfo)) { $sender_name = $this->option['email_sender_name']; $sender_email = empty($this->option['email_sender_email']) ? $this->option['email_account'] : $this->option['email_sender_email']; } else { $sender_name = $senderInfo['email_sender_name']; $sender_email = $senderInfo['email_sender_email']; } if ($this->option['email_sendtype'] == 'smtp') { $mail->Mailer = "smtp"; $mail->Host = $this->option['email_host']; // sets GMAIL as the SMTP server $mail->Port = $this->option['email_port']; // set the SMTP port if ($this->option['email_ssl']) { $mail->SMTPSecure = "ssl"; // sets the prefix to the servier tls,ssl } $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = $this->option['email_account']; // SMTP username $mail->Password = $this->option['email_password']; // SMTP password } $mail->Sender = $this->option['email_account']; // 真正的发件邮箱 $mail->SetFrom($sender_email, $sender_name, 0); // 设置发件人信息 $mail->CharSet = "UTF-8"; // 这里指定字符集! $mail->Encoding = "base64"; if (is_array($sendto_email)) { foreach ($sendto_email as $v) { $mail->AddAddress($v); } } else { $mail->AddAddress($sendto_email); } //以HTML方式发送 $mail->IsHTML(true); // send as HTML $mail->Subject = $subject; // 邮件主题 $mail->Body = $body; // 邮件内容 $mail->AltBody = "text/html"; $mail->SMTPDebug = false; return $mail->Send(); }
function SendMail($data) { require_once "PHPMailer/PHPMailerAutoload.php"; //載入PHPMailer類別 $mail = new PHPMailer(); $mail->IsSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; $mail->SMTPAuth = true; //使用Gmail的SMTP需要驗證,所以這裡要設true $mail->SMTPSecure = "ssl"; $mail->Debugoutput = 'html'; //Gmail的SMTP是使用465port $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->Username = '******'; //帳號 $mail->Password = '******'; //密碼 $mail->From = '*****@*****.**'; //寄件者 $mail->FromName = 'GoTutor'; //寄件者姓名 if (is_array($data['list'])) { foreach ($data['list'] as $email) { $mail->AddAddress($email); } } else { $mail->AddAddress($data['list']); } /* $mail->AddAttachment($_FILES['file2']['tmp_name'], $_FILES['file2']['name']); */ $mail->CharSet = "utf-8"; $mail->Subject = $data['subject']; //主旨 $mail->Body = $data['body']; //內文 $mail->AltBody = "Your browser does not support HTML"; //send the message, check for errors if (!$mail->send()) { return $data = array('send' => 0, 'info' => $mail->ErrorInfo); } else { return $data = array('send' => 1, 'info' => $mail->ErrorInfo); } }
public function index() { if (IS_POST) { $info = I('post.info'); $info['MAIL_AUTH'] = true; C($info); //发送邮件 $title = '这是一封测试邮件'; $message = '这是一封测试邮件, 无需回复'; $address = $info['MAIL_TO_ADDRESS']; $fromname = '一起PHP'; import('Org.Util.Mail'); $mail = new \PHPMailer(true); try { $mail->IsSMTP(); $mail->CharSet = 'UTF-8'; if (is_array($address)) { foreach ($address as $v) { $mail->AddAddress($v); } } else { $mail->AddAddress($address); } $mail->Body = $message; $mail->From = C('MAIL_ADDRESS'); $mail->FromName = $fromname; $mail->Subject = $title; $mail->Host = C('MAIL_SMTP'); $mail->SMTPAuth = C('MAIL_AUTH'); $mail->Port = C('MAIL_PORT'); $mail->SMTPSecure = C('MAIL_SECURE'); $mail->Username = C('MAIL_LOGINNAME'); $mail->Password = C('MAIL_PASSWORD'); $mail->IsHTML(true); $mail->MsgHTML($message); $result = $mail->Send(); if ($result) { $this->ajaxReturn(array('statusCode' => 200, 'message' => '发送成功')); } } catch (\phpmailerException $e) { $this->ajaxReturn(array('statusCode' => 300, 'message' => $e->errorMessage())); } catch (\Exception $e) { $this->ajaxReturn(array('statusCode' => 300, 'message' => $e->getMessage())); } } else { $this->display(); } }
function sendmails($address, $subject, $body, $altbody = '请使用兼容HTML格式邮箱') { //require_once "./PHPMailer-master/class.phpmailer.php"; require_once "./PHPMailer-master/PHPMailerAutoload.php"; //require './class.phpmailer.php'; $mail = new PHPMailer(); $mail->IsSMTP(); //设置PHPMailer应用SMTP发送Email $mail->CharSet = 'UTF-8'; $mail->Host = 'smtp.126.com'; // 指定邮件服务器 $mail->Port = 25; //指定邮件服务器端口 $mail->SMTPAuth = true; // 开启 SMTP验证 //设置SMTP用户名和密码 $mail->Username = '******'; $mail->Password = '******'; $mail->From = '*****@*****.**'; //指定发送邮件地址 $mail->FromName = '想学网测试服务器'; //为发送邮件地址命名 //这里为批量发送邮件 if (is_array($address)) { foreach ($address as $val) { $mail->AddAddress($val); } } else { $mail->AddAddress($address); } $mail->AddReplyTo('*****@*****.**', '大众影评网'); $mail->WordWrap = 50; // 设置自动换行的字符长度为 50 $mail->IsHTML(true); // 设置Email格式为HTML $mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = $altbody; //当收件人客户端不支持接收HTML格式email时的可替代内容; //发送邮件。 if (!$mail->Send()) { $mail->ErrorInfo; return false; //throw_exception("Mailer Error: " . $mail->ErrorInfo);提示邮箱发送不成功的错误信息 } else { return true; } }
function smtpmailer($para, $de, $de_nome, $assunto, $corpo) { global $error; $mail = new PHPMailer(); $mail->IsSMTP(); // Ativar SMTP $mail->SMTPDebug = 0; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas $mail->SMTPAuth = true; // Autenticação ativada $mail->SMTPSecure = 'ssl'; // SSL REQUERIDO pelo GMail $mail->Host = 'smtp.gmail.com'; // SMTP utilizado $mail->Port = 465; // A porta 465 deverá estar aberta em seu servidor $mail->Username = GUSER; $mail->Password = GPWD; $mail->SetFrom($de, $de_nome); $mail->Subject = $assunto; $mail->Body = $corpo; $mail->AddAddress($para); if (!$mail->Send()) { $error = 'Mail error: ' . $mail->ErrorInfo; return false; } else { ?> <script> alert("Cadastro realizado com sucesso acesse seu email e ative o usuário!"); window.location = 'index.php'; </script> <?php return true; } }
function smtpmailer($para, $de, $de_nome, $assunto, $corpo) { global $error; $mail = new PHPMailer(); $mail->IsSMTP(); // Ativar SMTP $mail->SMTPDebug = 0; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas $mail->SMTPAuth = true; // Autenticação ativada $mail->SMTPSecure = 'tls'; // SSL REQUERIDO pelo GMail $mail->Host = 'smtp.live.com'; // SMTP utilizado $mail->Port = 587; // A porta 587 deverá estar aberta em seu servidor $mail->Username = GUSER; $mail->Password = GPWD; $mail->SetFrom($de, $de_nome); $mail->Subject = $assunto; $mail->Body = $corpo; $mail->AddAddress($para); if (!$mail->Send()) { $error = 'Mail error: ' . $mail->ErrorInfo; return false; } else { $error = 'Mensagem enviada!'; return true; } }
public function try_to_send_notification() { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "your.host.com"; $mail->Port = 25; $mail->SMTPAuth = false; $mail->Username = "******"; $mail->Password = "******"; $mail->FromName = "Photo Gallery"; $mail->From = ""; $mail->AddAddress("", "Photo Gallery Admin"); $mail->Subject = "New Photo Gallery Comment"; $created = datetime_to_text($this->created); $mail->Body = <<<EMAILBODY A new comment has been received in the Photo Gallery. At {$created}, {$this->author} wrote: {$this->body} EMAILBODY; $result = $mail->Send(); return $result; }
function smtpmailer($to, $from, $from_name, $subject, $avatar, $user, $link) { global $error; $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 465; $mail->Username = GUSER; $mail->Password = GPWD; $mail->IsHTML(true); $mail->SetFrom($from, $from_name); $mail->Subject = $subject; $mail->AddEmbeddedImage('background1.jpg', 'background1img'); $name = explode($avatar, '.'); $mail->AddEmbeddedImage('templates/avatars/' . $avatar, 'avatarimg'); $mail->Body = "<div style='width:100%;background-color:rgb(77, 16, 1);height:500px;font-size:20px;color:#fff'>\n\t\t<font face='century Gothic,sans-serif'>\n\t\t<img src='cid:background1img' style='z-index:-2;text-align:center;margin-left:195px;width:300px;'>\n\t\t\n\t\t<div style='margin-left:0px;margin-top:30px;text-align:center;'><img src='cid:avatarimg' style='width:100px;height:100px;padding:1px;border:3px solid #ddd;margin-top:5px;margin-left:-5px;' /><div style='margin-top:5px;margin-left:-5px;'>Hello " . $user . "</div>\n\t\t\t<p style='text-align:justify;max-width:500px;margin-left:120px;'>\"Campus Connect\" is an initiative by a group of student enthusiasts, aiming to solve some of the issues faced by BITSians.\"BITS QUORA\" is one of the many projects covered under this initiative. </p>\n\t\t\n\t\t<div style='text-align:center'><br>\n\t\t<p style='text-align:center'><a href='http://BITSQ/register.php?token=" . $link . "&mail=" . $to . "' style='margin-top:18px;color:#fff;text-decoration:none;cursor:pointer;background:green;padding:6px;border:2 px solid darkgreen;border-radius:2px'>Click here to confirm your mail.</a></p> </div>\n\t\t</div>\n\t\t<div style='color:#fff;font-size:18px;position:absolute;bottom:0px;margin-left:100px;'>\n\t\tRegards<br>\n\t\tAkhil Reddy<br>\n\t\tH-Rep VK-BHAWAN<br>\n\t\t7728835792<br><br>\n\t\t</div>\t\t\n\t\t</div>\n\t\t</font></div>"; $mail->AddAddress($to); if (!$mail->Send()) { $error = 'Mail error: ' . $mail->ErrorInfo; return false; } else { $error = 'Confirmation Mail sent to the the provided mail!'; return true; } }
function email($contas) { global $CONFIG_smtp_server, $CONFIG_smtp_port, $CONFIG_smtp_username, $CONFIG_smtp_password, $CONFIG_smtp_mail, $CONFIG_name; $mensagem = "----------------------------\n"; for ($i = 0; isset($contas[$i][0]); $i++) { $mensagem .= "Username: "******"\nPassword: "******"\n----------------------------\n"; } $maildef = read_maildef("recover_password"); $maildef = str_ireplace("#account_info#", $mensagem, $maildef); $maildef = str_ireplace("#server_name#", $CONFIG_name, $maildef); $maildef = str_ireplace("#support_mail#", $CONFIG_smtp_mail, $maildef); $maildef = nl2br($maildef); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; $mail->Host = $CONFIG_smtp_server; $mail->Port = $CONFIG_smtp_port; $mail->Username = $CONFIG_smtp_username; $mail->Password = $CONFIG_smtp_password; $mail->From = $CONFIG_smtp_mail; $mail->FromName = $CONFIG_name; $mail->Subject = "Password Recovery"; $mail->Body = $maildef; $mail->WordWrap = 50; $mail->AddAddress($contas[0][2], $contas[0][2]); $mail->AddReplyTo($CONFIG_smtp_mail, $CONFIG_name); $mail->IsHTML(true); if (!$mail->Send()) { return $mail->ErrorInfo; } else { return "Message has been sent"; } }
function Send_Mail($to, $subject, $body) { require './class.phpmailer.php'; $from = "*****@*****.**"; $mail = new PHPMailer(); $mail->IsSMTP(true); // SMTP $mail->SMTPAuth = true; // SMTP authentication $mail->Mailer = "smtp"; $mail->Host = "mail.privateemail.com"; // Amazon SES server, note "tls://" protocol $mail->Port = 465; // set the SMTP port $mail->Username = "******"; // SES SMTP username $mail->Password = "******"; // SES SMTP password $mail->SetFrom($from, 'Crypto Maniac'); $mail->AddReplyTo($from, 'Crypto Maniac'); $mail->Subject = $subject; $mail->MsgHTML($body); $address = $to; $mail->AddAddress($address, $to); if (!$mail->Send()) { return false; } else { return true; } }
/** * */ function sendMail($to, $title, $content) { Vendor('PHPMailer.PHPMailerAutoload'); $mail = new PHPMailer(); //实例化 $mail->IsSMTP(); // 启用SMTP $mail->Host = C('MAIL_HOST'); //smtp服务器的名称(这里以QQ邮箱为例) $mail->SMTPAuth = C('MAIL_SMTPAUTH'); //启用smtp认证 $mail->Username = C('MAIL_USERNAME'); //你的邮箱名 $mail->Password = C('MAIL_PASSWORD'); //邮箱密码 $mail->From = C('MAIL_FROM'); //发件人地址(也就是你的邮箱地址) $mail->FromName = C('MAIL_FROMNAME'); //发件人姓名 $mail->AddAddress($to, "尊敬的客户"); $mail->WordWrap = 50; //设置每行字符长度 $mail->IsHTML(C('MAIL_ISHTML')); // 是否HTML格式邮件 $mail->CharSet = C('MAIL_CHARSET'); //设置邮件编码 $mail->Subject = $title; //邮件主题 $mail->Body = $content; //邮件内容 $mail->AltBody = "这是一个纯文本的身体在非营利的HTML电子邮件客户端"; //邮件正文不支持HTML的备用显示 return $mail->Send(); }
static function send_mail() { $mailer = new PHPMailer(); $mailer->IsSMTP(); $mailer->Host = 'ssl://smtp.gmail.com:465'; $mailer->SMTPAuth = TRUE; $mailer->Username = '******'; // Change this to your gmail adress $mailer->Password = '******'; // Change this to your gmail password $mailer->From = 'fake[ @ ] googlemail.com'; // This HAVE TO be your gmail adress $mailer->FromName = 'fake'; // This is the from name in the email, you can put anything you like here $mailer->Body = 'This is the main body of the email'; $mailer->Subject = 'This is the subject of the email'; $mailer->AddAddress('fake2[ @ ] gmail.com'); // This is where you put the email adress of the person you want to mail if (!$mailer->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mailer->ErrorInfo; } else { echo "Message has been sent"; } }