本文整理汇总了PHP中PHPMailer类的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer类的具体用法?PHP PHPMailer怎么用?PHP PHPMailer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPMailer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mail
public static function mail($address, $title, $content)
{
if (empty($address)) {
return false;
}
$mail = new \PHPMailer();
//服务器配置
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.qq.com';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->CharSet = 'UTF-8';
//用户名设置
$mailInfo = Config::getConfig('mail_info');
$mailInfo = json_decode($mailInfo, true);
$mail->FromName = $mailInfo['fromName'];
$mail->Username = $mailInfo['userName'];
$mail->Password = $mailInfo['password'];
$mail->From = $mailInfo['from'];
$mail->addAddress($address);
//内容设置
$mail->isHTML(true);
$mail->Subject = $title;
$mail->Body = $content;
//返回结果
if ($mail->send()) {
return true;
} else {
return false;
}
}
示例2: EmailError
function EmailError($errorText)
{
require_once "phpmailer/class.phpmailer.php";
$mail = new PHPMailer();
if (EMAIL_ERROR_MESSAGES) {
$mail->IsSMTP('true');
// set mailer to use SMTP
$mail->Host = "192.168.50.27";
// specify main and backup server
$mail->SMTPAuth = false;
// turn on SMTP authentication
$mail->Username = "";
// SMTP username
$mail->Password = "";
// SMTP password
$mail->From = "snowball@meyersound.com";
$mail->FromName = "Error on Snowball";
$mail->WordWrap = 70;
// set word wrap to 70 characters
$mail->Subject = 'PHP Server Error';
$text = "The following error just occured:\r\nMessage: {$errorText}\r\n";
$mail->AddAddress('ashwinib@meyersound.com');
$mail->IsHTML(false);
$mail->Body = $text;
$mail->Send();
}
}
示例3: register
public function register(Container $container)
{
$container['mail'] = function ($c) {
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
// if($c['phpmailer']['smtp'])
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = $c['phpmailer']['smtpdebug'];
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = $c['phpmailer']['host'];
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = $c['phpmailer']['port'];
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = $c['phpmailer']['smtpsecure'];
//Whether to use SMTP authentication
$mail->SMTPAuth = $c['phpmailer']['smtpauth'];
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = $c['phpmailer']['username'];
//Password to use for SMTP authentication
$mail->Password = $c['phpmailer']['password'];
//Set who the message is to be sent from
// $mail->setFrom($c['phpmailer.mail'], $c['phpmailer.firm']);
return $mail;
};
}
示例4: sendMail
function sendMail($subject = MAIL_SUBJECT, $body = "", $to = "topguay@topguay.com")
{
$mail = new PHPMailer();
$mail->IsSMTP();
// telling the class to use SMTP
$mail->Host = MAIL_HOST;
// SMTP server
$mail->From = MAIL_FROM;
$mail->FromName = MAIL_FROMNAME;
$mail->Subject = $subject;
$mail->SMTPAuth = true;
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;
$mail->AltBody = "Para ver el mensaje, use un visor de e-mail compatible con HTML.";
// optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($to);
if (!$mail->Send()) {
// echo "Mailer Error: " . $mail->ErrorInfo;
return $mail->ErrorInfo;
} else {
// echo "Message sent!";7
return true;
}
}
示例5: sendEmailNotifier
function sendEmailNotifier($contactUsEntry)
{
assert(isset($contactUsEntry) && $contactUsEntry != "");
$isSuccessful = false;
$mail = new PHPMailer();
//$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 0;
// enables SMTP debug information (for testing)
//$mail->SMTPAuth = TRUE; // enable SMTP authentication
//$mail->SMTPSecure = "ssl"; // sets the prefix to the server
//$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
//$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->IsHTML(TRUE);
// gmail account to use to send the email
//$mail->Username = "fongclinton.mail.gateway@gmail.com";
//$mail->Password = "Password001";
//$mail->SetFrom("fongclinton.mail.gateway@gmail.com");
$mail->AddAddress(CONTACT_US_EMAIL, "Contact Us");
//$mail->AddCC("info@clintonfong.com", "Clinton Fong");
$mail->Subject = "Contact Us Message from Online Diaries Website";
$msg = "Firstname: {$contactUsEntry->firstname} <br />";
$msg .= "Lastname: {$contactUsEntry->lastname} <br />";
$msg .= "Email: {$contactUsEntry->email}<br />";
$msg .= "Message: {$contactUsEntry->message}<br>";
$mail->Body = $msg;
// Mail it
$isSuccessful = $mail->Send();
/*
if( !$isSuccessful )
{
//$strResult .= " Mailer error: {$mail->ErrorInfo}";
}
*/
return $isSuccessful;
}
示例6: smtpmailer
function smtpmailer($para, $from, $de_nome, $subject, $corpo)
{
global $error, $smtpUsuario, $smtpSenha;
$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.gmail.com';
// SMTP utilizado
$mail->Port = 587;
// A porta 587 deverá estar aberta em seu servidor
$mail->Username = $smtpUsuario;
$mail->Password = $smtpSenha;
$mail->SetFrom($from, $de_nome);
$mail->Subject = $subject;
$mail->Body = $corpo;
$mail->AddAddress($para);
if (!$mail->Send()) {
$error = '<div class="sent">Mail error: ' . $mail->ErrorInfo . '</div>';
return false;
} else {
$error = '<div class="sent">Enviado com sucesso!</div>';
return true;
}
}
示例7: sendMail
public function sendMail($address, $send_user, $from, $title, $message)
{
vendor('mail.mail');
$message = eregi_replace("[\\]", '', $message);
// preg_replace('/\\\\/','', $message);
$mail = new PHPMailer();
$mail->IsSMTP();
// 设置PHPMailer使用SMTP服务器发送Email
$mail->CharSet = 'UTF-8';
// 设置邮件的字符编码,若不指定,则为'UTF-8'
$mail->Port = $this->setting['mail_port'];
//端口号
$mail->AddAddress($address);
// 添加收件人地址,可以多次使用来添加多个收件人
//$mail->Body=$message; // 设置邮件正文
$mail->MsgHTML($message);
//$mail->From=$this->setting['mail_username']; // 设置邮件头的From字段。
$mail->From = $from;
// 设置邮件头的From字段。
$mail->FromName = $this->setting['mail_fromname'];
// 设置发件人名字
$mail->Subject = $title;
// 设置邮件标题
$mail->Host = $this->setting['mail_smtp'];
// 设置SMTP服务器。
$mail->SMTPAuth = true;
// 设置为“需要验证”
//$mail->Username=$this->setting['mail_username']; // 设置用户名和密码。
$mail->Username = $send_user;
// 设置用户名和密码。
$mail->Password = $this->setting['mail_password'];
// 发送邮件。
return $mail->Send();
}
示例8: email
function email($users, $subject, $body, $altbody)
{
global $CONFIG;
global $PAGES;
require_once $PAGES['autoload'];
$mail = new PHPMailer();
// $mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = $CONFIG['mailer']['email'];
$mail->Password = $CONFIG['mailer']['password'];
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom($CONFIG['mailer']['email'], 'Maid');
foreach ($users as $user) {
$mail->addAddress($user->email, $user->name);
}
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $altbody;
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
return false;
}
return true;
}
示例9: PFMailSend
public function PFMailSend($sender, $param)
{
$Aufgabe = ProtokollDetailAufgabeView::finder()->findByidtm_protokoll_detail($param->CallbackParameter);
$MailEmpfaenger = OrganisationRecord::finder()->findByPk($Aufgabe->idtm_organisation);
$mail = new PHPMailer();
$mail->From = "info@planlogiq.com";
$mail->FromName = "planlogIQ";
$mail->Host = "smtp.1und1.de";
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->IsSendmail();
//nur bei 1und1
$mail->Username = "info@planlogiq.com";
$mail->Password = "";
$mail->AddAddress(KommunikationRecord::finder()->find('idtm_organisation=? AND kom_ismain=1 AND kom_type = 3', $Aufgabe->idtm_organisation)->kom_information, $MailEmpfaenger->org_name);
$mail->Subject = $Aufgabe->prtdet_topic;
$HTMLMessage = "Sehr geehrte(r) Frau/Herr " . $MailEmpfaenger->org_name . ",<br/><br/>";
$HTMLMessage .= "die folgende Aufgabe wurde Ihnen zugeordnet:<br/>";
$HTMLMessage .= "<p><table><tr><td bgcolor='#efefef'>TOP Nr.:</td><td>" . $Aufgabe->idtm_protokoll_detail_group . " </td><td bgcolor='#efefef'>Thema: </td><td>" . utf8_decode($Aufgabe->prtdet_topic) . "</td></tr>";
$HTMLMessage .= "<tr><td bgcolor='#efefef'>Bis:</td><td colspan='3'><b>" . $Aufgabe->auf_tdate . "</b></td></tr></table>";
$HTMLMessage .= "<p style='background-color:#efefef'><hr/>" . utf8_decode($Aufgabe->prtdet_descr) . "</p>";
$HTMLMessage .= "<p style='background-color:#efefef'><hr/>" . utf8_decode($Aufgabe->auf_beschreibung) . "<hr/></p>";
$HTMLMessage .= "Bitte nicht Antworten! Diese Mail wurde automatisch generiert...";
$mail->MsgHTML($HTMLMessage);
if (!$mail->Send()) {
$this->PFMAILER->TEXT = "error sending the message";
} else {
$this->PFMAILER->TEXT = "..done..";
}
}
示例10: execute
protected function execute($arguments = array(), $options = array())
{
$con = $this->crearConexion();
try {
$record = Doctrine::getTable('EmailConfiguration')->findAll()->getFirst();
$config_mail = array('charset' => 'UTF-8', 'encryption' => $record->getSmtpSecurityType(), 'host' => $record->getSmtpHost(), 'port' => $record->getSmtpPort(), 'username' => $record->getSmtpUsername(), 'password' => $record->getSmtpPassword(), 'authentication' => $record->getSmtpAuthType());
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = $config_mail['charset'];
if ($config_mail['authentication'] == "login") {
$mail->SMTPAuth = true;
}
if ($config_mail['encryption'] == "tls") {
$mail->SMTPSecure = "tls";
}
if ($config_mail['encryption'] == "ssl") {
$mail->SMTPSecure = "ssl";
}
$mail->Host = $config_mail['host'];
$mail->Port = $config_mail['port'];
$mail->Username = $config_mail['username'];
$mail->Password = $config_mail['password'];
$mail->FromName = 'Mi company';
$mail->From = $config_mail['username'];
//email de remitente desde donde se env?a el correo
$mail->AddAddress($config_mail['username'], 'Destinatario');
//destinatario que va a recibir el correo
$mail->Subject = "confeccion de gafete";
/*Recojemos los datos del oficial*/
$dao = new EmployeeDao();
$employeeList = $dao->getEmployeeList();
foreach ($employeeList as $employee) {
if ($employee->getJoinedDate() != "") {
$datetime1 = new DateTime($employee->getJoinedDate());
$datetime2 = new DateTime(date('y-m-d', time()));
$formato = $datetime2->format('y-m-d');
$intervalo = $datetime1->diff($datetime2, true);
if ($intervalo->m == 2 && $intervalo->d == 0) {
$html = "Identificador: " . $employee->getEmployeeId() . "<br/>";
$html .= "ID: " . $employee->getOtherId() . "<br/>";
$html .= "Nombre : " . utf8_encode($employee->getFullName()) . "<br/>";
$html .= "Fecha Nac : " . $employee->getEmpBirthday() . "<br/>";
$sexo = $employee->getEmpGender() == 1 ? "Masculino" : "Femenino";
$html .= "Género : " . $sexo . "<br/>";
$html .= "Nacionalidad: " . $employee->getNationality() . "<br/>";
$html .= "Móvil: " . $employee->getEmpMobile() . "<br/>";
$mail->MsgHTML($html);
if (!$mail->Send()) {
$this->escribirYML('log_tareas', false, $mail->ErrorInfo . " Error al enviar el correo con los datos del empleado " . $employee->getFullName());
} else {
$this->escribirYML('log_tareas', true, "correo enviado con los datos del empleado " . $employee->getFullName());
}
}
}
}
Doctrine_Manager::getInstance()->closeConnection($con);
} catch (Exception $e) {
$this->escribirYML('log_tareas', false, $e->getMessage());
}
}
示例11: smtpmailer
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;
}
}
示例12: getMailer
/**
* Initialize PHPMailer
*
* @access public
* @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
* @return \PHPMailer
*/
protected function getMailer()
{
$mailer = new \PHPMailer();
$SMTPConfig = $this->getOption(self::CONFIG_SMTP_CONFIG);
$mailer->IsSMTP();
$mailer->SMTPKeepAlive = true;
$mailer->Debugoutput = 'error_log';
$mailer->Host = $SMTPConfig['SMTP_HOST'];
$mailer->Port = $SMTPConfig['SMTP_PORT'];
$mailer->Username = $SMTPConfig['SMTP_USER'];
$mailer->Password = $SMTPConfig['SMTP_PASS'];
if (isset($SMTPConfig['DEBUG_MODE'])) {
$mailer->SMTPDebug = $SMTPConfig['DEBUG_MODE'];
}
if (isset($SMTPConfig['Mailer'])) {
$mailer->Mailer = $SMTPConfig['Mailer'];
}
if (isset($SMTPConfig['SMTP_AUTH'])) {
$mailer->SMTPAuth = $SMTPConfig['SMTP_AUTH'];
}
if (isset($SMTPConfig['SMTP_SECURE'])) {
$mailer->SMTPSecure = $SMTPConfig['SMTP_SECURE'];
}
return $mailer;
}
示例13: sendEmail
public function sendEmail()
{
try {
$time = Manager::getSysTime();
$ipaddress = $_SERVER['REMOTE_ADDR'];
$mail = new PHPMailer();
$mail->IsSMTP();
// telling the class to use SMTP
$mail->Host = Manager::getConf('mailer.smtpServer');
// SMTP server
$mail->From = Manager::getConf('mailer.smtpFrom');
$mail->FromName = Manager::getConf('mailer.smtpFromName');
$mail->Subject = $this->data->assunto;
$mail->isHTML(false);
$mail->CharSet = 'utf-8';
$body = 'Enviada de: ' . $ipaddress . ' em ' . $time;
$mail->Body = $body . "\n" . $this->data->mensagem;
$mail->WordWrap = 100;
$mail->addAddress($this->data->email);
$ok = $mail->send();
$mail->clearAllRecipients();
$this->renderPrompt('information', 'Mensagem enviada com sucesso!');
} catch (Exception $e) {
$this->renderPrompt('error', $e->getMessage());
}
}
示例14: actionSendEmail
public function actionSendEmail()
{
$mail = new \PHPMailer();
//будем отравлять письмо через СМТП сервер
$mail->isSMTP();
//хост
$mail->Host = 'smtp.yandex.ru';
//требует ли СМТП сервер авторизацию/идентификацию
$mail->SMTPAuth = true;
// логин от вашей почты
$mail->Username = 'nik0lai';
// пароль от почтового ящика
$mail->Password = '3z2x4c9v0b1nfs';
//указываем способ шифромания сервера
$mail->SMTPSecure = 'ssl';
//указываем порт СМТП сервера
$mail->Port = '465';
//указываем кодировку для письма
$mail->CharSet = 'UTF-8';
//информация от кого отправлено письмо
$mail->From = 'nik0lai@yandex.ru';
$mail->FromName = 'Админ';
$mail->addAddress($_POST['mail']);
$mail->isHTML(true);
$mail->Subject = $_POST['title'];
$mail->Body = $_POST['text'];
if ($mail->send()) {
echo 'Письмо отправлено';
} else {
echo 'Письмо не может быть отправлено. ';
echo 'Ошибка: ' . $mail->ErrorInfo;
}
}
示例15: send_email
function send_email($send_to, $subject, $body, $from_name, $from_email)
{
if (!empty($send_to) && !empty($subject) && !empty($body)) {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "universe1.southbankdomains.com";
$mail->Port = 465;
$mail->Priority = 1;
$mail->FromName = $from_name;
$mail->Username = EMAIL_ADDRESS;
$mail->Password = EMAIL_PASS;
$mail->From = $from_email;
$mail->AddAddress($send_to);
// for publishing
$mail->Subject = $subject;
$mail->Body = $body;
$mail->WordWrap = 50;
if (!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
//echo 'Message has been sent.';
}
} else {
echo "All email components are required.";
}
}