Automatically inlines images and creates a plain-text version by converting the HTML,
overwriting any existing values in Body and AltBody.
$basedir is used when handling relative image paths, e.g.
will look for an image file in $basedir/images/a.png and convert it to inline.
If you don't want to apply these transformations to your HTML, just set Body and AltBody yourself.
![](https://cdn-0.hotexamples.com/it/examples/-/PHPMailer/msgHTML/images/a.png)
public msgHTML ( string $message, string $basedir = '', boolean | callable $advanced = false ) : string | ||
$message | string | HTML message string |
$basedir | string | base directory for relative paths to images |
$advanced | boolean | callable | Whether to use the internal HTML to text converter or your own custom converter @see PHPMailer::html2text() |
return | string | $message The transformed message Body |
/** * Send email * @param array $to * @param array $from * @param string $subject * @param string $text * @param bool $use_template * @return bool */ public function send($to, $from, $subject, $text, $use_template = true) { $this->client->setFrom($from[1], $from[0]); $this->client->addAddress($to[1], $to[0]); $this->client->Subject = $subject; if ($use_template) { $template = ' <!DOCTYPE HTML> <html dir="rtl"> <head> <meta charset="utf-8"> </head> <body style="font-family: tahoma, sans-serif !important;"> <div style="font: 13px tahoma,sans-serif !important;direction: rtl;background-color: #e8e8e8;"> <div style="width: 70%;background-color: #fff;background-color: #fff; border-radius: 3px;margin: auto;position: relative;border-left: 1px solid #d9d9d9;border-right: 1px solid #d9d9d9;"> <div style="top: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div> <div style="padding: 22px 15px;"> {TEXT} </div> <div style="bottom: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div> </div> </div> </body> </html> '; $msg = str_replace('{TEXT}', $text, $template); } else { $msg = $text; } $this->client->msgHTML($msg); return $this->client->send(); }
/** * Informa o conteúdo da mensagem * @param type $assunto * @param type $mensagem */ public function setContent($assunto = null, $mensagem = null) { if (!empty($assunto)) { $this->SMTP->Subject = $assunto; } $this->SMTP->Body = "<!doctype html><html><head><title>{$assunto}</title><meta charset='UTF-8' /></head><body>{$mensagem}</body></html>"; $this->SMTP->msgHTML($mensagem); }
/** * Set the message body * * Multiple bodies with different types can be added by calling this method * multiple times. Every email is required to have a "plain" message body. * * @param string $body New message body * @param string $type Mime type: text/html, text/plain [Optional] * @return Email */ public function message($body, $type = NULL) { if (!$type or $type === 'text/plain') { // Set the main text/plain body $this->_mail->Body = $body; } else { // Add a custom mime type $this->_mail->msgHTML($body); } return $this; }
public function enviarCorreoPosiciones($nombre, $correo) { include 'conexion.php'; $stmt = $pdo->prepare("SELECT id_usuario from usuarios where nombre = '{$nombre}' and correo = '{$correo}'"); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); $cont = "SELECT id_usuario,longitud,latitud,tiempo FROM posiciones where id_usuario= " . $user['id_usuario']; $stmt2 = $pdo->prepare($cont); $stmt2->execute(); $correoAenviar = "<table border='1'><tr><th>ID_Usuario</th><th>Longitud</th><th>Latitud</th><th>Tiempo</th></tr>"; foreach ($stmt2->fetchAll(PDO::FETCH_ASSOC) as $row) { $correoAenviar .= "<tr><td>" . $row['id_usuario'] . "</td><td>" . $row['longitud'] . "</td><td>" . $row['latitud'] . "</td><td>" . $row['tiempo'] . "</td></tr>"; } $correoAenviar .= "</table>"; $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPAuth = true; //$mail->SMTPSecure = "ssl"; $mail->Host = "smtp.live.com"; $mail->Port = 587; $mail->Username = ""; $mail->Password = ""; $mail->From = ""; $mail->FromName = ""; $mail->Subject = "Posiciones App Tracking"; $mail->AltBody = "Mensaje de prueba"; $mail->msgHTML($correoAenviar); $mail->addAddress($correo, $nombre); $mail->isHTML(true); if (!$mail->send()) { echo "Error: " . $mail->ErrorInfo; } }
function EnviaCorreos_Chat($Usuario, $mailCliente, $strReclamacion, $strComentario) { require '../general/phpmailer/PHPMailerAutoload.php'; $from = '*****@*****.**'; $mail = new PHPMailer(); //Correo desde donde se envía (from) $mail->setFrom($from, ''); //Correo de envío (to) $mail->addAddress($mailCliente, ''); $mail->CharSet = "UTF-8"; $mail->Subject = 'Sistema de Calidad. Envío de claves'; $strHTML = '<table width="440" border="0" height="22" class="txtgeneral">'; $strHTML = $strHTML . "<tr><td>Ese correo a sido enviado por el usuario: {$Usuario}</td></tr>"; $strHTML = $strHTML . "<tr><td>Es un comentario de la reclamacion: {$strReclamacion}</td></tr>"; $strHTML = $strHTML . "<tr><td>Con fecha de: " . date('d/m/Y') . "</td></tr>"; $strHTML = $strHTML . "<tr><td></td></tr>"; $strHTML = $strHTML . "<tr><td></td></tr>"; $strHTML = $strHTML . "<tr><td>{$strComentario}</td></tr>"; $strHTML = $strHTML . '</td></tr>'; $strHTML = $strHTML . '<tr><td>Departamento de Calidad</td></tr>'; $strHTML = $strHTML . '<tr><td><center><IMG SRC="http://www.qualidad.info/qualidad/images/logo-' . $_SESSION['base'] . '.jpg" width="132" height="67" BORDER="0"></center>'; $strHTML = $strHTML . '</td></tr>'; $strHTML = $strHTML . '</TABLE>'; $strHTML = '<HTML><BODY><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""-1"">' . $strHTML . '</font></BODY></HTML>'; $mail->msgHTML($strHTML); $mail->send(); }
public function SendEmail($account, $type) { $email = new \PHPMailer(); $email->isSMTP(); // $email->Timeout = 120; //$email->SMTPDebug = 2; //$email->Debugoutput = 'html'; $email->Host = "smtp.gmail.com"; $email->Port = 587; $email->SMTPSecure = "tls"; $email->SMTPAuth = true; $email->Username = "******"; $email->Password = "******"; $email->setFrom("*****@*****.**", "Retos"); $email->addReplyTo("*****@*****.**", "Retos"); $email->addAddress("{$account}"); $email->isHTML(true); $email->Subject = "Retos | Chontal Developers"; $file = dirname(__DIR__) . "/views/email/index.html"; $email->msgHTML(file_get_contents($file)); if ($type == 1) { $email->AltBody = "Gracias por contactarnos en breve nos comunicaremos con usted. Les agradece El equipo Retos."; } else { if ($type == 2) { $email->AltBody = "Gracias por suscribirse a nuestro sito http://www.retos.co"; } } if (!$email->send()) { //echo 'Message could not be sent.'; //echo 'Mailer Error: ' . $email->ErrorInfo; } else { return true; } }
public function success($type, $id, $transactionid, $a = "search") { DB::table($type . "_transaction")->where("id", $transactionid)->update(array("status" => 1)); DB::table("overall_transaction")->where("related_transaction_id", $transactionid)->update(array("status" => 1)); $transaction = DB::table($type . "_transaction")->where("id", $transactionid)->first(); $owner = DB::table('users')->join($type, $type . '.user_id', '=', 'users.id')->select('users.email')->first(); $mail = new PHPMailer(); $mail->setFrom(Config::get("app.support_email")); $mail->addAddress($owner->email); $body = "<style>\n\t\t\t\t\t* {\n\t\t\t\t\t\tfont-family: Arial;\n\t\t\t\t\t}\n\t\t\t\t\ttable {\n\t\t\t\t\t\tfont-size: 12px;\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t\t<h4>You have a new donation from " . $transaction->name . ".</h4>\n\t\t\t\t<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Name: </td>\n\t\t\t\t\t\t<td>" . $transaction->name . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Email: </td>\n\t\t\t\t\t\t<td>" . $transaction->email . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Amount: </td>\n\t\t\t\t\t\t<td>" . $transaction->amount . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top'>Transaction : </td>\n\t\t\t\t\t\t<td><a href='" . Config::get("app.url") . "projects/" . $type . "/" . $id . "/transactions'>Click to go.</a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>"; $mail->Subject = "Christian Response: You have a new donation."; $mail->msgHTML($body); $mail->AltBody = $body; $mail->send(); if (Auth::check()) { //return View::make("/frontend/" . $this -> _permission[Auth::user() -> permission] . "/donation/success") -> with(array("active" => "", "redirect_url" => "/dashboard/project/view/" . $type . "/" . $id, "type" => "Project")); $error = "<div class='alert alert-success alert-dismissable'>\n <button aria-hidden='true' data-dismiss='alert' class='close' type='button'>×</button>\n Thank you for your support in this project.\n </div>"; Session::set("error", $error); if ($a == "search") { return Redirect::to("/search/project/" . $type . "/view/" . $id); } elseif ($a == "dashboard") { return Redirect::to("/dashboard/project/view/" . $type . "/" . $id); } } else { Session::set("error", $this->responsebox("Thank you for your support!.", "success")); return Redirect::to("/project/view/" . strtolower($type) . "/" . $id); } }
/** * Sends the message * @param string $email * @param string $subject * @param string $message with html markup * @return bool * @throws Exception * @throws phpmailerException */ function sendMail($email, $subject, $message) { //create a new PHPMailer instance $mail = new PHPMailer(); //tell PHPMailer to use SMTP $mail->isSMTP(); //enable debugging... $mail->SMTPDebug = 0; //ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //set the hostname of the server $mail->Host = 'smtp.gmail.com'; //set SMTP port number $mail->Port = 587; //set encryption $mail->SMTPSecure = 'tls'; //use SMTP authentication $mail->SMTPAuth = true; //Username $mail->Username = '******'; //Password $mail->Password = '******'; //Set FROM field $mail->setFrom('*****@*****.**', 'Jerry Krusinski'); //Set TO field $mail->addAddress($email); //Set the SUBJECT $mail->Subject = $subject; //Set Message $mail->msgHTML($message); //Send Message, Check for errors return $mail->send(); }
/** * Функция отправки сообщения: * * @param string $from - адрес отправителя * @param string $from_name - имя отправителя * @param string|array $to - адрес(-а) получателя * @param string $theme - тема письма * @param string $body - тело письма * @param bool $isText - является ли тело письма текстом * * @return bool отправилось ли письмо **/ public function send($from, $from_name, $to, $theme, $body, $isText = false) { $this->_mailer->clearAllRecipients(); $this->setFrom($from, $from_name); if (is_array($to)) { foreach ($to as $email) { $this->addAddress($email); } } else { $this->addAddress($to); } $this->setSubject($theme); if ($isText) { $this->_mailer->Body = $body; $this->_mailer->isHTML(false); } else { $this->_mailer->msgHTML($body, \Yii::app()->basePath); } try { return $this->_mailer->send(); } catch (\Exception $e) { \Yii::log($e->__toString(), \CLogger::LEVEL_ERROR, 'mail'); return false; } }
function send_mail($Host, $Port, $Secure, $Auth, $TitleMail, $Username, $Password, $ToName, $ToEmail, $Charset, $Subject, $Body) { $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = $Host; $mail->Port = $Port; $mail->SMTPSecure = $Secure; $mail->SMTPAuth = $Auth; $mail->Username = $Username; $mail->Password = $Password; $mail->setFrom($Username, $TitleMail); $mail->addReplyTo($ToEmail, $ToName); $mail->addAddress($Username, ""); $mail->CharSet = $Charset; $mail->Subject = $Subject; $body = mb_convert_encoding($Body, mb_detect_encoding($Body), 'UTF-8'); $mail->msgHTML($body); $mail->AltBody = 'This is a plain-text message body'; if (!$mail->send()) { $result = "Mailer Error: " . $mail->ErrorInfo . ' ' . $mymail; } else { $result = true; } return $result; }
function sendWelcomeEmail($email) { $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->Debugoutput = 'html'; $mail->Host = "sub5.mail.dreamhost.com"; // specify main and backup server $mail->Port = 587; $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $mail->setFrom("*****@*****.**", "Roscr Admin"); $mail->AddAddress($email); $mail->IsHTML(true); // set email format to HTML $mail->msgHTML(file_get_contents('welcome.html'), dirname(__FILE__)); $mail->AltBody = $emailText; $mail->Subject = "Subscription to ROSCr"; $mail->WordWrap = 50; // set word wrap to 50 characters if (!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; }
public function onLoad($param) { parent::onLoad($param); $checkNewsletter = nNewsletterRecord::finder()->findByStatus(1); if ($checkNewsletter) { $layout = nLayoutRecord::finder()->findBy_nNewsletterID($checkNewsletter->ID); $mail = new PHPMailer(); $mail->isSendmail(); $mail->setFrom('*****@*****.**', 'First Last'); $mail->addReplyTo('*****@*****.**'); $lista = nSenderRecord::finder()->findAll('nLayoutID = ? AND Status = 0 LIMIT 25', $layout->ID); foreach ($lista as $person) { $mail->addAddress($person->Email); $mail->Subject = $checkNewsletter->Name; $mail->msgHTML($layout->HtmlText); if ($mail->send()) { $person->Status = 1; $person->save(); } else { $person->Status = 5; $person->save(); echo "Mailer Error: " . $mail->ErrorInfo; } } if (empty($lista)) { $checkNewsletter->Status = 0; $checkNewsletter->save(); } } die; }
public static function send($to_email, $reply_email, $reply_name, $from_email, $from_name, $subject, $body, $attachments = array()) { if (Configuration::model()->emailer->relay == 'SMTP') { $email = new \PHPMailer(); //$email->SMTPDebug = 4; $email->isSMTP(); $email->Host = Configuration::model()->emailer->host; $email->SMTPAuth = Configuration::model()->emailer->auth; $email->Username = Configuration::model()->emailer->username; $email->Password = Configuration::model()->emailer->password; $email->SMTPSecure = Configuration::model()->emailer->security; $email->Port = Configuration::model()->emailer->port; } $email->addAddress($to_email); $email->addReplyTo($reply_email, $reply_name); $email->setFrom($from_email, $from_name); $email->Subject = $subject; $email->Body = $body; $email->msgHTML($body); $email->AltBody = strip_tags(str_replace('<br>', "\n\r", $body)); if (is_array($attachments)) { foreach ($attachments as $value) { $email->addAttachment($value); } } $email->send(); }
function EnviaCorreo_ClavesAlta($strEmail, $strUsuario, $strPassword) { require '../general/phpmailer/PHPMailerAutoload.php'; $from = '*****@*****.**'; $mail = new PHPMailer(); //Correo desde donde se envía (from) $mail->setFrom($from, ''); //Correo de envío (to) $mail->addAddress($strEmail, ''); $mail->CharSet = "UTF-8"; $mail->Subject = 'Sistema de Calidad. Envío de claves'; $strHTML = '<table width="440" border="0" height="22" class="txtgeneral">'; $strHTML = $strHTML . '<tr><td>Sus datos de acceso son:</td></tr>'; $strHTML = $strHTML . "<tr><td>Usuario: <strong>{$strUsuario}<strong></td></tr>"; $strHTML = $strHTML . "<tr><td>Contraseña: <strong>{$strPassword}<strong><br/><br/><br/><br/></td></tr>"; $strHTML = $strHTML . '<tr><td>Agradecemos su colaboración. </td></tr>'; $strHTML = $strHTML . '<tr><td>Atentamente,</td></tr><br><br>'; $strHTML = $strHTML . '<tr><td>Departamento de Calidad</td></tr>'; $strHTML = $strHTML . '<tr><td><center><IMG SRC="http://www.qualidad.info/qualidad/images/logo-' . $_SESSION['base'] . '.jpg" width="132" height="67" BORDER="0"></center>'; $strHTML = $strHTML . '</td></tr>'; $strHTML = $strHTML . '</table>'; $strHTML = '<HTML><BODY><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""-1""><meta http-equiv="Content-type" content="text/html; charset=utf-8" />' . $strHTML . '</font></BODY></HTML>'; $mail->msgHTML($strHTML); $mail->send(); }
function sendMail($nomeDestino, $emailDestino, $nomeRemetente, $emailRemetente, $assunto, $msg, $arquivo = "") { require_once str_replace("admin/", "", DIR) . "system/PHPMailer/PHPMailer.php"; #$nomeDestino = Nome de quem vai receber #$emailDestino = E-mail de quem vai receber #$nomeRemetente = Nome de quem está enviando #$emailRemetente = E-mail de quem está enviando #$assunto = Assunto do e-mail #$msg = Mensagem do e-mail $montaMsg = '<div style="text-align: left"><img src="' . str_replace("admin", "", CP) . '/assets/img/header_mail.jpg" alt="Header" /></div>'; $montaMsg .= '<br /><div style="font-family: Arial; color: #666; font-size: 14px;">' . $msg . '<br /><br />'; $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = getSys("smtpHost"); $mail->Port = getSys("smtpPort"); $mail->SMTPAuth = true; $mail->Username = getSys("smtpLogin"); $mail->Password = getSys("smtpPass"); $mail->SetFrom(getSys("smtpLogin"), $nomeRemetente); $mail->addReplyTo($emailRemetente, $nomeRemetente); $mail->AddAddress($emailDestino, $nomeDestino); $mail->Subject = $assunto; $mail->msgHTML($montaMsg); if ($arquivo == true) { $mail->AddAttachment($arquivo); } if (!$mail->send()) { return false; } else { return true; } }
public function send() { $mail = new \PHPMailer(); $mail->isSMTP(); //CONFIGURAÇÕES DO SMTP $mail->Host = 'smtp.email.com.br'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->Port = 587; //E-MAIL DESTIMO E CC $this->setTo("*****@*****.**"); $mail->addCC("*****@*****.**"); $mail->From = '*****@*****.**'; $mail->FromName = 'Assunto'; $mail->addAddress($this->getTo(), ''); $mail->Subject = $this->getSubject(); $mail->msgHTML($this->templateMail($this->getTemplate(), $this->getDataEmail())); $mail->isHTML(true); $msg = ""; if (!$mail->send()) { $msg += 'Message could not be sent.'; $msg += 'Mailer Error: ' . $mail->ErrorInfo; } else { $msg += 'Message has been sent'; } return $msg; }
function sendEmail($userEmail, $userFName, $userLName, $date, $price) { $mail = new PHPMailer(); $mail->isSendmail(); $mail->setFrom('*****@*****.**', 'Help Desk'); $mail->addReplyTo('*****@*****.**', 'Efraim Krug'); $mail->addAddress($userEmail, 'User Krug'); $message = "<html><body style=\"font:14px Arial,Helvetica,sans-serif; color:#000; background:#fff\">"; $message .= "\n<p>Dear " . $userFName . " " . $userLName . "</p>"; $message .= "\n<p>Please do not reply to this message, as it was sent from an unattended mail box.</p>"; $message .= "\n<p>This is an automated invoice for the Caneur!</p>"; $message .= "\n<p>For service rendered on " . $date . "</p>"; $message .= "\n<p>For the amount of " . number_format($price, 2) . "</p>"; $message .= "\n<p>Thank you so much for your patronage!</p>"; $message .= "\n<p>Best to you and your family!</p>"; $message .= "\n<p>Your local Caneur!</p>"; $message .= "</body></html>"; $mail->Subject = 'Caneur invoice - ' . $date; $mail->msgHTML($message); #$mail->addAttachment($FileName); #if (!$mail->send()) { # echo "Mailer Error: " . $mail->ErrorInfo; #} else { # echo "Message sent!"; #} return; }
/** * Populate the email message */ private function populateMessage() { $attributes = $this->attributes; $this->mailer->CharSet = 'UTF-8'; $this->mailer->Subject = $attributes['subject']; $from_parts = Email::explodeEmailString($attributes['from']); $this->mailer->setFrom($from_parts['email'], $from_parts['name']); $to = Helper::ensureArray($this->attributes['to']); foreach ($to as $to_addr) { $to_parts = Email::explodeEmailString($to_addr); $this->mailer->addAddress($to_parts['email'], $to_parts['name']); } if (isset($attributes['cc'])) { $cc = Helper::ensureArray($attributes['cc']); foreach ($cc as $cc_addr) { $cc_parts = Email::explodeEmailString($cc_addr); $this->mailer->addCC($cc_parts['email'], $cc_parts['name']); } } if (isset($attributes['bcc'])) { $bcc = Helper::ensureArray($attributes['bcc']); foreach ($bcc as $bcc_addr) { $bcc_parts = Email::explodeEmailString($bcc_addr); $this->mailer->addBCC($bcc_parts['email'], $bcc_parts['name']); } } if (isset($attributes['html'])) { $this->mailer->msgHTML($attributes['html']); if (isset($attributes['text'])) { $this->mailer->AltBody = $attributes['text']; } } elseif (isset($attributes['text'])) { $this->mailer->msgHTML($attributes['text']); } }
public function EnviarCorreo($Nombre, $ape1, $Correo, $URL, $Subject, $Mensaje) { try { $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPSecure = 'tls'; $mail->Host = $this->host; $mail->Port = $this->port; $mail->SMTPAuth = true; $mail->Username = $this->usernameFrom; $mail->Password = $this->pass; $mail->SMTPDebug = 0; //$mail->Debugoutput = 'html'; $mail->addAddress($correo, $Nombre); $mail->From = $this->usernameFrom; $mail->FromName = $this->{$FromName}; $mail->addReplyTo($this->usernameFrom, $this->{$ReplyTo}); $mail->Subject = $Subject; $mail->WordWrap = 50; $mail->msgHTML($Mensaje); $mail->isHTML(true); $mail->send(); } catch (phpmailerException $me) { Utils::escribeLog("Error: " . $me->getMessage() . " | Fichero: " . $me->getFile() . " | Línea: " . $me->getLine() . " [Error al enviar correo]", "debug"); return false; } catch (Exception $e) { Utils::escribeLog("Error: " . $e->getMessage() . " | Fichero: " . $e->getFile() . " | Línea: " . $e->getLine() . " [Error al enviar correo]", "debug"); return false; } return true; }
function email_confirm($nombre, $key, $correo) { //$link='"localhost/Aitor/TRACKING%20APP/trackingapp/confirmar.php?email="'.$correo."&key="."$key"'; $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPAuth = true; //$mail->SMTPSecure = "ssl"; $mail->Host = "smtp-mail.outlook.com"; $mail->Port = 587; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->FromName = "Tracking App"; $mail->Subject = "Bienvenido a App Tracking"; $mail->AltBody = "Mensaje de prueba"; $mail->msgHTML("<h1>Mensaje de Bienvenida</h1><br/><br/><p>\n Hola <b>" . $nombre . "</b><br>Gracias por incribirse en la <b>Tracking App</b></p><br/>\n <p>Debes activar tu cuenta pulsando este enlace \n :<a href='http://localhost/Aitor/TRACKING%20APP/trackingapp/confirmar.php?email=" . $correo . "&key=" . $key . "'>pulsa aqui para activar la cuenta</a></p>"); //<a href="http://www.w3schools.com">Visit W3Schools</a> // echo '<td>'."<a href=map.php?action=mapamostrar&datos=".$obj."><input type='button' value=' MAP' ></a>".'</td>'; //echo "<a href='".$link_address."'>Link</a>"; $mail->addAddress($correo, $nombre); $mail->isHTML(true); if (!$mail->send()) { echo "Error: " . $mail->ErrorInfo; } }
function sendemail($receivers, $subject, $contents) { //Create a new PHPMailer instance $mail = new PHPMailer(); //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = "smtp.163.com"; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = 25; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = "******"; //Password to use for SMTP authentication $mail->Password = "******"; //Set who the message is to be sent from $mail->setFrom('*****@*****.**', 'Boystyle.cn'); //Set an alternative reply-to address // $mail->addReplyTo('*****@*****.**', 'First Last'); //Set who the message is to be sent to $mail->addAddress($receivers); //Set the subject line $mail->Subject = $subject; // 使用内容模本发送邮件 //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body // $mail->msgHTML(file_get_contents('./lib/PHPMailer/contents.html'), dirname(__FILE__)); //Replace the plain text body with one created manually // $mail->AltBody = 'This is a plain-text message body'; // $msg = ""; // $msg .= "<html>"; // $msg .= "<head>"; // $msg .= " <title>Boystyle.cn</title>"; // $msg .= "</head>"; // $msg .= "<body>"; // $msg .= " <h3>Boystyle.cn上线了</h3>"; // $msg .= " <p>终于可以开心个的买买买啦...</p>"; // $msg .= "</body>"; // $msg .= "</html>"; // $mail->msgHTML($msg); $mail->msgHTML($contents); //附件 //Attach an image file // $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } }
public function setMessage($content) { if ($this->isHtml()) { $this->php_mailer->msgHTML($content); } else { $this->php_mailer->Body = $content; } }
/** * @author Xingda Wang <*****@*****.**> * @since 1.0 * * Send Email to user */ function sendEmail($email, $subject, $body) { //SMTP needs accurate times, and the PHP time zone MUST be set //This should be done in your php.ini, but this is how to do it if you don't have access to that date_default_timezone_set('Etc/UTC'); require 'php-mailer/PHPMailerAutoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer(); //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = 'smtp.gmail.com'; //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->Port = 587; //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = "******"; //Password to use for SMTP authentication $mail->Password = "******"; //Set who the message is to be sent from $mail->setFrom('*****@*****.**', 'Ucard Store'); //Set an alternative reply-to address //$mail->addReplyTo('*****@*****.**', 'First Last'); //$mail->addCC("*****@*****.**"); //Set who the message is to be sent to //$mail->addAddress('*****@*****.**', 'Ucard Store'); $mail->addAddress($email); //Set the subject line $mail->Subject = $subject; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); $msg = $body; $mail->msgHTML("{$msg}"); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file //$mail->addAttachment('/media/psf/Home/Downloads/ucard.jpg'); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } }
/** * @param User $user * * @throws \phpmailerException */ protected function sendVerificationMail($user) { $mail = new \PHPMailer(); $mail->isSendmail(); $mail->setFrom('*****@*****.**', 'Sample Blog News'); $mail->addAddress($user->email, $user->email); $mail->Subject = 'Confirm your Sample Blog News account'; $body = "You need to confirm your email address " . $user->email . " in order to activate your Sample Blog News\n account. <br/> Activating your account will give you more benefits and better control.<br />\n Please click the link below to confirm your account <br />\n http://" . $this->getRequest()->getUri()->getHost() . "/account/confirm/" . $user->token; $mail->msgHTML($body); $mail->send(); }
function sendEmail($data) { $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; $mail->isSendmail(); $mail->setFrom('*****@*****.**', $data['name']); $mail->addAddress('*****@*****.**', "Ирине Тишкевич"); $mail->Subject = "Отправка письма с shop.ru"; $mail->msgHTML('Заказан звонок от: ' . $data['name'] . '. Дата: ' . $data['day'] . '.' . $data['month'] . '. Телефон: ' . $data['phone'] . '. Комментарий: ' . $data['message']); return $mail->send(); }
function EnviaCorreoAlta($strMail, $originado, $destinatario, $num, $fecha, $departamento, $tipo) { require_once '../general/phpmailer/PHPMailerAutoload.php'; $to = $strMail; $from = '*****@*****.**'; $mail = new PHPMailer(); //Correo desde donde se envía (from) $mail->setFrom($from, ''); //Correo de envío (to) $mail->addAddress($to, ''); $mail->CharSet = "UTF-8"; $mail->Subject = "Sistema de Qualidad"; $html = '<!DOCTYPE html> <html> <head> <title>Q-Conta</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> </head> <body> <div><IMG SRC="https://www.qualidad.es/qualidad/images/logo-' . $_SESSION['base'] . '.JPG" width="140" height="70" BORDER="0"></div> <div><h1><font color="blue">Sistema de Gestión de Calidad</font></h1></div> <hr/> <div><font color="red">MENSAJE AUTOMÁTICO ENVIADO POR EL SISTEMA</font></div> <div>Originado por: <strong>' . $originado . '</strong></div> <div>Destinatario: <strong>' . $destinatario . '</strong></div> <div>En el Sistema de Gestión de la Calidad de ' . $_SESSION['strSesion'] . ' se han llevado a cabo acciones que requieren su intervención.</div> <div>Si por error las acciones detalladas al pie no le afectasen, deberá reenviar este mensaje a la persona afectada o comunicárselo al Departamento de Calidad.</div><br/> <div><font color="red">DESCRIPCIÓN DE LAS ACCIONES</font></div><br/> <div><strong>Acción C/P</strong> número <font color="blue">' . $num . '</font> con fecha <font color="blue">' . $fecha . '</font> que afecta al Departamento de <font color="blue">' . $departamento . '.</font></div><br/> <hr/> <div>El Departamento de Calidad agradece su participación en el sistema de gestión y su rápida actuación en las acciones mencionadas, orientadas al cumplimiento de los requisitos de la norma UNE-EN ISO 9001:2008.</div><br/> <div>AVISO: esta dirección de correo está destinada al envío de información y no está habilitada para la recepción de mensajes.</div><br/> </body> </html>'; //veo si el correo es HTML o texto plano if ($tipo === '1') { //HTML $mail->msgHTML($html); } else { //texto plano $mail->ContentType = 'text/plain'; $mail->IsHTML(false); $html = convert_html_to_text($html); $mail->Body = $html; } if (!$mail->send()) { logger('traza', basename($_SERVER['PHP_SELF']) . '-', "Usuario: " . $_SESSION['strUsuario'] . ', Empresa: ' . $_SESSION['srtBD'] . ', SesionID: ' . session_id() . " Correo NO Enviado."); return false; } else { logger('traza', basename($_SERVER['PHP_SELF']) . '-', "Usuario: " . $_SESSION['strUsuario'] . ', Empresa: ' . $_SESSION['srtBD'] . ', SesionID: ' . session_id() . " Correo Enviado CORRECTAMENTE."); return true; } }
/** * Send an email using PHPMailer * @param \Cogeco\Build\Entity\Email\Connector $connector * @param \Cogeco\Build\Entity\Email $emailData * @throws \Cogeco\Build\Exception */ public static function sendEmail(Connector $connector, Email $emailData) { $multipleRecipients = count($emailData->to) > 1; Task::log("- Sending email {$emailData->subject}\n"); $mail = new \PHPMailer(); if ($connector instanceof SmtpConnector) { //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = $connector->host; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = $connector->port; //Whether to use SMTP authentication $mail->SMTPAuth = false; // SMTP auth is currently unsupported // if ($connector->auth) { } } else { throw new Exception("EmailTask error: Unsupported email connector"); } // Set the FRom address and name $mail->setFrom($emailData->fromAddress, $emailData->fromName); //Set a reply-to address, if there is one if (!empty($emailData->replyAddress)) { $mail->addReplyTo($emailData->replyAddress, $emailData->replyName); } foreach ($emailData->to as $i => $toAddress) { $mail->addAddress($toAddress); } // Set the subject, HTML body and text $mail->Subject = $emailData->subject; $mail->msgHTML($emailData->bodyHtml); $mail->AltBody = $emailData->bodyText; // Set attachments if (!empty($emailData->attachments)) { foreach ($emailData->attachments as $i => $attachment) { $mail->addAttachment($attachment); } } $mail->CharSet = $emailData->encoding; // Send the message, check for errors if ($mail->send()) { Task::log("Email notification" . ($multipleRecipients ? 's' : '') . " sent\n\n"); } else { throw new Exception("Mailer Error: " . $mail->ErrorInfo); } }
/** * 快捷发送一封邮件 * @param string $to 收件人 * @param string $sub 邮件主题 * @param string $msg 邮件内容(HTML) * @param array $att 附件,每个键为文件名称,值为附件内容(可以为二进制文件),例如array('a.txt' => 'abcd' , 'b.png' => file_get_contents('x.png')) * @return bool 成功:true 失败:错误消息 */ public static function mail($to, $sub = '无主题', $msg = '无内容', $att = array()) { if (defined("SAE_MYSQL_DB") && class_exists('SaeMail')) { $mail = new SaeMail(); $options = array('from' => option::get('mail_name'), 'to' => $to, 'smtp_host' => option::get('mail_host'), 'smtp_port' => option::get('mail_port'), 'smtp_username' => option::get('mail_smtpname'), 'smtp_password' => option::get('mail_smtppw'), 'subject' => $sub, 'content' => $msg, 'content_type' => 'HTML'); $mail->setOpt($options); $ret = $mail->send(); if ($ret === false) { return 'Mail Send Error: #' . $mail->errno() . ' - ' . $mail->errmsg(); } else { return true; } } else { $From = option::get('mail_name'); if (option::get('mail_mode') == 'SMTP') { $Host = option::get('mail_host'); $Port = intval(option::get('mail_port')); $SMTPAuth = (bool) option::get('mail_auth'); $Username = option::get('mail_smtpname'); $Password = option::get('mail_smtppw'); $Nickname = option::get('mail_yourname'); if (option::get('mail_ssl') == '1') { $SSL = true; } else { $SSL = false; } $mail = new SMTP($Host, $Port, $SMTPAuth, $Username, $Password, $SSL); $mail->att = $att; if ($mail->send($to, $From, $sub, $msg, $Nickname)) { return true; } else { return $mail->log; } } else { $name = option::get('mail_yourname'); $mail = new PHPMailer(); $mail->setFrom($From, $name); $mail->addAddress($to); $mail->Subject = $sub; $mail->msgHTML($msg); $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; foreach ($att as $n => $d) { $mail->addStringAttachment($d, "=?UTF-8?B?" . base64_encode($n) . "?=", 'base64', get_mime(get_extname($n))); } if (!$mail->send()) { return $mail->ErrorInfo; } else { return true; } } } }
public function restaurarcuenta() { View::template('sbadmin'); if (Input::hasPost('correo')) { $Usuario = new Usuario(); $direccion = $_POST['correo']['email']; if ("SELECT count(*) FROM usuario WHERE email = '{$direccion}'" == 1) { $mail = new PHPMailer(); $mail->isSMTP(); //$mail>SMTPDebug = 2; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->Username = "******"; $mail->Password = "******"; $mail->setFrom('*****@*****.**', 'Gestión Documental'); //$mail>AddReplyTo("*****@*****.**", "Steven Ruiz"); $mail->Subject = "asunto"; $mail->msgHTML("mensaje"); //$address = "*****@*****.**"; $mail->addAddress($_POST['correo']['email'], "..."); if (!$mail->send()) { echo "Error al enviar: " . $mail->ErrorInfo; } Input::delete(); } else { print_r("No hay cuenta asociada al correo digitado"); } } }
function send_mail($from, $email, $tpl, $data = array()) { try { //Create a new PHPMailer instance $mail = new PHPMailer(); // Set PHPMailer to use the sendmail transport //$mail->isSendmail(); //Set who the message is to be sent from $mail->setFrom($from, $from); //Set an alternative reply-to address $mail->addReplyTo($from, $from); //Set who the message is to be sent to $mail->addAddress($email, ''); //$mail->addAddress( '*****@*****.**', ''); //Set the subject line $mail->Subject = isset($data['emailsubject']) ? $data['emailsubject'] : 'email from ' . $from; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML(template_file($tpl, $data)); //Replace the plain text body with one created manually $mail->AltBody = ''; $mail->CharSet = 'utf-8'; if ($mail->send()) { } } catch (Exception $e) { print_r($e); } }