本文整理汇总了PHP中phpmailer::AddAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP phpmailer::AddAttachment方法的具体用法?PHP phpmailer::AddAttachment怎么用?PHP phpmailer::AddAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpmailer
的用法示例。
在下文中一共展示了phpmailer::AddAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send mail, similar to PHP's mail
*
* A true return value does not automatically mean that the user received the
* email successfully. It just only means that the method used was able to
* process the request without any errors.
*
* The default content type is 'text/plain' which does not allow using HTML.
*/
public static function send($from_email, $from_name, array $to, $subject, $message, array $cc = array(), array $bcc = array(), array $attachments = array())
{
$mailer = new phpmailer();
$content_type = 'text/plain';
$mailer->ContentType = $content_type;
$mailer->Hostname = \lib\conf\constants::$domain;
$mailer->IsMail();
$mailer->IsHTML(false);
$mailer->From = $from_email;
$mailer->FromName = $from_name;
// add recipients
foreach ((array) $to as $recipient_name => $recipient_email) {
$mailer->AddAddress(trim($recipient_email), trim($recipient_name));
}
// Add any CC and BCC recipients
foreach ($cc as $recipient_name => $recipient_email) {
$mailer->AddCc(trim($recipient_email), trim($recipient_name));
}
foreach ($bcc as $recipient_name => $recipient_email) {
$mailer->AddBcc(trim($recipient_email), trim($recipient_name));
}
// Set mail's subject and body
$mailer->Subject = $subject;
$mailer->Body = $message;
foreach ($attachments as $attachment) {
$mailer->AddAttachment($attachment);
}
// Send!
$result = $mailer->Send();
return $result;
}
示例2: email_to_user
//.........这里部分代码省略.........
echo '<pre>' . "\n";
$mail->SMTPDebug = true;
}
$mail->Host = $CFG->smtphosts;
// specify main and backup servers
if ($CFG->smtpuser) {
// Use SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = $CFG->smtpuser;
$mail->Password = $CFG->smtppass;
}
}
}
/* not here yet, leave it in just in case.
// make up an email address for handling bounces
if (!empty($CFG->handlebounces)) {
$modargs = 'B'.base64_encode(pack('V',$user->ident)).substr(md5($user->email),0,16);
$mail->Sender = generate_email_processing_address(0,$modargs);
}
else {
$mail->Sender = $CFG->sysadminemail;
}
*/
$mail->Sender = $CFG->sysadminemail;
// for elgg. delete if we change the above.
// TODO add a preference for maildisplay
if (is_string($from)) {
// So we can pass whatever we want if there is need
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from;
} else {
if (empty($from)) {
// make stuff up
$mail->From = $CFG->sysadminemail;
$mail->FromName = $CFG->sitename . ' ' . __gettext('Administrator');
} else {
if ($usetrueaddress and !empty($from->maildisplay)) {
$mail->From = $from->email;
$mail->FromName = $from->name;
} else {
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from->name;
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, __gettext('Do not reply'));
}
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = $textlib->substr(stripslashes($subject), 0, 900);
$mail->AddAddress($user->email, $user->name);
$mail->WordWrap = 79;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
//TODO add a user preference for this. right now just send plaintext
$user->mailformat = 0;
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($CFG->sysadminemail, $CFG->sitename . ' ' . __gettext('Administrator'));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($attachment, $attachname, 'base64', $mimetype);
}
}
if ($mail->Send()) {
// set_send_count($user); // later
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
return false;
}
}
示例3: sendmail
function sendmail($subject, $mailcontent, $receiver, $receivername, $attachment = "")
{
if (strpos($_SERVER['HTTP_HOST'], "localhost")) {
return false;
}
$mail = new phpmailer();
$mail->IsSMTP();
$mail->Host = "mail.pepool.com";
$mail->Port = 2525;
$mail->SMTPAuth = true;
$mail->Username = "info+pepool.com";
// Write SMTP username in ""
$mail->Password = "*VTWqNzPNKlut";
$mail->Mailer = "smtp";
$mail->IsHTML(true);
$mail->ClearAddresses();
$mail->From = "info@pepool.com";
$mail->FromName = "pepool";
$mail->Subject = $subject;
$mail->Body = $mailcontent;
$mail->AddAddress($receiver, $receivername);
if ($attachment != '') {
$mail->AddAttachment($attachment);
}
$suc = $mail->Send();
return $suc > 0;
}
示例4: sendmail
public function sendmail($from, $to, $subject, $body, $altbody = null, $options = null, $attachments = null, $html = false)
{
if (!is_array($from)) {
$from = array($from, $from);
}
$mail = new phpmailer();
$mail->PluginDir = 'M/lib/phpmailer/';
if ($this->getConfig('smtp')) {
$mail->isSMTP();
$mail->Host = $this->getConfig('smtphost');
if ($this->getConfig('smtpusername')) {
$mail->SMTPAuth = true;
$mail->Port = $this->getConfig('smtpport') ? $this->getConfig('smtpport') : 25;
$mail->SMTPDebug = $this->smtpdebug;
$mail->Username = $this->getConfig('smtpusername');
$mail->Password = $this->getConfig('smtppassword');
}
}
$mail->CharSet = $this->getConfig('encoding');
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $note . $body;
$mail->AltBody = $altbody;
if (!is_array($from)) {
$from = array($from, $from);
}
$mail->From = $from[0];
$mail->FromName = $from[1];
if (key_exists('reply-to', $options)) {
$mail->AddReplyTo($options['reply-to']);
unset($options['reply-to']);
}
if (key_exists('Sender', $options)) {
$mail->Sender = $options['Sender'];
}
if (null != $attachments) {
if (!is_array($attachments)) {
$attachments = array($attachments);
}
foreach ($attachments as $k => $v) {
if (!$mail->AddAttachment($v, basename($v))) {
trigger_error("Attachment {$v} could not be added");
}
}
}
$mail->IsHTML($html);
$result = $mail->send();
}
示例5: sprintf
$mail->FromName = "Backup Bolão";
$mail->Hostname = "smtp.netsite.com.br";
$mail->Host = "smtp.netsite.com.br";
// $mail->SMTPDebug = 2;
$mail->Username = "alencarmo";
$mail->Password = "12345678";
$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) {
echo "<tr><td>There has been a mail error sending to " . $mail->ErrorInfo . "<br></td></tr>";
}
$mail->ClearAddresses();
$mail->ClearAttachments();
mysql_free_result($result);
示例6: sendMail
function sendMail($fileIN, $fileOUT, $naviera)
{
//$razonSocial = "MOPSA, S.A. de C.V.";
$dominio = "www.almartcon.com";
$att = "Robot";
$fileINOnlyName = str_replace("../ediCodeco/", "", $fileIN);
$fileOUTOnlyName = str_replace("../ediCodeco/", "", $fileOUT);
// ------------------------------------------------
// CONFIGURAR EMAIL.
// ------------------------------------------------
//Definimos las propiedades y llamamos a los métodos
//correspondientes del objeto mail
//Con PluginDir le indicamos a la clase phpmailer donde se
//encuentra la clase smtp que como he comentado al principio de
//este ejemplo va a estar en el subdirectorio includes
$mail = new phpmailer();
$mail->Priority = 0;
// Se declara la prioridad del mensaje.
$mail->PluginDir = "../include/";
$mail->Mailer = "smtp";
$mail->Port = 26;
// Configurar la cuenta de correo.
$mail->Host = "mail.nesoftware.net";
$mail->SMTPAuth = true;
$mail->Username = "robot-almartcon@nesoftware.net";
$mail->Password = "UF+)8&;-(6Oy";
$mail->From = "robot-almartcon@nesoftware.net";
$mail->FromName = "Robot ALMARTCON";
//El valor por defecto 10 de Timeout es un poco escaso dado que voy a usar
//una cuenta gratuita, por tanto lo pongo a 30
//$mail->Timeout=10;
$mail->Timeout = 10;
// --------------------
// FORMATO HTML
// --------------------
$mail->Body = "\n <html>\n <body>\n <font size=\"3\"><b>EDI-CODECO</b></font>\n <hr>\n <p>\n A quien corresponda : <br>\n <br>\n El sistema Web ({$dominio}) ha detectado en automático nuevas entradas y salidas mismas que fueron codificadas en formato\n EDI-CODECO para reconocimiento informático de otros sistemas navieros.\n <br>\n <b>Naviera :</b> {$naviera} <br>\n <b>Archivo GateIN :</b> {$fileINOnlyName} <br>\n <b>Archivo GateOUT:</b> {$fileOUTOnlyName} <br>\n <br>\n <i>\n Att. {$att} <br>\n </i>\n <p>\n <hr>\n <font color=\"red\" size=\"2\">\n <i>Este es un correo de envio automático generado por nuestro sistema {$dominio}, por favor no responda este email.<br></i>\n </font>\n <br>\n <br>\n <br>\n </body>\n </html>\n\n ";
// -------------------------------------------------------
// FORMATO TEXTO
// Definimos AltBody por si el destinatario del correo
// no admite email con formato html
// -------------------------------------------------------
$mail->AltBody = "\n =====================================================================\n ";
// Nota :
// La direccion PARA solo se puede manejar 1.
// Las direcciones CC puede manejar N correos.
// -------------
// Destinatarios
// -------------
$mail->ClearAddresses();
// ------------------------------------------------
// TO : Luis Felipe Pineda Mendoza <traluispineda@gmail.com>
$mail->AddAddress("traluispineda@gmail.com");
//$mail->AddCC( "nestor@nesoftware.net" );
//$mail->AddCC( "lemuel@nesoftware.net" );
// Subject :
$mail->Subject = "[EDI-CODECO] {$naviera} ";
//Incluir Attach.
$mail->AddAttachment($fileIN, $fileINOnlyName);
$mail->AddAttachment($fileOUT, $fileOUTOnlyName);
// Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true
//if( is_array($arrEdiFile) ){
$exito = $mail->Send();
/*
// PARA INTAR REENVIARLO
//Si el mensaje no ha podido ser enviado se realizaran 4 intentos mas como mucho
//para intentar enviar el mensaje, cada intento se hara 5 segundos despues
//del anterior, para ello se usa la funcion sleep
$intentos=1;
while ((!$exito) && ($intentos < 5)) {
sleep(5);
$exito = $mail->Send();
$intentos=$intentos+1;
}
*/
if (!$exito) {
echo "[ <font color=red><b>Problema de envio</b></font> ] " . $mail->ErrorInfo . "<br>";
} else {
echo "[ <font color=green><b>OK, E-Mail enviado.</b></font> ] <br>";
}
if (file_exists($fileIN)) {
unlink($fileIN);
}
if (file_exists($fileOUT)) {
unlink($fileOUT);
}
}
示例7: updateOrder
//.........这里部分代码省略.........
// 1 (for Monday) through 7 (for Sunday)
$dotwNumber = date('N', mktime(1, 1, 1, $arrMatch[2], $arrMatch[1], $arrMatch[3]));
$dotwName = $_ARRAYLANG['TXT_EGOV_DAYNAME_' . $dotwNumber];
$value = "{$dotwName}, {$value}";
}
$FormValue4Mail .= html_entity_decode($name) . ': ' . html_entity_decode($value) . "\n";
}
// Bestelleingang-Benachrichtigung || Mail f�r den Administrator
$recipient = self::GetProduktValue('product_target_email', $product_id);
if (empty($recipient)) {
$recipient = self::GetSettings('set_orderentry_recipient');
}
if (!empty($recipient)) {
$SubjectText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), self::GetSettings('set_orderentry_subject'));
$SubjectText = html_entity_decode($SubjectText);
$BodyText = str_replace('[[ORDER_VALUE]]', $FormValue4Mail, self::GetSettings('set_orderentry_email'));
$BodyText = html_entity_decode($BodyText);
$replyAddress = self::GetEmailAdress($order_id);
if (empty($replyAddress)) {
$replyAddress = self::GetSettings('set_orderentry_sender');
}
if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
$objMail = new \phpmailer();
if (!empty($_CONFIG['coreSmtpServer'])) {
if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
$objMail->IsSMTP();
$objMail->Host = $arrSmtp['hostname'];
$objMail->Port = $arrSmtp['port'];
$objMail->SMTPAuth = true;
$objMail->Username = $arrSmtp['username'];
$objMail->Password = $arrSmtp['password'];
}
}
$objMail->CharSet = CONTREXX_CHARSET;
$from = self::GetSettings('set_orderentry_sender');
$fromName = self::GetSettings('set_orderentry_name');
$objMail->AddReplyTo($replyAddress);
$objMail->SetFrom($from, $fromName);
$objMail->Subject = $SubjectText;
$objMail->Priority = 3;
$objMail->IsHTML(false);
$objMail->Body = $BodyText;
$objMail->AddAddress($recipient);
$objMail->Send();
}
}
// Update 29.10.2006 Statusmail automatisch abschicken || Produktdatei
if (self::GetProduktValue('product_electro', $product_id) == 1 || self::GetProduktValue('product_autostatus', $product_id) == 1) {
self::updateOrderStatus($order_id, $newStatus);
$TargetMail = self::GetEmailAdress($order_id);
if ($TargetMail != '') {
$FromEmail = self::GetProduktValue('product_sender_email', $product_id);
if ($FromEmail == '') {
$FromEmail = self::GetSettings('set_sender_email');
}
$FromName = self::GetProduktValue('product_sender_name', $product_id);
if ($FromName == '') {
$FromName = self::GetSettings('set_sender_name');
}
$SubjectDB = self::GetProduktValue('product_target_subject', $product_id);
if ($SubjectDB == '') {
$SubjectDB = self::GetSettings('set_state_subject');
}
$SubjectText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), $SubjectDB);
$SubjectText = html_entity_decode($SubjectText);
$BodyDB = self::GetProduktValue('product_target_body', $product_id);
if ($BodyDB == '') {
$BodyDB = self::GetSettings('set_state_email');
}
$BodyText = str_replace('[[ORDER_VALUE]]', $FormValue4Mail, $BodyDB);
$BodyText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(self::GetProduktValue('product_name', $product_id)), $BodyText);
$BodyText = html_entity_decode($BodyText);
if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
$objMail = new \phpmailer();
if ($_CONFIG['coreSmtpServer'] > 0) {
if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
$objMail->IsSMTP();
$objMail->Host = $arrSmtp['hostname'];
$objMail->Port = $arrSmtp['port'];
$objMail->SMTPAuth = true;
$objMail->Username = $arrSmtp['username'];
$objMail->Password = $arrSmtp['password'];
}
}
$objMail->CharSet = CONTREXX_CHARSET;
$objMail->SetFrom($FromEmail, $FromName);
$objMail->Subject = $SubjectText;
$objMail->Priority = 3;
$objMail->IsHTML(false);
$objMail->Body = $BodyText;
$objMail->AddAddress($TargetMail);
if (self::GetProduktValue('product_electro', $product_id) == 1) {
$objMail->AddAttachment(ASCMS_PATH . self::GetProduktValue('product_file', $product_id));
}
$objMail->Send();
}
}
}
return '';
}
示例8: send
//.........这里部分代码省略.........
//DBG::log("MailTemplate::send(): Substituted: ".var_export($arrTemplate, true));
//echo("MailTemplate::send(): Substituted:<br /><pre>".nl2br(htmlentities(var_export($arrTemplate, true), ENT_QUOTES, CONTREXX_CHARSET))."</PRE><hr />");
//die();//return true;
// Use defaults for missing mandatory fields
// if (empty($arrTemplate['sender']))
// $arrTemplate['sender'] = $_CONFIG['coreAdminName'];
if (empty($arrTemplate['from'])) {
\DBG::log("MailTemplate::send(): INFO: Empty 'from:', falling back to config");
$arrTemplate['from'] = $_CONFIG['coreAdminEmail'];
}
if (empty($arrTemplate['to'])) {
\DBG::log("MailTemplate::send(): INFO: Empty 'to:', falling back to config");
$arrTemplate['to'] = $_CONFIG['coreAdminEmail'];
}
// if (empty($arrTemplate['subject']))
// $arrTemplate['subject'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_SUBJECT'];
// if (empty($arrTemplate['message']))
// $arrTemplate['message'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_MESSAGE'];
$objMail->FromName = $arrTemplate['sender'];
$objMail->From = $arrTemplate['from'];
$objMail->Subject = $arrTemplate['subject'];
$objMail->CharSet = CONTREXX_CHARSET;
// $objMail->IsHTML(false);
if ($arrTemplate['html']) {
$objMail->IsHTML(true);
$objMail->Body = $arrTemplate['message_html'];
$objMail->AltBody = $arrTemplate['message'];
} else {
$objMail->Body = $arrTemplate['message'];
}
foreach (preg_split('/\\s*,\\s*/', $arrTemplate['reply'], null, PREG_SPLIT_NO_EMPTY) as $address) {
$objMail->AddReplyTo($address);
}
// foreach (preg_split('/\s*,\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $address) {
// $objMail->AddAddress($address);
// }
foreach (preg_split('/\\s*,\\s*/', $arrTemplate['cc'], null, PREG_SPLIT_NO_EMPTY) as $address) {
$objMail->AddCC($address);
}
foreach (preg_split('/\\s*,\\s*/', $arrTemplate['bcc'], null, PREG_SPLIT_NO_EMPTY) as $address) {
$objMail->AddBCC($address);
}
// Applicable to attachments stored with the MailTemplate only!
$arrTemplate['attachments'] = self::attachmentsToArray($arrTemplate['attachments']);
//DBG::log("MailTemplate::send(): Template Attachments: ".var_export($arrTemplate['attachments'], true));
// Now the MailTemplates' attachments index is guaranteed to
// contain an array.
// Add attachments from the parameter array, if any.
if (isset($arrField['attachments']) && is_array($arrField['attachments'])) {
foreach ($arrField['attachments'] as $path => $name) {
// if (empty($path)) $path = $name;
// if (empty($name)) $name = basename($path);
$arrTemplate['attachments'][$path] = $name;
//DBG::log("MailTemplate::send(): Added Field Attachment: $path / $name");
}
}
//DBG::log("MailTemplate::send(): All Attachments: ".var_export($arrTemplate['attachments'], true));
foreach ($arrTemplate['attachments'] as $path => $name) {
if (is_numeric($path)) {
$path = $name;
}
$objMail->AddAttachment(ASCMS_DOCUMENT_ROOT . '/' . $path, $name);
}
$arrTemplate['inline'] = self::attachmentsToArray($arrTemplate['inline']);
if ($arrTemplate['inline']) {
$arrTemplate['html'] = true;
}
foreach ($arrTemplate['inline'] as $path => $name) {
if (is_numeric($path)) {
$path = $name;
}
$objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name);
}
if (isset($arrField['inline']) && is_array($arrField['inline'])) {
$arrTemplate['html'] = true;
foreach ($arrField['inline'] as $path => $name) {
if (is_numeric($path)) {
$path = $name;
}
$objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name);
}
}
//die("MailTemplate::send(): Attachments and inlines<br />".var_export($objMail, true));
$objMail->CharSet = CONTREXX_CHARSET;
$objMail->IsHTML($arrTemplate['html']);
//DBG::log("MailTemplate::send(): Sending: ".nl2br(htmlentities(var_export($objMail, true), ENT_QUOTES, CONTREXX_CHARSET))."<br />Sending...<hr />");
$result = true;
foreach (preg_split('/\\s*;\\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $addresses) {
$objMail->ClearAddresses();
foreach (preg_split('/\\s*[,]\\s*/', $addresses, null, PREG_SPLIT_NO_EMPTY) as $address) {
$objMail->AddAddress($address);
}
//DBG::log("MailTemplate::send(): ".var_export($objMail, true));
// TODO: Comment for test only!
$result &= $objMail->Send();
// TODO: $objMail->Send() seems to sometimes return true on localhost where
// sending the mail is actually impossible. Dunno why.
}
return $result;
}
示例9: email_to_user
//.........这里部分代码省略.........
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, get_string('noreplyname'));
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = substr(stripslashes($subject), 0, 900);
$mail->AddAddress($user->email, fullname($user));
$mail->WordWrap = 79;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($supportuser->email, fullname($supportuser, true));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($CFG->dataroot . '/' . $attachment, $attachname, 'base64', $mimetype);
}
}
/// If we are running under Unicode and sitemailcharset or allowusermailcharset are set, convert the email
/// encoding to the specified one
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
/// Set it to site mail charset
$charset = $CFG->sitemailcharset;
/// Overwrite it with the user mail charset
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
/// If it has changed, convert all the necessary strings
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
/// Save the new mail charset
$mail->CharSet = $charset;
/// And convert some strings
$mail->FromName = $textlib->convert($mail->FromName, 'utf-8', $mail->CharSet);
//From Name
foreach ($mail->ReplyTo as $key => $rt) {
//ReplyTo Names
$mail->ReplyTo[$key][1] = $textlib->convert($rt, 'utf-8', $mail->CharSet);
}
$mail->Subject = $textlib->convert($mail->Subject, 'utf-8', $mail->CharSet);
//Subject
foreach ($mail->to as $key => $to) {
$mail->to[$key][1] = $textlib->convert($to, 'utf-8', $mail->CharSet);
//To Names
}
$mail->Body = $textlib->convert($mail->Body, 'utf-8', $mail->CharSet);
//Body
$mail->AltBody = $textlib->convert($mail->AltBody, 'utf-8', $mail->CharSet);
//Subject
}
}
if ($mail->Send()) {
set_send_count($user);
$mail->IsSMTP();
// use SMTP directly
if (!empty($CFG->debugsmtp)) {
echo '</pre>';
}
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
add_to_log(SITEID, 'library', 'mailer', $FULLME, 'ERROR: ' . $mail->ErrorInfo);
if (!empty($CFG->debugsmtp)) {
echo '</pre>';
}
return false;
}
}
示例10: SendEmail
/**
* Send the email
* @param int $UserID
* @param int $NewsletterID
* @param string $TargetEmail
* @param string $type
*/
function SendEmail($UserID, $NewsletterID, $TargetEmail, $TmpEntry, $type = self::USER_TYPE_NEWSLETTER)
{
global $objDatabase, $_ARRAYLANG, $_DBCONFIG;
require_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php';
$newsletterValues = $this->getNewsletterValues($NewsletterID);
if ($newsletterValues !== false) {
$subject = $newsletterValues['subject'];
$template = $newsletterValues['template'];
$content = $newsletterValues['content'];
$priority = $newsletterValues['priority'];
$sender_email = $newsletterValues['sender_email'];
$sender_name = $newsletterValues['sender_name'];
$return_path = $newsletterValues['return_path'];
$count = $newsletterValues['count'];
$smtpAccount = $newsletterValues['smtp_server'];
}
$break = $this->getSetting('txt_break_after');
$break = intval($break) == 0 ? 80 : $break;
$HTML_TemplateSource = $this->GetTemplateSource($template, 'html');
// TODO: Unused
// $TEXT_TemplateSource = $this->GetTemplateSource($template, 'text');
$newsletterUserData = $this->getNewsletterUserData($UserID, $type);
$testDelivery = !$TmpEntry;
$NewsletterBody_HTML = $this->ParseNewsletter($subject, $content, $HTML_TemplateSource, '', $TargetEmail, $newsletterUserData, $NewsletterID, $testDelivery);
\LinkGenerator::parseTemplate($NewsletterBody_HTML, true);
$NewsletterBody_TEXT = $this->ParseNewsletter('', '', '', 'text', '', $newsletterUserData, $NewsletterID, $testDelivery);
\LinkGenerator::parseTemplate($NewsletterBody_TEXT, true);
$mail = new \phpmailer();
if ($smtpAccount > 0) {
if (($arrSmtp = \SmtpSettings::getSmtpAccount($smtpAccount)) !== false) {
$mail->IsSMTP();
$mail->Host = $arrSmtp['hostname'];
$mail->Port = $arrSmtp['port'];
$mail->SMTPAuth = $arrSmtp['username'] == '-' ? false : true;
$mail->Username = $arrSmtp['username'];
$mail->Password = $arrSmtp['password'];
}
}
$mail->CharSet = CONTREXX_CHARSET;
$mail->AddReplyTo($return_path);
$mail->SetFrom($sender_email, $sender_name);
$mail->Subject = $subject;
$mail->Priority = $priority;
$mail->Body = $NewsletterBody_HTML;
$mail->AltBody = $NewsletterBody_TEXT;
$queryATT = "SELECT newsletter, file_name FROM " . DBPREFIX . "module_newsletter_attachment where newsletter=" . $NewsletterID . "";
$objResultATT = $objDatabase->Execute($queryATT);
if ($objResultATT !== false) {
while (!$objResultATT->EOF) {
$mail->AddAttachment(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesAttachPath() . "/" . $objResultATT->fields['file_name'], $objResultATT->fields['file_name']);
$objResultATT->MoveNext();
}
}
$mail->AddAddress($TargetEmail);
if ($UserID) {
// mark recipient as in-action to prevent multiple tries of sending the newsletter to the same recipient
$query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=2 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . " AND sendt=0";
if ($objDatabase->Execute($query) === false || $objDatabase->Affected_Rows() == 0) {
return $count;
}
}
if ($mail->Send()) {
// && $UserID == 0) {
$ReturnVar = $count++;
if ($TmpEntry == 1) {
// Insert TMP-ENTRY Sended Email & Count++
$query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=1 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . "";
if ($objDatabase->Execute($query) === false) {
if ($_DBCONFIG['dbType'] == 'mysql' && $objDatabase->ErrorNo() == 2006) {
@$objDatabase->Connect($_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], $_DBCONFIG['database'], true);
if ($objDatabase->Execute($query) === false) {
return false;
}
}
}
$objDatabase->Execute("\n UPDATE " . DBPREFIX . "module_newsletter\n SET count=count+1\n WHERE id={$NewsletterID}");
$queryCheck = "SELECT 1 FROM " . DBPREFIX . "module_newsletter_tmp_sending where newsletter=" . $NewsletterID . " and sendt=0";
$objResultCheck = $objDatabase->SelectLimit($queryCheck, 1);
if ($objResultCheck->RecordCount() == 0) {
$objDatabase->Execute("\n UPDATE " . DBPREFIX . "module_newsletter\n SET status=1\n WHERE id={$NewsletterID}");
}
}
/*elseif ($mail->error_count) {
if (strstr($mail->ErrorInfo, 'authenticate')) {
self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)).'<br />';
$ReturnVar = false;
}
} */
} else {
$performRejectedMailOperation = false;
if (strstr($mail->ErrorInfo, 'authenticate')) {
// -> smtp error
self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)) . '<br />';
//.........这里部分代码省略.........
示例11: sendMail
//.........这里部分代码省略.........
$objTemplate->parse('field_' . $fieldId);
} elseif ($objTemplate->blockExists('form_field')) {
// parse regular field template block
$objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue));
$objTemplate->parse('form_field');
}
} elseif ($objTemplate->blockExists('field_' . $fieldId)) {
// hide field specific template block, if present
$objTemplate->hideBlock('field_' . $fieldId);
}
}
// parse plaintext body
$tabCount = $maxlength - strlen($fieldLabel);
$tabs = $tabCount == 0 ? 1 : $tabCount + 1;
// TODO: what is this all about? - $value is undefined
if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') {
$value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID];
}
if (in_array($fieldId, $textAreaKeys)) {
// we're dealing with a textarea, don't indent value
$plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n";
} else {
$plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n";
}
}
$arrSettings = $this->getSettings();
// TODO: this is some fixed plaintext message data -> must be ported to html body
$message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n";
if ($arrSettings['fieldMetaDate']) {
$message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n";
}
$message .= $plaintextBody . "\n\n";
if ($arrSettings['fieldMetaHost']) {
$message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n";
}
if ($arrSettings['fieldMetaIP']) {
$message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n";
}
if ($arrSettings['fieldMetaLang']) {
$message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n";
}
$message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n";
if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
$objMail = new \phpmailer();
if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
$objMail->IsSMTP();
$objMail->Host = $arrSmtp['hostname'];
$objMail->Port = $arrSmtp['port'];
$objMail->SMTPAuth = true;
$objMail->Username = $arrSmtp['username'];
$objMail->Password = $arrSmtp['password'];
}
}
$objMail->CharSet = CONTREXX_CHARSET;
$objMail->From = $_CONFIG['coreAdminEmail'];
$objMail->FromName = $senderName;
if (!empty($replyAddress)) {
$objMail->AddReplyTo($replyAddress);
if ($arrFormData['sendCopy'] == 1) {
$objMail->AddAddress($replyAddress);
}
if ($arrFormData['useEmailOfSender'] == 1) {
$objMail->From = $replyAddress;
}
}
$objMail->Subject = $arrFormData['subject'];
if ($isHtml) {
$objMail->Body = $objTemplate->get();
$objMail->AltBody = $message;
} else {
$objMail->IsHTML(false);
$objMail->Body = $message;
}
// attach submitted files to email
if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) {
foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) {
foreach ($arrFilesOfField as $file) {
$objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']);
}
}
}
if ($chosenMailRecipient !== null) {
if (!empty($chosenMailRecipient)) {
$objMail->AddAddress($chosenMailRecipient);
$objMail->Send();
$objMail->ClearAddresses();
}
} else {
foreach ($arrFormData['emails'] as $sendTo) {
if (!empty($sendTo)) {
$objMail->AddAddress($sendTo);
$objMail->Send();
$objMail->ClearAddresses();
}
}
}
}
return true;
}
示例12: archivo
exit;
}
if (fwrite($gestor, $dompdf->output()) === FALSE) {
echo "No se puede escribir al archivo ({$nombre_archivo})";
exit;
}
echo "Éxito, se escribió al archivo ({$nombre_archivo})";
fclose($gestor);
//$dompdf->stream('personal.pdf');
//mail("tapiagenaro3@gmail.com", "Comision", $codigoHtml);
$mail->ClearAllRecipients();
$mail->ClearAttachments();
// añado el usuario de destino y otras configuraciones
$usuario_obj = "tapiagenaro3@gmail.com";
$mail->AddAddress($usuario_obj);
$mail->Subject = "Prueba de phpmailer";
$cuerpo_mensaje = "hola";
$mail->Body = $cuerpo_mensaje;
// nombre_adjunto es el nombre que verá el usuario cuando reciba el mail como nombre del archivo
$mail->AddAttachment($nombre_archivo, "nombre_adjunto.pdf");
// texto alternativo por si el usuario no admite html
$mail->AltBody = "Mensaje de prueba mandado con phpmailer en formato solo texto";
$exito = $mail->Send();
// borro el fichero real
unlink($nombre_archivo);
if (!$exito) {
echo "Problemas enviando correo electrónico";
echo "\n" . $mail->ErrorInfo;
} else {
echo "Mensaje enviado correctamente";
}
示例13: elseif
$upl_tmp_dir = get_cfg_var('upload_tmp_dir');
}
if ($fix_tmp_dir) {
// only for fixing on some servers, normally NOT used - set in config.php
$tmp_dir = $fix_tmp_dir;
} elseif ($upl_tmp_dir) {
$tmp_dir = $upl_tmp_dir;
} else {
$tmp_dir = dirname(tempnam('', ''));
}
if ($pic1 != "none" && $pic1) {
$pic1_file = $tmp_dir . "/pic1.tmp";
copy($pic1, $pic1_file);
}
if ($pic1_file) {
$mail->AddAttachment("{$pic1_file}", "{$pic1_name}");
}
if ($pic2 != "none" && $pic2) {
$pic2_file = $tmp_dir . "/pic2.tmp";
copy($pic2, $pic2_file);
}
if ($pic2_file) {
$mail->AddAttachment("{$pic2_file}", "{$pic2_name}");
}
if ($pic3 != "none" && $pic3) {
$pic3_file = $tmp_dir . "/pic3.tmp";
copy($pic3, $pic3_file);
}
if ($pic3_file) {
$mail->AddAttachment("{$pic3_file}", "{$pic3_name}");
}
示例14: sendReportEmail
function sendReportEmail($idUsr)
{
global $hoy;
$mail = new phpmailer();
$mail->Priority = 0;
// Se declara la prioridad del mensaje.
// ------------------------------------------------
// CONFIGURAR EMAIL.
// ------------------------------------------------
//Definimos las propiedades y llamamos a los métodos
//correspondientes del objeto mail
//Con PluginDir le indicamos a la clase phpmailer donde se
//encuentra la clase smtp que como he comentado al principio de
//este ejemplo va a estar en el subdirectorio includes
$mail->PluginDir = "../include/";
$mail->Mailer = "smtp";
// ++ EXCHANGE MSC ++
$mail->Host = "10.110.0.12";
$mail->SMTPAuth = true;
$mail->Username = "robot.sion";
$mail->Password = "Rmsc77";
$mail->From = "robot.sion@mscmexico.com";
$mail->FromName = "Robot.SION";
//El valor por defecto 10 de Timeout es un poco escaso dado que voy a usar
//una cuenta gratuita, por tanto lo pongo a 30
//$mail->Timeout=10;
$mail->Timeout = 30;
$email = getValueTable("Email", "USUARIO", "Id_usuario", $idUsr);
$ejecutivo = getValueTable("Nombre", "USUARIO", "Id_usuario", $idUsr);
if (!empty($email)) {
// --------------------
// FORMATO HTML
// --------------------
$mail->Body = "\n\t\t\t\t<html>\t\t\t\t\t\t\t\t\n\t\t\t\t<body>\t\t\t\t\n\t\t\t\t<b>MEDITERRANEAN SHIPPING COMPANY MEXICO S.A. DE C.V.<BR>\n\t\t\t\tSolo como Agentes / As Agents only</b>\n\t\t\t\t<hr>\t\t\t\t\n\t\t\t\t<b>DEMORAS</b>\n\t\t\t\t<p>\n\t\t\t\t\n\t\t\t\t<center>\t\t\t\t\n\t\t\t\t<b><u>POSIBLES CONTENEDORES EN ABANDONO</u></b>\n\t\t\t\t</center>\n\t\t\t\t<p>\t\t\t\t\t\t\t\t\n\t\t\t\t<b>{$ejecutivo} :</b>\n\t\t\t\t<p>\t\t\t\t\n\t\t\t\tEl sistema ha detectado algunos clientes que tienen contenedores con mas de 15 días incurriendo en demoras,\n\t\t\t\tfavor de revisar a la brevedad. Adjunto archivo.\n\t\t\t\t<p>\t\t\t\n\t\t\t\tNOTA : El archivo tiene formato CSV, pero se puede abrir con MS-Excel sin problema.\n\t\t\t\t<p>\n\t\t\t\tAtt. Robot SION.\n\t\t\t\t<p>\t\t\t\t\n\t\t\t\t<hr>\n\t\t\t\t<font color=red><b>\n\t\t\t\t* FAVOR DE NO RESPONDER A ESTA DIRECCIÓN DE CORREO YA QUE NO SE RECIBIRA SU MENSAJE Y POR CONSIGUIENTE NO SERA ATENDIDO.\n\t\t\t\t</b>\n\t\t\t\t</font>\t\t\t\t\n\t\t\t\t<p>\t\t\t\t\t\t\t\t\n\t\t\t";
// -------------------------------------------------------
// FORMATO TEXTO
// Definimos AltBody por si el destinatario del correo
// no admite email con formato html
// -------------------------------------------------------
$mail->AltBody = "\nMEDITERRANEAN SHIPPING COMPANY MÉXICO\nMSC México (As Agents Only-Solo como Agentes)\n=====================================================================\n\nYour are a Winner !!!\n\n{$ejecutivo} :\n\nEl sistema ha detectado algunos clientes que tienen contenedores con mas de 15 días incurriendo en demoras,\nfavor de revisar a la brevedad. Adjunto archivo.\nHasta luego.\nAtt. Robot SION.\n* FAVOR DE NO RESPONDER A ESTA DIRECCIÓN DE CORREO YA QUE NO SE RECIBIRA SU MENSAJE Y POR CONSIGUIENTE NO SERA ATENDIDO.\n";
// Nota :
// La direccion PARA solo se puede manejar 1.
// Las direcciones CC puede manejar N correos.
// -------------
// Destinatarios
// -------------
$mail->ClearAddresses();
// ------------------------------------------------
$mail->AddAddress("{$email}");
$mail->AddCC("ajaime@mscmexico.com");
$mail->AddCC("nperez@mscmexico.com");
$mail->Subject = "[SION] Pos.Abandono / {$ejecutivo} ";
// Incluir Attach.
$mail->AddAttachment("../files/demPosAba_{$idUsr}.zip", "demPosAba_{$idUsr}.zip");
// Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true
$exito = $mail->Send();
//Si el mensaje no ha podido ser enviado se realizaran 4 intentos mas como mucho
//para intentar enviar el mensaje, cada intento se hara 5 segundos despues
//del anterior, para ello se usa la funcion sleep
$intentos = 1;
while (!$exito && $intentos < 5) {
sleep(5);
$exito = $mail->Send();
$intentos = $intentos + 1;
}
if (!$exito) {
echo "[ <font color=red><b>Problema de envio</b></font> ] <b><a href=\"javascript:ventanaNueva('csNfyCatCli2.php?modo=consulta&idCliente={$idCli}',600,400)\">{$cliente}</a></b> -> <i>{$emailDestino}</i> -> {$valor}" . $mail->ErrorInfo . "<br>";
} else {
// echo "[ <font color=green><b>Enviado</b></font> ] <b><a href=\"javascript:ventanaNueva('csNfyCatCli2.php?modo=consulta&idCliente=$idCli',600,400)\">$cliente</a></b> -> <i>$emailDestino</i> <br>";
}
}
}
示例15: stripslashes
$mail->UseMSMailHeaders = true;
$mail->AddCustomHeader("X-Mailer: {$bazar_name} {$bazar_}#{$Id}\$- Email Interface");
$mail->AddAddress("{$toemail}", "{$toname}");
if ($cc) {
$mail->AddBCC($fromemail, $fromname);
}
$mail->Subject = stripslashes($subject);
if ($webmail_enable) {
$mail->Body = addslashes($body);
$mail->Subject = addslashes($subject);
} else {
$mail->Body = stripslashes($body);
$mail->Subject = stripslashes($subject);
}
if ($pic1 != "none" && $pic1) {
$mail->AddAttachment("{$pic1}", "{$pic1_name}");
}
if ($pic2 != "none" && $pic2) {
$mail->AddAttachment("{$pic2}", "{$pic2_name}");
}
if ($pic3 != "none" && $pic3) {
$mail->AddAttachment("{$pic3}", "{$pic3_name}");
}
if (!$mail->Send()) {
echo "There was an error sending the message";
exit;
}
if ($mail_notify) {
$subject_notify = "NOTIFY E-Mail from {$fromname}<{$fromemail}> to {$toname}<{$toemail}>";
if ($webmail_enable && !$friend) {
//WebMail or NOT ???