function dest_mail() { global $WORKING, $STATIC; $WORKING['STEPTODO'] = filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']); $WORKING['STEPDONE'] = 0; trigger_error(sprintf(__('%d. try to sending backup with mail...', 'backwpup'), $WORKING['DEST_MAIL']['STEP_TRY']), E_USER_NOTICE); //Create PHP Mailer require_once realpath($STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC']) . '/class-phpmailer.php'; $phpmailer = new PHPMailer(); //Setting den methode if ($STATIC['CFG']['mailmethod'] == "SMTP") { require_once realpath($STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC']) . '/class-smtp.php'; $phpmailer->Host = $STATIC['CFG']['mailhost']; $phpmailer->Port = $STATIC['CFG']['mailhostport']; $phpmailer->SMTPSecure = $STATIC['CFG']['mailsecure']; $phpmailer->Username = $STATIC['CFG']['mailuser']; $phpmailer->Password = base64_decode($STATIC['CFG']['mailpass']); if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass'])) { $phpmailer->SMTPAuth = true; } $phpmailer->IsSMTP(); trigger_error(__('Send mail with SMTP', 'backwpup'), E_USER_NOTICE); } elseif ($STATIC['CFG']['mailmethod'] == "Sendmail") { $phpmailer->Sendmail = $STATIC['CFG']['mailsendmail']; $phpmailer->IsSendmail(); trigger_error(__('Send mail with Sendmail', 'backwpup'), E_USER_NOTICE); } else { $phpmailer->IsMail(); trigger_error(__('Send mail with PHP mail', 'backwpup'), E_USER_NOTICE); } trigger_error(__('Creating mail', 'backwpup'), E_USER_NOTICE); $phpmailer->From = $STATIC['CFG']['mailsndemail']; $phpmailer->FromName = $STATIC['CFG']['mailsndname']; $phpmailer->AddAddress($STATIC['JOB']['mailaddress']); $phpmailer->Subject = sprintf(__('BackWPup archive from %1$s: %2$s', 'backwpup'), date('Y/m/d @ H:i', $STATIC['JOB']['starttime'] + $STATIC['WP']['TIMEDIFF']), $STATIC['JOB']['name']); $phpmailer->IsHTML(false); $phpmailer->Body = sprintf(__('Backup archive: %s', 'backwpup'), $STATIC['backupfile']); //check file Size if (!empty($STATIC['JOB']['mailefilesize'])) { if (filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']) > abs($STATIC['JOB']['mailefilesize'] * 1024 * 1024)) { trigger_error(__('Backup archive too big for sending by mail!', 'backwpup'), E_USER_ERROR); $WORKING['STEPDONE'] = 1; $WORKING['STEPSDONE'][] = 'DEST_MAIL'; //set done return; } } trigger_error(__('Adding backup archive to mail', 'backwpup'), E_USER_NOTICE); need_free_memory(filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']) * 5); $phpmailer->AddAttachment($STATIC['JOB']['backupdir'] . $STATIC['backupfile']); trigger_error(__('Send mail....', 'backwpup'), E_USER_NOTICE); if (false == $phpmailer->Send()) { trigger_error(sprintf(__('Error "%s" on sending mail!', 'backwpup'), $phpmailer->ErrorInfo), E_USER_ERROR); } else { $WORKING['STEPTODO'] = filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']); trigger_error(__('Mail send!!!', 'backwpup'), E_USER_NOTICE); } $WORKING['STEPSDONE'][] = 'DEST_MAIL'; //set done }
public function send() { $mail = new PHPMailer(); foreach ($this->to as $to) { $mail->AddAddress($to); } $mail->IsMail(); $mail->Subject = $this->subject; $mail->From = MAIL_REPLY_TO; $mail->FromName = $this->fromName ?: MAIL_FROM_NAME; $mail->Sender = MAIL_REPLY_TO; if ($this->replyTo) { $mail->AddReplyTo($this->replyTo); } $mail->Body = $this->body; if (substr(trim($this->body), 0, 1) == '<') { $mail->IsHTML(true); if (isset($this->plain_body)) { $mail->AltBody = html_entity_decode($this->plain_body); } } else { $mail->Body = html_entity_decode($this->body); $mail->IsHTML(false); } if (IS_PRODUCTION) { return $mail->Send(); } else { \jmvc::log(print_r($mail, true), 'mail'); } }
private static function getMailObject() { require_once 'includes/libs/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(true); $mail->PluginDir = 'includes/libs/phpmailer/'; $config = Config::get(); if ($config->mail_use == 2) { $mail->IsSMTP(); $mail->SMTPSecure = $config->smtp_ssl; $mail->Host = $config->smtp_host; $mail->Port = $config->smtp_port; if ($config->smtp_user != '') { $mail->SMTPAuth = true; $mail->Username = $config->smtp_user; $mail->Password = $config->smtp_pass; } } elseif ($config->mail_use == 0) { $mail->IsMail(); } else { throw new Exception("sendmail is deprecated, use SMTP instead!"); } $mailFromAddress = $config->smtp_sendmail; $mailFromName = $config->game_name; $mail->CharSet = 'UTF-8'; $mail->SetFrom($mailFromAddress, $mailFromName); return $mail; }
public function PDF_DO() { include labels(); $pdf = new Gift_PDF(); $title = ''; $uid = $_POST['uid']; $toMail = $_POST['to-mail']; $fromMail = $_POST['sender-mail']; $fromName = $_POST['sender-name']; $pdf->SetTitle($title); $pdf->PrintChapter($labelET['Company name'], 1, "Kupongi kood: {$uid}"); $pdf->ContentHolder(); $pdf->Ln(10); $name = $_POST['name'] . ' kingitus' . ' ID ' . $uid; $file = $name; $file .= '.pdf'; $pdf->Output('files/PDF/' . $file); //Redirect //header('Location: ' . 'FILES/' . $file); require "libaries/PHPMailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsMail(); $path = "files/PDF/" . $file; $mail->SetFrom($fromMail, "Kingituse tegi sulle: {$fromName}"); $mail->AddAddress($toMail); $mail->Subject = "Kingitus Falseprogrammingu poolt"; $mail->Body = "Vaata PDF faili. Kingitusi tegi sulle {$fromName} Emaililt: {$fromMail}"; $mail->AddAttachment($path); if (!$mail->Send()) { echo "Error saatmisega: " . $mail->ErrorInfo; } else { echo "Kiri saadetud"; } }
function sendEmail($senderName, $senderEmail, $name, $email, $subject, $message) { include_once ROOT . "/library/contrib/phpmailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->SetLanguage('en', ROOT . "/library/contrib/phpmailer/language/"); $mail->IsHTML(true); $mail->CharSet = 'utf-8'; $mail->From = $senderEmail; $mail->FromName = $senderName; $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = 'To view this email message, open the email with html enabled mailer.'; $mail->AddAddress($email, $name); if (!Setting::getServiceSettingGlobal('useCustomSMTP', 0)) { $mail->IsMail(); } else { $mail->IsSMTP(); $mail->Host = Setting::getServiceSettingGlobal('smtpHost', '127.0.0.1'); $mail->Port = Setting::getServiceSettingGlobal('smtpPort', 25); } ob_start(); $ret = $mail->Send(); ob_clean(); if (!$ret) { return array(false, $mail->ErrorInfo); } return true; }
/** * Miscellaneous calls to improve test coverage and some small tests */ function test_Miscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->AddCustomHeader('SomeHeader: Some Value'); $this->Mail->ClearCustomHeaders(); $this->Mail->ClearAttachments(); $this->Mail->IsHTML(false); $this->Mail->IsSMTP(); $this->Mail->IsMail(); $this->Mail->IsSendMail(); $this->Mail->IsQmail(); $this->Mail->SetLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->CreateHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); //Test pathinfo $a = '/mnt/files/飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched'); $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched'); $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3'; $q = PHPMailer::mb_pathinfo($a); $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched'); $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched'); $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched'); $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched'); }
/** * send an email * * @param string $toaddress * @param string $toname * @param string $subject * @param string $mailtext * @param string $fromaddress * @param string $fromname * @param bool $html */ public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { $SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail'); $SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1'); $SMTPAUTH = OC_Config::getValue('mail_smtpauth', false); $SMTPUSERNAME = OC_Config::getValue('mail_smtpname', ''); $SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', ''); $mailo = new PHPMailer(true); if ($SMTPMODE == 'sendmail') { $mailo->IsSendmail(); } elseif ($SMTPMODE == 'smtp') { $mailo->IsSMTP(); } elseif ($SMTPMODE == 'qmail') { $mailo->IsQmail(); } else { $mailo->IsMail(); } $mailo->Host = $SMTPHOST; $mailo->SMTPAuth = $SMTPAUTH; $mailo->Username = $SMTPUSERNAME; $mailo->Password = $SMTPPASSWORD; $mailo->From = $fromaddress; $mailo->FromName = $fromname; $mailo->Sender = $fromaddress; $a = explode(' ', $toaddress); try { foreach ($a as $ad) { $mailo->AddAddress($ad, $toname); } if ($ccaddress != '') { $mailo->AddCC($ccaddress, $ccname); } if ($bcc != '') { $mailo->AddBCC($bcc); } $mailo->AddReplyTo($fromaddress, $fromname); $mailo->WordWrap = 50; if ($html == 1) { $mailo->IsHTML(true); } else { $mailo->IsHTML(false); } $mailo->Subject = $subject; if ($altbody == '') { $mailo->Body = $mailtext . OC_MAIL::getfooter(); $mailo->AltBody = ''; } else { $mailo->Body = $mailtext; $mailo->AltBody = $altbody; } $mailo->CharSet = 'UTF-8'; $mailo->Send(); unset($mailo); OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG); } catch (Exception $exception) { OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR); throw $exception; } }
function end_mail($to, $subject, $body, $replyto = '', $replyto_name = '') { if (file_exists(END_SYSTEM_DIR . 'config/smtp.config.php')) { require END_SYSTEM_DIR . 'config/smtp.config.php'; } else { $config = array('use_smtp' => false); } include_once END_SYSTEM_DIR . 'plugin/phpmailer/class.phpmailer.php'; try { $mail = new PHPMailer(true); //New instance, with exceptions enabled $body = preg_replace('/\\\\/', '', $body); //Strip backslashes if ($config['use_smtp']) { $mail->IsSMTP(); $mail->SMTPDebug = false; $mail->CharSet = 'utf-8'; $mail->SMTPAuth = true; if ($config['smtp_port']) { $mail->Port = $config['smtp_port']; } if ($config['smtp_secure']) { $mail->SMTPSecure = $config['smtp_secure']; } if ($config['smtp_host']) { $mail->Host = $config['smtp_host']; } if ($config['smtp_username']) { $mail->Username = $config['smtp_username']; } if ($config['smtp_password']) { $mail->Password = $config['smtp_password']; } } else { $mail->IsMail(); } $mail->From = $config['smtp_fullemail']; $mail->FromName = $config['smtp_fullname']; !$replyto && ($replyto = $config['smtp_fullemail']); !$replyto_name && ($replyto_name = $cofnig['smtp_fullname']); $mail->AddReplyTo($replyto, $replyto_name); $mail->AddAddress($to); $mail->Subject = $subject; $mail->WordWrap = 80; // set word wrap $mail->MsgHTML($body); $mail->IsHTML(true); // send as HTML $mail->Send(); return true; } catch (phpmailerException $e) { echo $e->errorMessage(); return false; } }
function mailer_init() { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $smtp_options = $this->get_smtp_options(); // $smtp_options['enabled'] = $this->options['smtp_enabled']; // $smtp_options['host'] = $this->options['smtp_host']; // $smtp_options['port'] = $this->options['smtp_port']; // $smtp_options['user'] = $this->options['smtp_user']; // $smtp_options['pass'] = $this->options['smtp_pass']; // $smtp_options['secure'] = $this->options['smtp_secure']; //$smtp_options = apply_filters('newsletter_smtp', $smtp_options); if ($smtp_options['enabled'] == 1) { $this->mailer = new PHPMailer(); $this->mailer->IsSMTP(); $this->mailer->Host = $smtp_options['host']; if (!empty($smtp_options['port'])) { $this->mailer->Port = (int) $smtp_options['port']; } if (!empty($smtp_options['user'])) { $this->mailer->SMTPAuth = true; $this->mailer->Username = $smtp_options['user']; $this->mailer->Password = $smtp_options['pass']; } $this->mailer->SMTPKeepAlive = true; $this->mailer->SMTPSecure = $smtp_options['secure']; $this->mailer->SMTPAutoTLS = false; if ($smtp_options['ssl_insecure'] == 1) { $this->mailer->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true)); } } else { if ($this->options['phpmailer'] == 1) { $this->mailer = new PHPMailer(); $this->mailer->IsMail(); } else { $this->mailer = null; return; } } if (!empty($this->options['content_transfer_encoding'])) { $this->mailer->Encoding = $this->options['content_transfer_encoding']; } else { $this->mailer->Encoding = 'base64'; } $this->mailer->CharSet = 'UTF-8'; $this->mailer->From = $this->options['sender_email']; $return_path = $this->options['return_path']; if (!empty($return_path)) { $this->mailer->Sender = $return_path; } if (!empty($this->options['reply_to'])) { $this->mailer->AddReplyTo($this->options['reply_to']); } $this->mailer->FromName = $this->options['sender_name']; }
/** * 发送邮件 * * @param string $to * @param string $to_name * @param string $subject * @param string $body * @param string $mailtype * @return boolean */ public static function send($to, $to_name, $subject, $body, $chaosong = array(), $mailtype = 'txt') { self::init(); $send_type = mod_config::get_one_config('fl_sendemailtype') == '1' ? 'smtp' : 'mail'; $mail = new PHPMailer(); $mail->SMTPDebug = false; // 发送方式 if ($send_type == 'smtp') { self::smtp_init(); $mail->IsSMTP(); $mail->Host = self::$smtp_server; $mail->Port = self::$smtp_port; $mail->SmtpSsl = self::$smtp_ssl; // SSL 连接 if (self::$smtp_auth) { $mail->SMTPAuth = true; $mail->Username = self::$smtp_user; $mail->Password = self::$smtp_pwd; } else { $mail->SMTPAuth = false; } } elseif ($send_type == 'mail') { $mail->IsMail(); } // 发件人邮箱 $mail->From = self::$from_email; // 发件人名称 if (self::$from_name != '') { $mail->FromName = self::$from_name; } // 收件人邮箱和姓名 $mail->AddAddress($to, $to_name); if ($chaosong) { foreach ($chaosong as $v) { $mail->AddCC($v['to'], $v['name']); } } // 邮件编码 $mail->CharSet = self::$charset; // 邮件编码方式 $mail->Encoding = "base64"; // 邮件格式类型 if ($mailtype == 'txt') { $mail->IsHTML(false); } elseif ($mailtype == 'html') { $mail->IsHTML(true); $mail->AltBody = "text/html"; } $mail->Subject = $subject; // 邮件主题 $mail->Body = $body; // 邮件内容D return !$mail->Send() ? false : true; }
function email($from, $fromname, $to, $subject, $msg) { $mail = new PHPMailer(); $mail->IsMail(); $mail->CharSet = "utf-8"; $mail->AddReplyTo($from, $fromname); $mail->AddAddress($to); $mail->SetFrom($from, $fromname); $mail->Subject = $subject; $mail->MsgHTML($msg); $mail->Send(); }
public function send($emailAddresses) { $phpMailer = new PHPMailer(); $phpMailer->IsMail(); $phpMailer->AddReplyTo($this->email, $this->name); foreach ($emailAddresses as $emailAddress) { $phpMailer->AddAddress($emailAddress); } $phpMailer->SetFrom($this->email, $this->name); $phpMailer->Subject = 'Contact form message: ' . $this->subject . ' from ' . $this->name . '.'; $msg = 'Name: ' . $this->name . '<br />' . 'Email: ' . $this->email . '<br />' . 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '<br /><br />' . 'Message:<br /><br />' . nl2br($this->message); $phpMailer->MsgHTML($msg); $phpMailer->Send(); }
public static function enviar($motivo, $tipo, $email, $nome, $id = 0, $complemento = "", $anexo = "") { $mail = new PHPMailer(); $mail->From = SENDMAIL_FROM; $mail->FromName = SENDMAIL_FROM_NAME; $mail->Host = SENDMAIL_HOST; $mail->IsMail(); $mail->IsHTML(true); $mail->AddAddress($email, $nome); $tipoCapitulado = ucfirst($tipo); $saudacao = $tipo == "individual" ? "Olá " : ""; $primeiro_nome = array_shift(explode(" ", $nome)); $texto = "<!DOCTYPE html><html lang='pt-br'><head><meta charset='utf-8'></head><body>{$saudacao}<b>{$primeiro_nome}</b>,<br><br>"; switch ($motivo) { case 'cadastro': $titulo = "Cadastro realizado com sucesso"; $texto .= "Obrigado pelo interesse em participar do <b>" . NOME_EVENTO . "</b>!<br><br>\n <b>Confirmação da Pré-Inscrição:</b><br>\n Confirmamos o cadastro de seus dados, você está inscrito com o código de <b>número {$id}</b>.<br><br>\n <b>Pagamento:</b><br>\n Estamos aguardando a confirmação do PagSeguro, para finalizarmos seu processo de inscrição.<br><br>\n Assim que concluído, você receberá uma mensagem de confirmação da inscrição no <b>" . NOME_EVENTO . "</b>.<br><br>\n Caso tenha ocorrido algum problema, utilize o link abaixo para efetuar o pagamento e confirmar a inscrição.<br>\n <a href='" . HOME_PAGE . "inscricao/view/pagamento{$tipoCapitulado}.php?id=" . $id . "'>" . HOME_PAGE . "inscricao/view/pagamento{$tipoCapitulado}.php?id=" . $id . "</a><br><br>\n {$complemento}"; break; case 'pagamento': $titulo = "Confirmação de pagamento e inscrição"; if ($tipo == "individual") { $texto .= "Escrevemos para informar que recebemos o pagamento de sua inscrição.<br><br>"; } elseif ($tipo == "empresa") { $texto .= "Escrevemos para informar que recebemos o pagamento da inscrição de seus funcionários.<br><br>{$complemento}"; } break; case 'envio_certificado': $titulo = "Certificado de Participação"; if (file_exists($anexo)) { $mail->AddAttachment($anexo); } $texto .= "Queremos agradecer sua participação e colaboração no <b>" . NOME_EVENTO . "</b>.<br><br>\n Também estamos enviando, em anexo, seu certificado de participação. Nos vemos nos próximos eventos!<br><br>"; break; default: $titulo = "Aviso"; if (!empty($complemento)) { $texto .= "{$complemento}<br><br>"; } else { $texto .= "Verificamos em nosso sistema que seu pagamento ainda não foi efetuado.<br><br>\n \n Estamos chegando ao número máximo da lotação do evento. Precisamos que você confirme sua participação para que a mesma não seja cancelada na próxima sexta-feira. Assim, podermos dar oportunidade a outras pessoas que desejam participar.<br><br>\n \n Assim que concluído, você receberá uma mensagem de confirmação.<br><br>\n Caso tenha ocorrido algum problema, utilize o link abaixo para efetuar o pagamento e confirmar sua inscrição.<br><br>\n <a href='" . HOME_PAGE . "inscricao/view/pagamento{$tipoCapitulado}.php?id=" . $id . "'>" . HOME_PAGE . "inscricao/view/pagamento{$tipoCapitulado}.php?id=" . $id . "</a><br><br>"; } } if ($motivo != "envio_certificado") { $texto .= "<br>Acesse nosso <a href='" . HOME_PAGE . "'>web site</a> ou siga o <a href='" . TWITTER_ENDERECO . "'>" . TWITTER_NOME . "</a> no Twitter para acompanhar as notícias sobre o " . NOME_EVENTO . ".<br><br>"; } $texto .= "<b>Organização do " . NOME_EVENTO . "</b></body></html>"; $mail->Subject = $titulo; $mail->Body = $texto; return $mail->Send(); }
function sendMailToAdmin($subject, $email, $body) { global $modx; $mail = new PHPMailer(); $mail->IsMail(); $mail->IsHTML(false); $mail->From = $modx->config['emailsender']; $mail->FromName = $_SERVER['SERVER_NAME']; $mail->Subject = $subject; $mail->Body = $body; $mail->AddAddress($email); if (!$mail->send()) { //echo $mail->ErrorInfo; } }
/** * Miscellaneous calls to improve test coverage and some small tests */ function test_Miscellaneous() { $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed'); $this->Mail->AddCustomHeader('SomeHeader: Some Value'); $this->Mail->ClearCustomHeaders(); $this->Mail->ClearAttachments(); $this->Mail->IsHTML(false); $this->Mail->IsSMTP(); $this->Mail->IsMail(); $this->Mail->IsSendMail(); $this->Mail->IsQmail(); $this->Mail->SetLanguage('fr'); $this->Mail->Sender = ''; $this->Mail->CreateHeader(); $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded'); $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed'); }
function send_mail($mail_to, $mail_body, $mail_subject = 'No title', $mail_name = 'No name', $mail_from = '', $mail_priority = 3, $mail_wordwrap = 50, $mail_altbody = '') { global $GO_CONFIG; // $mail_to='*****@*****.**'; // $mail_from = '*****@*****.**'; // $mail_name = "333"; // $mail_subject = 'subject'; // $mail_body = '123456789'; // $mail_altbody = 'qqqqqqqqqqqqqqqq'; require $GO_CONFIG->class_path . "phpmailer/class.phpmailer.php"; require $GO_CONFIG->class_path . "phpmailer/class.smtp.php"; $mail = new PHPMailer(); $mail->PluginDir = $GO_CONFIG->class_path . 'phpmailer/'; $mail->SetLanguage($php_mailer_lang, $GO_CONFIG->class_path . 'phpmailer/language/'); switch ($GO_CONFIG->mailer) { case 'smtp': $mail->Host = $GO_CONFIG->smtp_server; $mail->Port = $GO_CONFIG->smtp_port; $mail->IsSMTP(); break; case 'qmail': $mail->IsQmail(); break; case 'sendmail': $mail->IsSendmail(); break; case 'mail': $mail->IsMail(); break; } $mail->Priority = $mail_priority; $mail->Sender = $mail_from; $mail->From = $mail_from; $mail->FromName = $mail_name; $mail->AddReplyTo($mail_from, $mail_name); $mail->WordWrap = $mail_wordwrap; // $mail->Encoding = "quoted-printable"; $mail->IsHTML(true); $mail->Subject = $mail_subject; $mail->AddAddress($mail_to); $mail->Body = $mail_body; $mail->AltBody = $mail_altbody; if (!$mail->Send()) { return '<p class="Error">' . $ml_send_error . ' ' . $mail->ErrorInfo . '</p>'; } }
/** * @desc envia email atravez da configuração passada no MailInfoPostVOVO * @return ReturnResultVO */ public function mail() { //inicia um retorno de ReturnResultVO $ReturnResultVO = new ReturnResultVO(); $RuturnResultVO = $this->MailInfoPostVO->validate(); if (!$RuturnResultVO->success) { return $RuturnResultVO; } $mail = new PHPMailer(); $mail->IsMail(); $mail->CharSet = $this->MailInfoPostVO->char_set; //$mail->IsSMTP(); // send via SMTP $mail->Host = $this->MailInfoPostVO->host; //seu servidor SMTP $mail->SMTPAuth = $this->MailInfoPostVO->smtp_auth; // true para autenticação $mail->Username = $this->MailInfoPostVO->username; // usuário de SMTP $mail->Password = $this->MailInfoPostVO->password; // senha de SMTP $mail->From = $this->MailInfoPostVO->from; //coloque aqui o seu correio, para que a autenticação não barre a mensagem $mail->FromName = $this->MailInfoPostVO->from_name; $mail->WordWrap = 50; // Definiçao de quebra de linha // envio como HTML se é true if ($this->MailInfoPostVO->is_html) { $mail->IsHTML(TRUE); } $mail->Subject = $this->MailInfoPostVO->subject; $mail->Body = $this->MailInfoPostVO->body; //$mail->AltBody = $msgFinal; //Destinatarios $mail->AddAddress($this->MailInfoPostVO->to); $mail->AddAddress($this->MailInfoPostVO->add_address); //envia email atravez do phpmailer if (@$mail->Send()) { $RuturnResultVO->success = TRUE; $RuturnResultVO->addMessage(Translation::text("LibraryLanguage::SUCCESS_CONTACT_SEND_EMAIL")); return $RuturnResultVO; } else { $RuturnResultVO->success = FALSE; $RuturnResultVO->addMessage(Translation::text("LibraryLanguage::ERROR_CONTACT_SEND_EMAIL")); return $RuturnResultVO; } }
function mailer_init() { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $this->mailer = new PHPMailer(); $smtp_options = array(); $smtp_options['enabled'] = $this->options['smtp_enabled']; $smtp_options['host'] = isset($this->options['smtp_host']) ? $this->options['smtp_host'] : ""; $smtp_options['port'] = isset($this->options['smtp_port']) ? $this->options['smtp_port'] : ""; $smtp_options['user'] = isset($this->options['smtp_user']) ? $this->options['smtp_user'] : ""; $smtp_options['pass'] = isset($this->options['smtp_pass']) ? $this->options['smtp_pass'] : ""; $smtp_options['secure'] = $this->options['smtp_secure']; $smtp_options = apply_filters('newsletter_smtp', $smtp_options); if ($smtp_options['enabled'] == 1) { $this->mailer->IsSMTP(); $this->mailer->Host = $smtp_options['host']; if (!empty($smtp_options['port'])) { $this->mailer->Port = (int) $smtp_options['port']; } if (!empty($smtp_options['user'])) { $this->mailer->SMTPAuth = true; $this->mailer->Username = $smtp_options['user']; $this->mailer->Password = $smtp_options['pass']; } $this->mailer->SMTPKeepAlive = true; $this->mailer->SMTPSecure = $smtp_options['secure']; } else { $this->mailer->IsMail(); } if (!empty($this->options['content_transfer_encoding'])) { $this->mailer->Encoding = $this->options['content_transfer_encoding']; } else { $this->mailer->Encoding = 'base64'; } $this->mailer->CharSet = 'UTF-8'; $this->mailer->From = $this->options['sender_email']; $return_path = $this->options['return_path']; if (!empty($return_path)) { $this->mailer->Sender = $return_path; } if (!empty($this->options['reply_to'])) { $this->mailer->AddReplyTo($this->options['reply_to']); } $this->mailer->FromName = $this->options['sender_name']; }
function sendMail($nome, $email, $mensagem) { require_once 'function/PHPMailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); $mail->IsMail(true); $mail->IsHTML(true); $mail->From = $email; $mail->FromName = $nome; $mail->AddAddress('*****@*****.**', 'Arena Piscinas'); $mail->Subject = 'Mensagem - Site'; $mail->Body = '<b>Nome:</b> ' . $nome . ' <br /><br /><b>E-mail:</b> ' . $email . ' <br /><br /><b>Mensagem:</b> ' . $mensagem; if ($mail->Send()) { $envio = true; } else { $envio = false; } return $envio; }
public function sendMail($dest_email, $subject, $body, $attachments = array(), $dest_name = "") { //$this->log->write("sendMail() sono in: ".getcwd()); require_once '../system/library/PHPMailer/class.phpmailer.php'; //$this->log->write("importato mailer!"); $mail = new PHPMailer(); $mail->IsMail(); // Set mailer to use PHP mail() $mail->From = $this->config->get('config_email'); $mail->FromName = $this->config->get('config_name'); $mail->AddAddress($dest_email); //mando in chiaro al customer $mail->AddReplyTo($this->config->get('config_email')); $mail->AddBCC($this->config->get('config_email')); //e in copia blind anche all'admin $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->IsHTML(true); // Set email format to HTML $mail->Subject = $subject; //headers $message = $this->model_burro_mailing->getMailTemplate("header"); //body if ($dest_name != "") { $message .= "Dear " . $dest_name . " / Gentile " . $dest_name . ",<br/><br/>"; } $message .= $body; //footers $message .= $this->model_burro_mailing->getMailTemplate("footer"); //attachments if (is_array($attachments) && count($attachments) > 0) { foreach ($attachments as $att) { $mail->AddAttachment($att["fullpath"], $att["filename"]); } } //encode $mail->Body = utf8_decode($message); $mail->AltBody = str_replace("<br/>", "\n", $message); //and send if (!$mail->Send()) { $this->log->write('sendMail(): Message could not be sent.'); $this->log->write('sendMail(): Mailer Error: ' . $mail->ErrorInfo); } }
/** * Try to send a mail by using PHPMailer. * Make sure you have loaded PHPMailer via Composer. * Depending on your EMAIL_USE_SMTP setting this will work via SMTP credentials or via native mail() * * @param $user_email * @param $from_email * @param $from_name * @param $subject * @param $body * * @return bool * @throws Exception * @throws phpmailerException */ public function sendMailWithPHPMailer($user_email, $from_email, $from_name, $subject, $body) { $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; // if you want to send mail via PHPMailer using SMTP credentials if (Config::get('EMAIL_USE_SMTP')) { // set PHPMailer to use SMTP $mail->IsSMTP(); // 0 = off, 1 = commands, 2 = commands and data, perfect to see SMTP errors $mail->SMTPDebug = 0; // enable SMTP authentication $mail->SMTPAuth = Config::get('EMAIL_SMTP_AUTH'); // encryption if (Config::get('EMAIL_SMTP_ENCRYPTION')) { $mail->SMTPSecure = Config::get('EMAIL_SMTP_ENCRYPTION'); } // set SMTP provider's credentials $mail->Host = Config::get('EMAIL_SMTP_HOST'); $mail->Username = Config::get('EMAIL_SMTP_USERNAME'); $mail->Password = Config::get('EMAIL_SMTP_PASSWORD'); $mail->Port = Config::get('EMAIL_SMTP_PORT'); } else { $mail->IsMail(); } // fill mail with data $mail->From = $from_email; $mail->FromName = $from_name; $mail->AddAddress($user_email); $mail->Subject = $subject; $mail->Body = $body; // try to send mail $mail->Send(); if ($mail) { return true; } else { // if not successful, copy errors into Mail's error property $this->error = $mail->ErrorInfo; return false; } }
function forgotpassword($email) { global $settings, $error, $error_die; if (empty($email)) { $error[] = 'You must enter an email'; return false; } $sql = call('sql_query', "SELECT email, user FROM users WHERE email = '{$email}'"); if (call('sql_num_rows', $sql) == 0) { $error[] = 'This email is not registered to any existing users'; return false; } if (!errors()) { $mail = new PHPMailer(); $fetch = call('sql_fetch_array', $sql); $newpass = substr(str_shuffle('qwertyuiopasdfghjklmnbvcxz0987612345'), 0, 7); $sql = call('sql_query', "UPDATE users SET pass = '******' WHERE email = '{$email}'"); if ($settings['mail'] == 'sendmail') { $mail->IsMail(); } elseif ($settings['mail'] == 'smtp') { $mail->IsSMTP(); $mail->Host = $settings['smtp_host']; $mail->SMTPAuth = true; $mail->Username = $settings['smtp_username']; $mail->Password = $settings['smtp_password']; } $mail->FromName = $settings['site_name']; $mail->From = $settings['email']; $mail->AddAddress("{$email}"); $mail->Subject = 'New Password for ' . $settings['site_name'] . ''; $mail->Body = "Hi " . $fetch['user'] . ",\n Your new password as requested is:\n" . $newpass; if (!$mail->Send()) { $error[] = "Error sending: " . $mail->ErrorInfo; return false; } else { return true; } } }
public function send() { // Create a PHP Mailer object and set it up $mailer = new \PHPMailer(true); $mailer->IsMail(); // Set the emails subject $mailer->Subject = $this->subject; // Set the from address if (!empty($this->from)) { $mailer->SetFrom($this->from['email'], $this->from['name'], true); } // Set the to address foreach ($this->to as $to) { $mailer->AddAddress($to['email'], $to['name']); } // cc foreach ($this->cc as $cc) { $mailer->AddCC($cc['email'], $cc['name']); } // bcc foreach ($this->bcc as $bcc) { $mailer->AddBCC($bcc['email'], $bcc['name']); } // If we have an HTML body, set that on the message // and mark it as an HTML email if (!empty($this->htmlBody)) { $mailer->Body = $this->htmlBody; $mailer->AltBody = $this->textBody; $mailer->IsHTML(); } else { $mailer->Body = $this->textBody; } // Attachments foreach ($this->attachments as $attachment) { $mailer->AddStringAttachment($attachment['content'], $attachment['filename'], 'base64', $attachment['mime']); } // Finally, try and send teh message return $mailer->Send(); }
private static function getMailObject() { require 'includes/libs/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(true); $mail->PluginDir = 'includes/libs/phpmailer/'; if (Config::get('mail_use') == 2) { $mail->IsSMTP(); $mail->SMTPSecure = Config::get('smtp_ssl'); $mail->Host = Config::get('smtp_host'); $mail->Port = Config::get('smtp_port'); if (Config::get('smtp_user') != '') { $mail->SMTPAuth = true; $mail->Username = Config::get('smtp_user'); $mail->Password = Config::get('smtp_pass'); } } elseif (Config::get('mail_use') == 0) { $mail->IsMail(); } else { throw new Exception("Sendmail is deprecated, use SMTP instaed!"); } return $mail; }
/** * @todo add port settings */ public function Send($EventName = '') { $this->FireEvent('BeforeSendMail'); if (C('Garden.Email.Disabled')) { return; } if (C('Garden.Email.UseSmtp')) { $this->PhpMailer->IsSMTP(); $SmtpHost = C('Garden.Email.SmtpHost', ''); $SmtpPort = C('Garden.Email.SmtpPort', 25); if (strpos($SmtpHost, ':') !== FALSE) { list($SmtpHost, $SmtpPort) = explode(':', $SmtpHost); } $this->PhpMailer->Host = $SmtpHost; $this->PhpMailer->Port = $SmtpPort; $this->PhpMailer->SMTPSecure = C('Garden.Email.SmtpSecurity', ''); $this->PhpMailer->Username = $Username = C('Garden.Email.SmtpUser', ''); $this->PhpMailer->Password = $Password = C('Garden.Email.SmtpPassword', ''); if (!empty($Username)) { $this->PhpMailer->SMTPAuth = TRUE; } } else { $this->PhpMailer->IsMail(); } if ($EventName != '') { $this->EventArguments['EventName'] = $EventName; $this->FireEvent('SendMail'); } if (!empty($this->Skipped) && $this->PhpMailer->CountRecipients() == 0) { // We've skipped all recipients. return TRUE; } $this->PhpMailer->ThrowExceptions(TRUE); if (!$this->PhpMailer->Send()) { throw new Exception($this->PhpMailer->ErrorInfo); } return TRUE; }
function sendMail($subject, $email, $body) { global $modx; $charset = $modx->config['modx_charset']; $site_name = $modx->config['site_name']; $adminEmail = $modx->config['emailsender']; require_once MODX_MANAGER_PATH . "includes/controls/class.phpmailer.php"; $mail = new PHPMailer(); //add smtp method by Dmi3yy if ($modx->config['email_method'] == 'smtp') { $mail->IsSMTP(); // отсылать используя SMTP $mail->Host = $modx->config['email_host']; // SMTP сервер $mail->SMTPAuth = true; // включить SMTP аутентификацию $mail->Username = $modx->config['email_smtp_sender']; // SMTP username $mail->Password = $modx->config['email_pass']; // SMTP password $mail->From = $modx->config['email_smtp_sender']; $mail->Port = $modx->config['email_port']; } else { $mail->IsMail(); $mail->From = $adminEmail; } $mail->IsHTML(false); $mail->CharSet = $charset; $mail->FromName = $site_name; $mail->Subject = $subject; $mail->Body = $body; $mail->AddAddress($email); if (!$mail->send()) { echo $mail->ErrorInfo; exit; } }
function sendVerificationEmail($htmlbody, $useremailad, $mailsubject) { $mail = new PHPMailer(); // use SMTP or use mail() if (EMAIL_USE_SMTP) { // Set mailer to use SMTP $mail->IsSMTP(); //useful for debugging, shows full SMTP errors //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only // Enable SMTP authentication $mail->SMTPAuth = EMAIL_SMTP_AUTH; // Enable encryption, usually SSL/TLS if (defined(EMAIL_SMTP_ENCRYPTION)) { $mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION; } // Specify host server $mail->Host = EMAIL_SMTP_HOST; $mail->Username = EMAIL_SMTP_USERNAME; $mail->Password = EMAIL_SMTP_PASSWORD; $mail->Port = EMAIL_SMTP_PORT; } else { $mail->IsMail(); } $mail->IsHTML(true); $mail->From = EMAIL_VERIFICATION_FROM; $mail->FromName = EMAIL_VERIFICATION_FROM_NAME; $mail->AddAddress($useremailad); $mail->Subject = $mailsubject; $mail->Body = $htmlbody; if (!$mail->Send()) { $this->errors[] = MESSAGE_VERIFICATION_MAIL_NOT_SENT . $mail->ErrorInfo; return false; } else { return true; } }
function xmail($to, $from = array(), $topic, $comment) { global $config, $gpc; require_once "classes/mail/class.phpmailer.php"; $mail = new PHPMailer(); $mail->CharSet = 'UTF-8'; // Added Check_mail for better security // Now it is not possible to add various headers to the mail if (!isset($from['mail']) || !check_mail($from['mail'])) { $mail->From = $config['forenmail']; } else { $mail->From = $gpc->plain_str($from['mail']); } if (!isset($from['name'])) { $mail->FromName = $gpc->plain_str($config['fname']); } else { $mail->FromName = $gpc->plain_str($from['name']); } if ($config['smtp'] == 1) { $mail->Mailer = "smtp"; $mail->IsSMTP(); $mail->Host = $config['smtp_host']; if ($config['smtp_auth'] == 1) { $mail->SMTPAuth = TRUE; $mail->Username = $config['smtp_username']; $mail->Password = $config['smtp_password']; } } elseif ($config['sendmail'] == 1) { $mail->IsSendmail(); $mail->Mailer = "sendmail"; $mail->Sendmail = $config['sendmail_host']; } else { $mail->IsMail(); } $mail->Subject = $gpc->plain_str($topic); if (!is_array($to)) { $to = array('0' => array('mail' => $to)); } $i = 0; foreach ($to as $email) { $mail->IsHTML(false); $mail->Body = $gpc->plain_str($comment); if (isset($email['name'])) { $mail->AddAddress($gpc->plain_str($email['mail']), $gpc->plain_str($email['name'])); } else { $mail->AddAddress($gpc->plain_str($email['mail'])); } if ($config['local_mode'] == 0) { if ($mail->Send()) { $i++; } } $mail->ClearAddresses(); $mail->ClearAttachments(); } return $i; }
/** * 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. * * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from * creating a from address like 'Name <*****@*****.**>' when both are set. If * just 'wp_mail_from' is set, then just the email address will be used with no * name. * * The default content type is 'text/plain' which does not allow using HTML. * However, you can set the content type of the email by using the * 'wp_mail_content_type' filter. * * The default charset is based on the charset used on the blog. The charset can * be set using the 'wp_mail_charset' filter. * * @since 1.2.1 * * @uses PHPMailer * * @param string|array $to Array or comma-separated list of email addresses to send message. * @param string $subject Email subject * @param string $message Message contents * @param string|array $headers Optional. Additional headers. * @param string|array $attachments Optional. Files to attach. * @return bool Whether the email contents were sent successfully. */ function wp_mail($to, $subject, $message, $headers = '', $attachments = array()) { // Compact the input, apply the filters, and extract them back out /** * Filter the wp_mail() arguments. * * @since 2.2.0 * * @param array $args A compacted array of wp_mail() arguments, including the "to" email, * subject, message, headers, and attachments values. */ $atts = apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments')); if (isset($atts['to'])) { $to = $atts['to']; } if (isset($atts['subject'])) { $subject = $atts['subject']; } if (isset($atts['message'])) { $message = $atts['message']; } if (isset($atts['headers'])) { $headers = $atts['headers']; } if (isset($atts['attachments'])) { $attachments = $atts['attachments']; } if (!is_array($attachments)) { $attachments = explode("\n", str_replace("\r\n", "\n", $attachments)); } global $phpmailer; // (Re)create it, if it's gone missing if (!$phpmailer instanceof PHPMailer) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer(true); } // Headers if (empty($headers)) { $headers = array(); } else { if (!is_array($headers)) { // Explode the headers out, so this function can take both // string headers and an array of headers. $tempheaders = explode("\n", str_replace("\r\n", "\n", $headers)); } else { $tempheaders = $headers; } $headers = array(); $cc = array(); $bcc = array(); // If it's actually got contents if (!empty($tempheaders)) { // Iterate through the raw headers foreach ((array) $tempheaders as $header) { if (strpos($header, ':') === false) { if (false !== stripos($header, 'boundary=')) { $parts = preg_split('/boundary=/i', trim($header)); $boundary = trim(str_replace(array("'", '"'), '', $parts[1])); } continue; } // Explode them out list($name, $content) = explode(':', trim($header), 2); // Cleanup crew $name = trim($name); $content = trim($content); switch (strtolower($name)) { // Mainly for legacy -- process a From: header if it's there case 'from': $bracket_pos = strpos($content, '<'); if ($bracket_pos !== false) { // Text before the bracketed email is the "From" name. if ($bracket_pos > 0) { $from_name = substr($content, 0, $bracket_pos - 1); $from_name = str_replace('"', '', $from_name); $from_name = trim($from_name); } $from_email = substr($content, $bracket_pos + 1); $from_email = str_replace('>', '', $from_email); $from_email = trim($from_email); // Avoid setting an empty $from_email. } elseif ('' !== trim($content)) { $from_email = trim($content); } break; case 'content-type': if (strpos($content, ';') !== false) { list($type, $charset_content) = explode(';', $content); $content_type = trim($type); if (false !== stripos($charset_content, 'charset=')) { $charset = trim(str_replace(array('charset=', '"'), '', $charset_content)); } elseif (false !== stripos($charset_content, 'boundary=')) { $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset_content)); $charset = ''; } // Avoid setting an empty $content_type. } elseif ('' !== trim($content)) { $content_type = trim($content); } break; case 'cc': $cc = array_merge((array) $cc, explode(',', $content)); break; case 'bcc': $bcc = array_merge((array) $bcc, explode(',', $content)); break; default: // Add it to our grand headers array $headers[trim($name)] = trim($content); break; } } } } // Empty out the values that may be set $phpmailer->ClearAllRecipients(); $phpmailer->ClearAttachments(); $phpmailer->ClearCustomHeaders(); $phpmailer->ClearReplyTos(); // From email and name // If we don't have a name from the input headers if (!isset($from_name)) { $from_name = 'WordPress'; } /* If we don't have an email from the input headers default to wordpress@$sitename * Some hosts will block outgoing mail from this address if it doesn't exist but * there's no easy alternative. Defaulting to admin_email might appear to be another * option but some hosts may refuse to relay mail from an unknown domain. See * https://core.trac.wordpress.org/ticket/5007. */ if (!isset($from_email)) { // Get the site domain and get rid of www. $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $from_email = 'wordpress@' . $sitename; } /** * Filter the email address to send from. * * @since 2.2.0 * * @param string $from_email Email address to send from. */ $phpmailer->From = apply_filters('wp_mail_from', $from_email); /** * Filter the name to associate with the "from" email address. * * @since 2.3.0 * * @param string $from_name Name associated with the "from" email address. */ $phpmailer->FromName = apply_filters('wp_mail_from_name', $from_name); // Set destination addresses if (!is_array($to)) { $to = explode(',', $to); } foreach ((array) $to as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->AddAddress($recipient, $recipient_name); } catch (phpmailerException $e) { continue; } } // Set mail's subject and body $phpmailer->Subject = $subject; $phpmailer->Body = $message; // Add any CC and BCC recipients if (!empty($cc)) { foreach ((array) $cc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->AddCc($recipient, $recipient_name); } catch (phpmailerException $e) { continue; } } } if (!empty($bcc)) { foreach ((array) $bcc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->AddBcc($recipient, $recipient_name); } catch (phpmailerException $e) { continue; } } } // Set to use PHP's mail() $phpmailer->IsMail(); // Set Content-Type and charset // If we don't have a content-type from the input headers if (!isset($content_type)) { $content_type = 'text/plain'; } /** * Filter the wp_mail() content type. * * @since 2.3.0 * * @param string $content_type Default wp_mail() content type. */ $content_type = apply_filters('wp_mail_content_type', $content_type); $phpmailer->ContentType = $content_type; // Set whether it's plaintext, depending on $content_type if ('text/html' == $content_type) { $phpmailer->IsHTML(true); } // If we don't have a charset from the input headers if (!isset($charset)) { $charset = get_bloginfo('charset'); } // Set the content-type and charset /** * Filter the default wp_mail() charset. * * @since 2.3.0 * * @param string $charset Default email charset. */ $phpmailer->CharSet = apply_filters('wp_mail_charset', $charset); // Set custom headers if (!empty($headers)) { foreach ((array) $headers as $name => $content) { $phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content)); } if (false !== stripos($content_type, 'multipart') && !empty($boundary)) { $phpmailer->AddCustomHeader(sprintf("Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary)); } } if (!empty($attachments)) { foreach ($attachments as $attachment) { try { $phpmailer->AddAttachment($attachment); } catch (phpmailerException $e) { continue; } } } /** * Fires after PHPMailer is initialized. * * @since 2.2.0 * * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference. */ do_action_ref_array('phpmailer_init', array(&$phpmailer)); // Send! try { return $phpmailer->Send(); } catch (phpmailerException $e) { return false; } }
/** * @todo add port settings */ public function Send($EventName = '') { if (Gdn::Config('Garden.Email.UseSmtp')) { $this->PhpMailer->IsSMTP(); $SmtpHost = Gdn::Config('Garden.Email.SmtpHost', ''); $SmtpPort = Gdn::Config('Garden.Email.SmtpPort', 25); if (strpos($SmtpHost, ':') !== FALSE) { list($SmtpHost, $SmtpPort) = explode(':', $SmtpHost); } $this->PhpMailer->Host = $SmtpHost; $this->PhpMailer->Port = $SmtpPort; $this->PhpMailer->Username = $Username = Gdn::Config('Garden.Email.SmtpUser', ''); $this->PhpMailer->Password = $Password = Gdn::Config('Garden.Email.SmtpPassword', ''); if (!empty($Username)) { $this->PhpMailer->SMTPAuth = TRUE; } } else { $this->PhpMailer->IsMail(); } if ($EventName != '') { $this->EventArguments['EventName'] = $EventName; $this->FireEvent('SendMail'); } if (!$this->PhpMailer->Send()) { throw new Exception($this->PhpMailer->ErrorInfo); } return true; }