function send_mail($email, $date, $time) { require '../phpmailer/PHPMailerAutoload.php'; $mail = new phpmailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('*****@*****.**', 'Mailer'); $mail->addAddress('' . $email . '', 'user'); $mail->isHTML(true); $mail->Subject = 'booking'; $mail->Body = 'This email is coming from global styling to: ' . $email . ' </br> your booking is set for ' . $date . ' at ' . $time . ' thank you for booking with us. Global Styling'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent to your E-Mail address'; } }
function envmail($email, $subject, $msg, $from, $fromname = "Opala Clube Franca") { require_once "class.phpmailer.php"; $mail = new phpmailer(); $mail->ClearAddresses(); $mail->ClearAllRecipients(); $mail->ClearAddresses(); $mail->ClearCustomHeaders(); $mail->IsSMTP(); // $mail->IsSendmail(); $mail->From = $from; $mail->FromName = $fromname; // $mail->Hostname = "smtp.gmail.com"; // $mail->Host = "smtp.gmail.com"; $mail->SMTPSecure = "ssl"; $mail->Hostname = "smtp.opalaclubefranca.com.br"; $mail->Host = "smtp.opalaclubefranca.com.br"; // $mail->SMTPDebug = 2; $mail->Username = "******"; $mail->Password = "******"; $mail->SMTPAuth = true; $mail->Port = 465; $mail->Timeout = 120; $body = $msg; $text_body = $msg; $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = $text_body; if (is_array($email)) { foreach ($email as $em) { $mail->AddAddress($em, ""); } } else { $mail->AddAddress($email, ""); } /* echo '<tr><td>To '.$email.'</td></tr>'."\n"; echo '<tr><td>Assunto '.$subject.'</td></tr>'."\n"; echo '<tr><td>Mensagem '.$msg.'</td></tr>'."\n"; echo '<tr><td>From '.$from.'</td></tr>'."\n"; */ $exito = $mail->Send(); $v = 0; // echo "<tr><td>ErrorInfo " . $mail->ErrorInfo . "<br></td></tr>"; while (!$exito && $v < 5 && $mail->ErrorInfo != "SMTP Error: Data not accepted.") { sleep(2); $exito = $mail->Send(); echo "<tr><td>ErrorInfo " . $mail->ErrorInfo . "<br></td></tr>"; $v = $v + 1; } if (!$exito) { echo "<tr><td>There has been a mail error sending to " . $mail->ErrorInfo . "<br></td></tr>"; } $mail->ClearAddresses(); $mail->ClearAttachments(); return $mail->ErrorInfo; }
$mail->ClearAllRecipients(); $mail->ClearAddresses(); $mail->ClearCustomHeaders(); $mail->IsSMTP(); $mail->From = "*****@*****.**"; $mail->FromName = "Backup Bolão"; $mail->Hostname = "smtp.netsite.com.br"; $mail->Host = "smtp.netsite.com.br"; // $mail->SMTPDebug = 2; $mail->Username = "******"; $mail->Password = "******"; $mail->SMTPAuth = true; $mail->Timeout = 120; $body = "Backup automático do bolão"; $text_body = "Backup automático do bolão"; $mail->isHTML(true); $mail->Subject = sprintf("Backup Bolão do dia %s", date("d/m/Y H:i:s")); $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($row['emailwbm'], ""); $mail->AddAttachment("/home/bkbolao/bkdados.tar.gz"); $mail->AddAttachment("/home/bkbolao/bkfontes.tar.gz"); $exito = $mail->Send(); $v = 0; while (!$exito && $v < 5 && $mail->ErrorInfo != "SMTP Error: Data not accepted.") { sleep(2); $exito = $mail->Send(); echo "<tr><td>ErrorInfo " . $mail->ErrorInfo . "<br></td></tr>"; $v = $v + 1; } if (!$exito) {
} if (!isset($error_message)) { $email_body = ""; $email_body .= "Name: " . $name . "\n"; $email_body .= "Email: " . $email . "\n"; $email_body .= "Suggested Item\n"; $email_body .= "Category: " . $category . "\n"; $email_body .= "Title: " . $title . "\n"; $email_body .= "Format: " . $format . "\n"; $email_body .= "Genre: " . $genre . "\n"; $email_body .= "Year: " . $year . "\n"; $email_body .= "Details: " . $details . "\n"; $mail->setFrom($email, $name); $mail->addAddress('*****@*****.**', 'Daisho'); // Add a recipient $mail->isHTML(false); // Set email format to HTML $mail->Subject = 'Personal Media Library Suggestion from ' . $name; $mail->Body = $email_body; if ($mail->send()) { header("location:suggest.php?status=thanks"); exit; } $error_message = 'Message could not be sent.'; $error_message .= 'Mailer Error: ' . $mail->ErrorInfo; } } $pageTitle = "Suggest a Media Item"; $section = "suggest"; include "inc/header.php"; ?>
function send_mail() { require 'phpmailer/PHPMailerAutoload.php'; $email = ""; $mail = new phpmailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('*****@*****.**', 'Mailer'); $mail->addAddress('*****@*****.**', 'user'); $mail->isHTML(true); $mail->Subject = 'The code works'; $mail->Body = 'This email is coming from <b> GLOBAL STYLING SALONS !! </b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent to your E-Mail address'; } }
function emailSend($data) { $stime = array_sum(explode(' ', microtime())); require_once "getmxrr.php"; $smtp =& $this->params; $mail = new phpmailer(); $mail->Mailer = "smtp"; $mail->From = isset($data['from']) & !empty($data['from']) ? $data['from'] : '*****@*****.**'; $mail->FromName = isset($data['fromName']) & !empty($data['fromName']) ? $data['fromName'] : 'RuSoft'; $mail->Sender = isset($data['from']) & !empty($data['from']) ? $data['from'] : '*****@*****.**'; $mail->Host = $smtp['host']; $mail->CharSet = $smtp['charset']; $mail->Encoding = $smtp['encoding']; $mail->Port = $smtp['port']; $mail->SMTPAuth = $smtp['auth']; $mail->Subject = isset($data['subj']) & !empty($data['subj']) ? $data['subj'] : ''; if ($smtp['auth']) { $mail->Username = $smtp['user']; $mail->Password = $smtp['pass']; } // HTML body if (isset($data['mess']['html']) & !empty($data['mess']['html'])) { $body = $data['mess']['html']; $mail->isHTML(true); } // Plain text body (for mail clients that cannot read HTML) if (isset($data['mess']['text']) & !empty($data['mess']['text'])) { $text_body = $data['mess']['text']; $mail->isHTML(false); } $mail->AltBody = isset($text_body) ? $text_body : ''; $mail->Body = isset($body) ? $body : (isset($text_body) ? $text_body : ''); $i = 1; // порядковый номер файла //добавляем файлы прикрепленные файлы if (isset($data['attachment']) & !empty($data['attachment'])) { foreach ($data['attachment'] as $k => $item) { if (isset($item['binary']) & !empty($item['binary'])) { $mail->AddStringAttachment($item["binary"], isset($item["name"]) & !empty($item["name"]) ? $item["name"] : 'file' . $i, $smtp['encoding']); $i++; } elseif (isset($item['path']) & !empty($item['path'])) { $mail->AddAttachment($item["path"], isset($item["name"]) & !empty($item["name"]) ? $item["name"] : 'file' . $i, $smtp['encoding']); $i++; } } } // добавляем файлы, отображаемые на странице if (isset($data['embedded']) & !empty($data['embedded'])) { foreach ($data['embedded'] as $k => $item) { if (isset($item['path']) & !empty($item['path'])) { $mail->AddEmbeddedImage($item["path"], isset($item["cid"]) & !empty($item["cid"]) ? $item["cid"] : $i, isset($item["name"]) & !empty($item["name"]) ? $item["name"] : 'file' . $i, $smtp['encoding']); $i++; } } } //pr($mail); //на данном этапе имеется уже собранное письмо и нам необходимо определить mx серверы для отправки...для каждого письма. //чтобы повторно не искать серверы в момент отправки для каждого... //сохраняем для каждого домена один и тот же сервер $mxsrvs = array(); $mxemails = array(); $debug['ctime'] = round((array_sum(explode(' ', microtime())) - $stime) * 1000, 2) . " ms"; foreach ($data['to'] as $email => $name) { //берем чисто host if (!$this->_is_valid_email($email)) { $debug['emails'][$email]['error'] = "неправильно указан email адрес."; continue; } $host = substr($email, strpos($email, "@") + 1); $domains = explode(".", $host); foreach ($domains as $level => $domain) { $address = implode(".", $domains); if (!key_exists($address, $mxsrvs)) { $time = array_sum(explode(' ', microtime())); if (getmxrr_portable($address, $mxhosts, $preference) == true) { array_multisort($preference, $mxhosts); } $debug['emails'][$email]['mxtime'] = round((array_sum(explode(' ', microtime())) - $time) * 1000, 2) . " ms"; if (!empty($mxhosts)) { $mxhosts[] = $smtp['host']; //потому что shadow тормознутый сервак if (in_array('shadow.rusoft.ru', $mxhosts)) { unset($mxhosts[0]); } //чтобы включить рассылку на smtp серверы получателей, необходимо закоментировать следующую строчку $mxhosts = array_reverse($mxhosts); $mxsrvs[$address] = $mxhosts; $mxemails[$email] =& $mxsrvs[$address]; $debug['emails'][$email]['mxsrvs'] =& $mxsrvs[$address]; break; } else { unset($domains[$level]); } } else { $debug['emails'][$email]['mxtime'] = 'cache(0 ms)'; $mxemails[$email] =& $mxsrvs[$address]; $debug['emails'][$email]['mxsrvs'] =& $mxsrvs[$address]; } } } //получены все mx северы и теперь начинаем отправку по списку foreach ($mxemails as $email => $mxs) { //проверяем email адрес на существование и работу mx сервера //можно включить проверку, но это 1) замедляет, 2) вероятность очень низкая //$this->checkEmail($email, $mxs, $debug); $mail->AddAddress($email, $name); foreach ($mxs as $k => $host) { $mail->Host = $host; $time = array_sum(explode(' ', microtime())); $status = $mail->Send(); $debug['emails'][$email]['sendtime'] = round((array_sum(explode(' ', microtime())) - $time) * 1000, 2) . " ms"; $debug['emails'][$email]['status'] = $status; if ($status) { $debug['emails'][$email]['host'] = $host; break; } } $mail->ClearAddresses(); } $debug['time'] = round((array_sum(explode(' ', microtime())) - $stime) * 1000, 2) . " ms"; if (function_exists('log_notice')) { //скидываем в лог информацию о отправленных сообщениях $str = "<b>Были отправлены следующие сообщения:</b><br>Время генерации шалона для отправки: " . $debug['ctime'] . "<br>Общее время: " . $debug['time'] . "<br><b>Адреса:</b><br>"; foreach ($debug['emails'] as $k => $v) { $str .= "<br> <b><font color='blue'>" . $k . "</font></b>"; $str .= "<br> Определение smtp серверов: " . $v['mxtime']; $str .= "<br> Отправлено через: " . $v['host']; $str .= "<br> Время отправления: " . $v['sendtime']; $str .= "<br> Статус: " . ($v['status'] ? '<font color="green">успешно</font>' : '<font color="red">неудачно</font>'); } log_notice('email', false, $str); } //$status = true; // Clear attachments for next loop $mail->ClearAttachments(); if ($status) { return true; } return false; }