本文整理汇总了PHP中PHPMailer::Send方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::Send方法的具体用法?PHP PHPMailer::Send怎么用?PHP PHPMailer::Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emailBlast
function emailBlast($from, $fromname, $subject, $message, $emails, $bouncereturn, $debug = 0)
{
$_SMTPHOST = 'www.startuplist.sg';
$_SMTPUSER = 'mailer@startuplist.sg';
$_SMTPPASS = 'mailer';
$mail = new PHPMailer();
$mail->IsSMTP();
// set mailer to use SMTP
//$mail->IsQmail();
$mail->Host = $_SMTPHOST;
// specify main and backup server
$mail->SMTPAuth = true;
// turn on SMTP authentication
$mail->Username = $_SMTPUSER;
// SMTP username
$mail->Password = $_SMTPPASS;
// SMTP password
$mail->Sender = $bouncereturn;
$mail->From = $from;
$mail->FromName = $fromname;
if ($debug) {
echo "From: {$fromname} <", $from, "><br>";
echo "Reply-To: ", $from, "<br>";
echo "Return Path: ", $bouncereturn, "<br>";
}
$t = count($emails);
for ($i = 0; $i < $t; $i++) {
//print_r($emails[$i]);
//$mail->AddAddress("josh@example.net", "Josh Adams");
//$mail->AddReplyTo("josh@example.net", "Josh Adams");
$mail->AddAddress($emails[$i]['email'], $emails[$i]['name']);
$mail->AddReplyTo($from, $fromname);
//$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
//western european encoding
//$mail->Subject = "=?iso-8859-1?q?".$subject."?=";
//$mail->Subject = "=?utf-8?q?".$this->subject."?=";
$mail->Subject = $subject;
$emailtext = $message;
$mail->Body = $emailtext;
$mail->AltBody = strip_tags($emailtext);
if ($debug) {
echo "Sending to <b>" . $emails[$i]['email'] . "</b> ... ", $mail->Send(), "<br>";
echo $mail->ErrorInfo;
} else {
$mail->Send();
}
$mail->ClearAddresses();
}
}
示例2: handle
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;
}
示例3: 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;
}
}
示例4: 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();
}
}
示例5: send
/**
* @param bool $immediately
* @return bool
* @throws \phpmailerException
*/
public function send($immediately = true)
{
$salida = $this->mail->Send();
$this->mail->clearAddresses();
$this->mail->clearAttachments();
return $salida;
}
示例6: Send
/**
* Envia a mensagem
* @return boolean
* @throws Exception
*/
public function Send()
{
if (!$this->SMTP->Send()) {
throw new Exception($this->SMTP->ErrorInfo);
}
return true;
}
示例7: order
public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $adminNotifyTplID = 'admin_purchase_notify', $customerNotifyTplID = 'user_purchase_notify')
{
global $db;
$user = \cf\User::getLoggedIn();
$productList = '';
$products = \cf\api\cart\getList();
if (!array_key_exists('contents', $products) || !count($products['contents'])) {
return false;
}
$tpl = new MailTemplate('order');
execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :contents)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'contents' => $tpl->parseBody(array('cart' => $products))));
$orderId = $db->lastInsertId();
$msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => $products['total'], 'products' => $products['contents']);
\cf\api\cart\clear();
$mail = new \PHPMailer();
$mail->CharSet = 'UTF-8';
if ($adminNotifyTplID) {
$tpl = new MailTemplate($adminNotifyTplID);
$mail->Subject = $tpl->parseSubject($msgParams);
$mail->MsgHTML($tpl->parseBody($msgParams));
foreach ($tpl->recipients() as $address) {
$mail->addAddress($address);
}
$mail->Send();
}
$mail->clearAddresses();
if ($customerNotifyTplID && $email) {
$tpl = new MailTemplate($customerNotifyTplID);
$mail->Subject = $tpl->parseSubject($msgParams);
$mail->MsgHTML($tpl->parseBody($msgParams));
$mail->addAddress($email);
$mail->Send();
}
return $orderId;
}
示例8: send
public function send($subject, $body, $from, $fromName)
{
$this->mail->From = $from;
$this->mail->FromName = $fromName;
$this->mail->Subject = $subject;
$this->mail->Body = $body;
return $this->mail->Send();
}
示例9: send
public function send(Mail $mail)
{
$converter = new MailToPHPMailerConverter();
$this->mailer = $converter->convert($mail);
$this->set_send_settings($this->mailer);
try {
$this->mailer->Send();
} catch (Exception $ex) {
throw new IOException('Mail couldn\'t be sent: ' . $ex->getMessage());
}
}
示例10: smtpmailer
function smtpmailer($para, $de, $de_nome, $assunto, $corpo, $tipo)
{
if ($tipo == 0) {
include "./phpmailer/class.phpmailer.php";
} else {
include "../phpmailer/class.phpmailer.php";
}
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "gerenciador.tgsi@gmail.com";
$mail->Password = "testegerenciador";
$mail->SetFrom($de, $de_nome);
$mail->Subject = $assunto;
$mail->Body = $corpo;
$mail->AddAddress($para);
if (!$mail->Send()) {
$erro = 'Erro: ' . $mail->ErrorInfo;
return $erro;
} else {
return 'Informações enviadas para o seu e-mail!';
}
}
示例11: PHPMailer
function send_emailMailer($recipient, $sender, $name, $subject, $message)
{
//require_once("PHPMailer/class.phpmailer.php");
include "PHPMailer/class.phpmailer.php";
include "PHPMailer/class.smtp.php";
$CI =& get_instance();
$mail = new PHPMailer();
$mail->IsSMTP();
// telling the class to use SMTP
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->Host = $CI->config->item('smtp_host');
// sets the SMTP server
$mail->Port = 25;
// set the SMTP port for the GMAIL server
$mail->Username = $CI->config->item('smtp_username');
// SMTP account username
$mail->Password = $CI->config->item('smtp_password');
// SMTP account password
$mail->SetFrom($sender, $name);
$mail->AddReplyTo($sender, $name);
$mail->Subject = $subject;
$mail->AltBody = "Reset email";
// optional, comment out and test
$mail->MsgHTML($message);
$mail->AddAddress($recipient, '');
if (!$mail->Send()) {
return array("error" => "Mailer Error: " . $mail->ErrorInfo);
} else {
return true;
}
}
示例12: PHPMailer
function PHPMailer($xmlDoc, $name, $email, $subject, $message)
{
require "class.phpmailer.php";
$parentNode = $xmlDoc->createElement('status');
$mail = new PHPMailer();
$mail->IsSMTP();
// telling the class to use SMTP
$mail->SMTPAuth = true;
// SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
// SMTP server
$mail->Port = 587;
// SMTP Port
$mail->Username = "jared314@gmail.com";
// SMTP account username
$mail->Password = "lnvfcqnotxajucwy";
// SMTP account password
$mail->SetFrom('jared314@gmail.com');
// FROM
$mail->AddAddress('jared314@gmail.com', 'Jared');
// recipient email
$mail->Subject = 'Contact Form Submission';
// email subject
$mail->Body = 'FROM: ' . $name . " " . $email . " Subject: " . $subject . " Message: " . $message;
if (!$mail->Send()) {
$statusNode = $xmlDoc->createElement('mail_status', 0);
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
$statusNode = $xmlDoc->createElement('mail_status', 1);
}
$parentNode->appendChild($statusNode);
return $parent;
}
示例13: form
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);
}
}
示例14: Send_Mail
function Send_Mail($to, $subject, $body)
{
require 'class.phpmailer.php';
$from = "from@gmail.com";
$mail = new PHPMailer();
$mail->IsSMTP(true);
// use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->Host = "tls://smtp.gmail.com";
// Amazon SES server, note "tls://" protocol
$mail->Port = 465;
// set the SMTP port
$mail->Username = "sassyladies.csse@gmail.com";
// SMTP username
$mail->Password = "sassyladies";
// SMTP password
$mail->SetFrom($from, 'Find Your Perfect Roommate');
$mail->AddReplyTo($from, 'Reply to Find Your Perfect Roommate');
$mail->Subject = $subject;
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $to);
$mail->Send();
}
示例15: 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());
}
}