本文整理汇总了PHP中PHPMailer::addAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::addAttachment方法的具体用法?PHP PHPMailer::addAttachment怎么用?PHP PHPMailer::addAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::addAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
}
示例2: send
function send()
{
$registry = Registry::getInstance();
$site_root_absolute = $registry->get('site_root_absolute');
$mail = new PHPMailer();
# $mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'smtp-relay.gmail.com;smtp.gmail.com';
// Specify main and backup SMTP servers
# $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'info@mmotoracks.com';
// SMTP username
$mail->Password = 'mmotoracks321';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
// TCP port to connect to
$mail->isHTML(true);
// Set email format to HTML
$mail->setFrom($this->from);
$mail->addAddress($this->to);
// Add a recipient
# $mail->addAddress('ellen@example.com'); // Name is optional
if ($this->reply) {
$mail->addReplyTo($this->reply);
}
# $mail->addCC('cc@example.com');
$mail->addBCC('mmoto@jne21.com');
$mail->Subject = $this->subject;
$mail->Body = $this->html;
$mail->AltBody = $this->text;
if (is_array($this->attachments)) {
foreach ($this->attachments as $attach) {
$mail->addAttachment($site_root_absolute . self::BASE_PATH . $this->id . EmailTemplateAttahchment::PATH . $attach->filename);
}
}
if (is_array($this->images)) {
foreach ($this->images as $image) {
$mail->addAttachment($site_root_absolute . self::BASE_PATH . $this->id . EmailTemplateEmbedded::PATH . $image->filename, $image->cid, 'base64', null, 'inline');
}
}
foreach ($this->makeHeaders($this->headers) as $name => $value) {
$mail->addCustomHeader($name, $value);
}
$result = $mail->send();
if (!$result) {
$this->errorInfo = $mail->ErrorInfo;
}
return $result;
}
示例3: sendEmail
function sendEmail($force, $clients, $subject, $body, $resources = array())
{
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = SMTP_HOST;
$mail->SMTPAuth = true;
$mail->Username = EMAIL;
$mail->Password = PASSWORD;
$mail->SMTPSecure = SMTP_SECURE;
$mail->Port = SMTP_PORT;
$mail->setFrom(EMAIL, 'The cat long');
$mail->isHTML(true);
$mail->Subject = $subject;
foreach ($clients as $client) {
if (EMAIL != $client['email'] && !empty($client['news']) || !!$force) {
$mail->addAddress($client['email']);
}
}
$mail->Body = $body;
foreach ($resources as $i) {
if (!isset($i['absolute'])) {
$mail->addAttachment(IMGS . $i['path']);
} else {
$mail->addAttachment($i['path']);
}
}
$mail->AltBody = $body;
if ($mail->send()) {
flash('msg', 'Su email se ha enviado correctamente', 'Notificación');
return header('location: /');
}
}
示例4: email_helper
function email_helper($sender, $subject, $message, $attachment1, $attachment2)
{
//if(isset($_POST['add-device'])){
//Send Mail
require 'phpMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
//$mail->SMTPDebug = 3; // Enable verbose debug output
$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 = 'nddcb1@gmail.com';
// SMTP username
$mail->Password = 'ashan!@#$%';
// SMTP password
$mail->SMTPSecure = 'ssl';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;
// TCP port to connect to
$mail->From = 'nddcb1@gmail.com';
$mail->FromName = 'National Dangerous Drug Control Board-Sri Lanka';
$mail->addAddress($sender);
// Add a recipient
$mail->addReplyTo('nddcb1@gmail.com', 'Support');
//$mail->addCC('jro@ucsc.cmb.ac.lk');
//$mail->addBCC('vsh@ucsc.cmb.ac.lk');
$mail->isHTML(true);
// Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = 'ffff';
if (!empty($attachment1)) {
$mail->addAttachment($attachment1);
}
if (!empty($attachment2)) {
$mail->addAttachment($attachment2);
}
if (!$mail->send()) {
//echo 'Message could not be sent.';
//echo 'Mailer Error: ' . $mail->ErrorInfo;
return false;
} else {
//echo 'Message has been sent';
return true;
}
//}else{
// $msg = "<div class='alert alert-danger' role='alert'>Error Adding Device</div>";
//}
}
示例5: sendEmail
function sendEmail($addressArray, $subject, $body, $altBody, $theFile = Null, $fileName = Null)
{
$mail = new PHPMailer();
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = $mail->From = 'bkInfo@balkamp.com';
$mail->FromName = "BK Info";
foreach ($addressArray as $address) {
$mail->addAddress($address);
// Add a recipient
}
$mail->WordWrap = 50;
// Set word wrap to 50 characters
for ($i = 0; $i < count($theFile); $i++) {
$mail->addAttachment($theFile[$i], $fileName[$i]);
}
$mail->isHTML(true);
// Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $altBody;
if (!$mail->send()) {
$response['success'] = false;
$response['error'] = $mail->ErrorInfo;
return $response;
} else {
$response['success'] = true;
return $response;
}
}
示例6: send
/**
* Sends the email
*
* @return bool
*/
public function send()
{
try {
$this->configure();
$this->phpMailer->Subject = $this->generateSubject();
if (is_array($this->from) === true) {
$this->phpMailer->setFrom($this->from['email'], $this->from['name']);
} else {
$this->phpMailer->setFrom($this->from);
}
$this->generateBody();
// Add attachments to the E-mail
if (count($this->attachments) > 0) {
foreach ($this->attachments as $attachment) {
if (!empty($attachment) && is_file($attachment)) {
$this->phpMailer->addAttachment($attachment);
}
}
}
if (!empty($this->recipients)) {
return $this->bcc === true ? $this->sendBcc() : $this->sendTo();
}
} catch (\phpmailerException $e) {
$this->logger->error('mailer', $e);
} catch (\Exception $e) {
$this->logger->error('mailer', $e);
}
return false;
}
示例7: 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;
}
示例8: sendmail
public function sendmail()
{
//trebalo bi ovako nesto da ide ja sam otvorio ovaj mail nalog i dodelio mu ovaj password
$mail = new PHPMailer();
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com';
// Specify main and backup SMTP servers
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'admin@creativeeweb.com';
// SMTP username
$mail->Password = 'VmQi5yPJNC-7TPhCUry8Lw';
// SMTP password
$mail->SMTPSecure = 'tls';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
// TCP port to connect to
$mail->From = $this->from_email;
$mail->FromName = 'Agencija SHOPKO';
$mail->addAddress($this->to_email);
// Add a recipient
$mail->addReplyTo('office@shopko.rs');
$mail->isHTML(true);
$mail->Subject = $this->subject_str;
$mail->Body = $this->setup_message();
if (null !== $this->attachment) {
foreach ($this->attachment as $a) {
$mail->addAttachment($a);
}
}
//slanje
$mail->send();
//mail($this->to_email, $this->subject_str, $this->setup_message(), $this->setup_headers());
}
示例9: send
public static function send($to_email, $reply_email, $reply_name, $from_email, $from_name, $subject, $body, $attachments = array())
{
if (Configuration::model()->emailer->relay == 'SMTP') {
$email = new \PHPMailer();
//$email->SMTPDebug = 4;
$email->isSMTP();
$email->Host = Configuration::model()->emailer->host;
$email->SMTPAuth = Configuration::model()->emailer->auth;
$email->Username = Configuration::model()->emailer->username;
$email->Password = Configuration::model()->emailer->password;
$email->SMTPSecure = Configuration::model()->emailer->security;
$email->Port = Configuration::model()->emailer->port;
}
$email->addAddress($to_email);
$email->addReplyTo($reply_email, $reply_name);
$email->setFrom($from_email, $from_name);
$email->Subject = $subject;
$email->Body = $body;
$email->msgHTML($body);
$email->AltBody = strip_tags(str_replace('<br>', "\n\r", $body));
if (is_array($attachments)) {
foreach ($attachments as $value) {
$email->addAttachment($value);
}
}
$email->send();
}
示例10: send_email
public static function send_email($subject, $message, $attachment_file = '', $send_to_email = '')
{
require_once APPPATH . 'third_party/PHPMailer/PHPMailerAutoload.php';
$ci =& get_instance();
$ci->config->load('my_email');
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->isSMTP();
$mail->Host = $ci->config->item('smtp_host');
$mail->Port = $ci->config->item('smtp_port');
$mail->SMTPAuth = true;
$mail->SMTPSecure = $ci->config->item('smtp_secure');
$mail->Username = $ci->config->item('smtp_user');
$mail->Password = $ci->config->item('smtp_pass');
$mail->From = $ci->config->item('smtp_user');
$mail->FromName = $ci->config->item('from_name');
if (!empty($attachment_file)) {
$mail->addAttachment($attachment_file);
}
$mail->addAddress($send_to_email);
$mail->Subject = $subject;
$mail->IsHTML(true);
$mail->Body = $message;
$mail->AltBody = "text/html";
if (!$mail->send()) {
log_message('error', $mail->ErrorInfo);
return "false";
}
return 'true';
}
示例11: attach
/**
* Прикрепление файлов к письму
*
* @param array|string $data
*
* @return void
*/
public function attach($data)
{
$data = !is_array($data) ? (array) $data : $data;
foreach ($data as $file) {
$this->PHPMailer->addAttachment($file);
}
}
示例12: dumpDBAction
/**
* @Route("/dump_db", name="dump_db")
* @Security("has_role('ROLE_ADMIN')")
*/
public function dumpDBAction()
{
$path = $this->get('kernel')->getRootDir() . '/../web';
$backupFile = $path . '/backup/renoart_5_' . date("Y-m-d") . '.sql';
$mail = new \PHPMailer();
$mail->setFrom('reno@art.pl', 'RenoArt');
$mail->addAddress('abusay8@gmail.com');
// $mail->addAddress('scibisz.piotr@gmail.com');
$mail->Subject = 'Baza danych z ' . date("Y-m-d");
$mail->Body = 'Baza danych z ' . date("Y-m-d") . ' jest w załączniku.';
$mail->addAttachment($backupFile);
if ($mail->send()) {
$this->addFlash('notice', 'E-mail z kopią bazy danych został wysłany.');
}
// $response = new Response();
// // Set headers
// $response->headers->set('Cache-Control', 'private');
// $response->headers->set('Content-type', mime_content_type($backupFile));
// $response->headers->set('Content-Disposition', 'attachment; filename="' . basename($backupFile) . '";');
// $response->headers->set('Content-length', filesize($backupFile));
//
// // Send headers before outputting anything
// $response->sendHeaders();
//
// $response->setContent(file_get_contents($backupFile));
return $this->redirect($this->generateUrl('homepage'));
}
示例13: sendMail
function sendMail($to, $subject, $html, $files = false)
{
$mail = new PHPMailer();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
# ssl / tls
$mail->Port = '465';
# 465 / 587
$mail->Username = MAILUSER;
$mail->Password = MAILPASS;
$mail->CharSet = 'UTF-8';
$mail->From = 'no-reply@lagerkvist.eu';
$mail->FromName = 'Lagerkvist.eu';
$mail->addAddress('powerbuoy@gmail.com');
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $html;
$mail->AltBody = strip_tags($html);
if (is_array($files) and count($files)) {
foreach ($files as $path => $name) {
$mail->addAttachment($path, $name);
}
}
if ($mail->send()) {
return true;
} else {
return $mail->ErrorInfo;
}
}
示例14: mailsend
function mailsend($subjects, $emailto, $file1, $body, $fName, $lName)
{
$mail = new PHPMailer();
$mail->Host = 'smtp.gmail.com';
// Specify main and backup SMTP servers
$mail->isSMTP();
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->Username = 'electroshopsender@gmail.com';
// SMTP username
$mail->Password = 'amanaman123';
// SMTP password
$mail->SMTPSecure = 'ssl';
// Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;
// TCP port to connect to
$mail->From = "electroshopsender@gmail.com";
$mail->FromName = "ElectroShop Newsletter";
$mail->addAddress($emailto);
//Recipient //Name is optional
$mail->Subject = $subjects;
$mail->Body = $body;
$mail->addReplyTo('electroshopsender@gmail.com', 'ElectroShop Admin');
$mail->isHTML(true);
$file = $file1;
$mail->addAttachment($file, 'ElectroShop Newsletter');
if (!$mail->send()) {
// echo "Mailer Error: " . $mail->ErrorInfo;
} else {
}
}
示例15: send
public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
{
if (!$this->enabled) {
return;
}
$isHtml = stripos($message, "<html>") !== FALSE;
$f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
$validRecipients = $this->getValidRecipients($to);
if (count($validRecipients) === 0) {
Logging::logDebug("No valid recipient email addresses, no mail sent");
return;
}
if (Logging::isDebug()) {
Logging::logDebug("Sending mail from [" . $f . "] to [" . Util::array2str($validRecipients) . "]: [" . $message . "]");
}
set_include_path("vendor/PHPMailer" . DIRECTORY_SEPARATOR . PATH_SEPARATOR . get_include_path());
require 'class.phpmailer.php';
$mailer = new PHPMailer();
$smtp = $this->env->settings()->setting("mail_smtp");
if ($smtp != NULL and isset($smtp["host"])) {
$mailer->isSMTP();
$mailer->Host = $smtp["host"];
if (isset($smtp["username"]) and isset($smtp["password"])) {
$mailer->SMTPAuth = true;
$mailer->Username = $smtp["username"];
$mailer->Password = $smtp["password"];
}
if (isset($smtp["secure"])) {
$mailer->SMTPSecure = $smtp["secure"];
}
}
$mailer->From = $f;
foreach ($validRecipients as $recipient) {
$mailer->addBCC($recipient["email"], $recipient["name"]);
}
if (!$isHtml) {
$mailer->WordWrap = 50;
} else {
$mailer->isHTML(true);
}
if ($attachments != NULL) {
//TODO use stream
foreach ($attachments as $attachment) {
$mailer->addAttachment($attachment);
}
}
$mailer->Subject = $subject;
$mailer->Body = $message;
try {
if (!$mailer->send()) {
Logging::logError('Message could not be sent: ' . $mailer->ErrorInfo);
return FALSE;
}
return TRUE;
} catch (Exception $e) {
Logging::logError('Message could not be sent: ' . $e);
return FALSE;
}
}