本文整理汇总了PHP中PHPMailer::send方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::send方法的具体用法?PHP PHPMailer::send怎么用?PHP PHPMailer::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDuplicateIDNRemoved
/**
* Tests removal of duplicate recipients and reply-tos.
*/
public function testDuplicateIDNRemoved()
{
if (!$this->Mail->idnSupported()) {
$this->markTestSkipped('intl and/or mbstring extensions are not available');
}
$this->Mail->clearAllRecipients();
$this->Mail->clearReplyTos();
$this->Mail->CharSet = 'utf-8';
$this->assertTrue($this->Mail->addAddress('test@françois.ch'));
$this->assertFalse($this->Mail->addAddress('test@françois.ch'));
$this->assertTrue($this->Mail->addAddress('test@FRANÇOIS.CH'));
$this->assertFalse($this->Mail->addAddress('test@FRANÇOIS.CH'));
$this->assertTrue($this->Mail->addAddress('test@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addAddress('test@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addAddress('test@XN--FRANOIS-XXA.CH'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@françois.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@françois.ch'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@XN--FRANOIS-XXA.CH'));
$this->buildBody();
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
// There should be only one "To" address and one "Reply-To" address.
$this->assertEquals(1, count($this->Mail->getToAddresses()), 'Bad count of "to" recipients');
$this->assertEquals(1, count($this->Mail->getReplyToAddresses()), 'Bad count of "reply-to" addresses');
}
示例2: downloadpdfAction
/**
* PDF of a test order is downloaded by this method
*/
public function downloadpdfAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$id = $this->getRequest()->getParam('id', '');
$email = $this->getRequest()->getParam('email', 0);
require_once 'mpdf/mpdf.php';
$html .= $this->view->action('viewreport', 'patient', 'patient', array('id' => $id));
$mpdf = new mPDF('+aCJK', 'A4', '', '', 15, 15, 15, 0, 0, 0);
$mpdf->mirrorMargins = 0;
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->SetDisplayMode('fullwidth');
$mpdf->WriteHTML($html);
$fileName = 'PDF_Form' . time() . '.pdf';
$mpdf->Output('tmp/' . $fileName, $email ? 'F' : 'D');
if ($email) {
$patient = patient::getOrderById($id);
$mail = new PHPMailer();
$mail->From = 'kashif.ir@gmail.com';
$mail->FromName = 'Lab';
$mail->addAddress($patient[0]['email'], '');
$mail->addAttachment('tmp/' . $fileName);
$mail->Subject = 'Your Test Report';
$mail->Body = 'Please find attached report';
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
unlink('tmp/' . $fileName);
$flashMessenger = $this->_helper->getHelper('FlashMessenger');
$flashMessenger->addMessage('mail_sent');
$this->_redirect('/patient/orders');
}
}
}
示例3: mail
public static function mail($address, $title, $content)
{
if (empty($address)) {
return false;
}
$mail = new \PHPMailer();
//服务器配置
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'smtp.qq.com';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->CharSet = 'UTF-8';
//用户名设置
$mailInfo = Config::getConfig('mail_info');
$mailInfo = json_decode($mailInfo, true);
$mail->FromName = $mailInfo['fromName'];
$mail->Username = $mailInfo['userName'];
$mail->Password = $mailInfo['password'];
$mail->From = $mailInfo['from'];
$mail->addAddress($address);
//内容设置
$mail->isHTML(true);
$mail->Subject = $title;
$mail->Body = $content;
//返回结果
if ($mail->send()) {
return true;
} else {
return false;
}
}
示例4: send
/**
* Send email
* @param array $to
* @param array $from
* @param string $subject
* @param string $text
* @param bool $use_template
* @return bool
*/
public function send($to, $from, $subject, $text, $use_template = true)
{
$this->client->setFrom($from[1], $from[0]);
$this->client->addAddress($to[1], $to[0]);
$this->client->Subject = $subject;
if ($use_template) {
$template = '
<!DOCTYPE HTML>
<html dir="rtl">
<head>
<meta charset="utf-8">
</head>
<body style="font-family: tahoma, sans-serif !important;">
<div style="font: 13px tahoma,sans-serif !important;direction: rtl;background-color: #e8e8e8;">
<div style="width: 70%;background-color: #fff;background-color: #fff; border-radius: 3px;margin: auto;position: relative;border-left: 1px solid #d9d9d9;border-right: 1px solid #d9d9d9;">
<div style="top: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div>
<div style="padding: 22px 15px;">
{TEXT}
</div>
<div style="bottom: 0;position: absolute;width: 100%; height: 4px;background: url( \'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAECAYAAAD8kH0gAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P///xkGKFh27TfDkiu/GQiBKC1WhhgdVoLqXkzsZHje30ZQnUR+OYNkYRVWORZkxy0DOo6JgGERpDhuYgcDAxN+EyVyS3E6DgSYkB3HQG3HEQo5Ao4DO3AwOw4EAAIMAMZJM9nl1EbWAAAAAElFTkSuQmCC\' ) repeat;"></div>
</div>
</div>
</body>
</html>
';
$msg = str_replace('{TEXT}', $text, $template);
} else {
$msg = $text;
}
$this->client->msgHTML($msg);
return $this->client->send();
}
示例5: send
/**
* Envia o email usando smtp como servico default
*
* @return boolean
* @throws Exception
*/
public function send()
{
$this->chose_sender_strategy();
$this->configure_smtp_parameters();
try {
return $this->php_mailer->send();
} catch (phpmailerException $e) {
throw new Exception($e->getMessage());
}
}
示例6: sendLowPriceEmail
public function sendLowPriceEmail($productName, $productUrl, $currentPrice, $previousPrice)
{
$title = "Price Alert - " . $productName;
$msg = "Current price: " . $currentPrice . "<br/> Previous Price: " . $previousPrice;
$msg .= '<br/><br/> Get it now at: <a href="' . $productUrl . '">' . $productUrl . '</a>';
$this->_mailer->Subject = $title;
$this->_mailer->Body = $msg;
if (!$this->_mailer->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $this->_mailer->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
示例7: send
/**
* Send an email
*
* @param string $name Name
* @param string $email Email address
* @param string $subject Subject
* @param string $body Body
* @return boolean true if the email was sent successfully, false otherwise
*/
public static function send($name, $email, $subject, $body)
{
require dirname(dirname(__FILE__)) . '/vendors/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
//Set PHPMailer to use SMTP.
$mail->isSendMail();
//Set SMTP host name
$mail->Host = Config::SMTP_HOST;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = Config::SMTP_USER;
$mail->Password = Config::SMTP_PASS;
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = Config::SMTP_CERTIFICATE;
//Set TCP port to connect to
$mail->Port = Config::SMTP_PORT;
$mail->setFrom($email, $name);
$mail->addAddress(Config::SMTP_USER, Config::SMTP_NAME);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
}
示例8: send_email
function send_email() {
require_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'arshad.cyberlinks@gmail.com'; // SMTP username
$mail->Password = '31513119'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'arshad.faiyaz@cyberlinks.co.in';
$mail->FromName = 'Arshad Faiyaz';
$mail->addAddress('shekher.cyberlinks@gmail.com', 'Shekher CYberlinks'); // Add a recipient
//$mail->addAddress('anand.vyas@cyberlinks.in', 'Anand Sir'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information'); // Reply To.........
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->WordWrap = 50; // Set word wrap to 50 characters
//$mail->addAttachment('index.php'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'PHP Mailer Testing';
$mail->Body = 'This is the Succefull php Mailer Test <b>By Arshad</b>';
$mail->AltBody = 'Success';
if (!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
示例9: forgotPassword
function forgotPassword()
{
$targetEmail = $this->input->post('email');
$result = $this->users_model->emailVerif($targetEmail);
$url = site_url('/index/view');
if ($result == "Invalid") {
echo "<script>alert('Invalid email address.')</script>";
echo "<script> window.location = '{$url}'</script>";
} else {
$path = APPPATH;
echo "<script>alert('{$path}')</script>";
require_once APPPATH . '\\third_party\\mailer\\PHPMailerAutoload.php';
$m = new PHPMailer();
$m->isSMTP();
$m->SMTPAuth = true;
//$m->SMTPDebug = 2;
$m->Host = "smtp.gmail.com";
$m->Username = "umtwebsite@gmail.com";
$m->Password = "utilitymanagementteam";
$m->SMTPSecure = "ssl";
$m->Port = 465;
$m->From = "umtwebsite@gmail.com";
$m->FromName = "UMT";
$m->addAddress($targetEmail, "");
//$m->$addCC("karisuma1010@gmail.com", "UMT");
//$m->addBCC("karisuma1010@gmail.com", "UMT");
$m->Subject = "Password Recovery";
$m->Body = "Here is your password: '{$result}'. We recommend that you change it after logging-in.";
$m->send();
echo "<script>javascript:alert('Sent successfully')</script>";
echo "<script> window.location = '{$url}'</script>";
}
}
示例10: mailSend
/**
*
* @param array $from
* @param array $to
* @param array $replyTo Default is NULL
* @param string $subject
* @param string $body
* @return boolean
*/
function mailSend($from, $to, $replyTo = NULL, $subject = NULL, $body = NULL)
{
require_once APP_DIR . '/libs/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->From = $from['email'];
$mail->FromName = $from['name'];
$mail->addAddress($to);
$addresses = explode(',', $to);
foreach ($addresses as $address) {
$mail->addAddress($address);
}
if ($replyTo) {
$mail->addReplyTo($replyTo['email'], $replyTo['name']);
}
$mail->WordWrap = 50;
$mail->isHTML(FALSE);
if ($subject) {
$mail->Subject = $subject;
}
if ($body) {
$mail->Body = $body;
}
if ($mail->send()) {
return TRUE;
}
return FALSE;
}
示例11: send
private function send($email)
{
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->isHTML(true);
$mail->CharSet = 'UTF-8';
$mail->FromName = 'Портал Vidal.ru';
$mail->Subject = 'Отчет по пользователям Vidal';
$mail->Body = '<h2>Отчет содержится в прикрепленных файлах</h2>';
$mail->addAddress($email);
$mail->Host = '127.0.0.1';
$mail->From = 'maillist@vidal.ru';
// $mail->Host = 'smtp.mail.ru';
// $mail->From = '7binary@list.ru';
// $mail->SMTPSecure = 'ssl';
// $mail->Port = 465;
// $mail->SMTPAuth = true;
// $mail->Username = '7binary@list.ru';
// $mail->Password = 'ooo000)O';
$file = $this->getContainer()->get('kernel')->getRootDir() . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'download' . DIRECTORY_SEPARATOR . 'users.xlsx';
$mail->AddAttachment($file, 'Отчет Vidal: по всем пользователям.xlsx');
$prevMonth = new \DateTime('now');
$prevMonth = $prevMonth->modify('-1 month');
$prevMonth = intval($prevMonth->format('m'));
$file = $this->getContainer()->get('kernel')->getRootDir() . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'download' . DIRECTORY_SEPARATOR . "users_{$prevMonth}.xlsx";
$name = 'Отчет Vidal: за прошедший месяц - ' . $this->getMonthName($prevMonth) . '.xlsx';
$mail->AddAttachment($file, $name);
$mail->send();
}
示例12: sendmail
public static function sendmail($toList, $subject, $content)
{
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = self::SMTP_HOST;
$mail->SMTPAuth = true;
$mail->Username = self::SMTP_USER;
$mail->Password = self::SMTP_PASSWD;
$mail->SMTPSecure = self::SMTP_SECURE;
$mail->Port = self::SMTP_PORT;
$mail->Timeout = 3;
// seconds
$mail->From = self::MAIL_FROM;
$mail->CharSet = 'utf-8';
$mail->FromName = 'xxx';
// TODO
foreach ($toList as $to) {
$mail->addAddress($to);
}
//$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $content;
$mail->AltBody = $content;
if (!$mail->send()) {
Log::fatal('mailer error: ' . $mail->ErrorInfo);
return false;
}
return true;
}
示例13: sendmail
function sendmail($Email, $content)
{
date_default_timezone_set('Etc/UTC');
require "PHPMailer/PHPMailerAutoload.php";
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "bookmyprinterncku@gmail.com";
$mail->Password = "e8k9j9e1rz58";
$mail->setFrom('bookmyprinterncku@gmail.com', 'book printer');
$mail->addReplyTo('bookmyprinterncku@gmail.com', 'book printer');
$mail->addAddress($Email, ' ');
if (!strcmp($content, 'GETKEY')) {
$mail->Subject = 'bookmyprinter verification mail';
$key = rand(1, 999999);
$mail->Body = '你的認證碼是: ' . $key;
} else {
$mail->Subject = 'bookmyprinter user report';
$mail->Body = $content;
}
$mail->SMTPDebug = 0;
$mail->send();
if (!strcmp($content, 'GETKEY')) {
return $key;
} else {
return 1;
}
}
示例14: EnviarCorreo
public function EnviarCorreo(CorreosDTO $dto)
{
$mail = new PHPMailer();
$mail->isSMTP();
//Correo del remitente
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = $dto->getRemitente();
$mail->Password = $dto->getContrasena();
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->CharSet = 'UTF-8';
$mail->setFrom($dto->getRemitente(), $dto->getNombreRemitente());
//Correo del destinatario
$mail->addAddress($dto->getDestinatario());
$mail->addReplyTo($dto->getRemitente(), $dto->getNombreRemitente());
$mail->addAttachment($dto->getArchivos());
//Adjuntar Archivos
$mail->isHTML(true);
$mail->Subject = $dto->getAsunto();
//Cuerpo del correo
$mail->Body = $dto->getContenido();
if (!$mail->send()) {
$mensaje2 = 'No se pudo enviar el correo ' . 'Error: ' . $mail->ErrorInfo;
} else {
$mensaje2 = 'True';
}
return $mensaje2;
}
示例15: gogo
public function gogo($email)
{
$mail = new PHPMailer();
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'mail.your-server.de';
// Specify main and backup server
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'no-reply@matchday.biz';
// SMTP username
$mail->Password = '11zRyyWMel79g2fO';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable encryption, 'ssl' also accepted
$mail->Port = 25;
//Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('no-reply@matchday.biz', 'Matchday');
//Set who the message is to be sent from
$mail->addAddress($email);
// Add a recipient
$mail->isHTML(true);
// Set email format to HTML
$mail->CharSet = 'UTF-8';
$text = "Информация по инциденту 22.01.2016";
$text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
$mail->Subject = $text;
$mail->Body = "Уважаемые пользователи ресурса matchday.biz! <br/><br/>\n\t\t\n\t\tБез всякого предупреждения нас отключили от хостинга. Хостер (немецкая компания hetzner.de) обнаружил перегрузку сервера, связанную с многочисленными запросами, идущими на наш сайт со стороннего адреса и отключил нас, отказавшись далее разбираться до понедельника.\n\t\tНаши специалисты диагностировали проблему и выяснили, что запросы идут с пула IP адресов ТОГО ЖЕ хостера – то есть, от него самого, что свидетельствует о том, что у хостера просто некорректно налажена работа самого хостинга.\n\t\tТехподдержка с нами отказалась работать после 18-00 пятницы немецкого времени, и сайт matchday.biz будет теперь гарантировано лежать до середины дня понедельника, 25 января.\n\t\t(желающие прочитать про очень похожий случай с этим же хостером могут сделать это тут).<br/><br/>\n\t\t\n\t\tНезависимо от того, чем закончится эта история, мы будем менять хостера, но локальная задача – включить сайт, чем мы и будем заниматься, увы, теперь только в понедельник.\n\t\tМы очень извиняемся за неудобства, причиненные этой историей, которая полностью находится вне нашего контроля.<br/><br/>\n\t\t\n\t\tПодкаст по итогам 23го тура будет записан авторами в воскресение и будет опубликован, как только сайт станет доступным.\n\t\tНи бетмен-лайв, ни фэнтэзи-лайв в23м туре провести не представляется возможным.<br/>\n\t\tВ бетмене все ставки будут засчитаны.<br/><br/>\n\t\t\n\t\tО доступности сайта мы немедленно вас проинформируем, в том числе и на сайте arsenal-blog.com.<br/><br/>\n\t\t\n\t\t\n\t\tАдминистрация matchday.biz";
if (!$mail->send()) {
return false;
}
return true;
}