本文整理汇总了PHP中PHPMailer::AddAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::AddAttachment方法的具体用法?PHP PHPMailer::AddAttachment怎么用?PHP PHPMailer::AddAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::AddAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
public function sendMail($to, $subject, $body, $files = array())
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = EMAIL_SMTPSECURE;
$mail->Host = EMAIL_SMTPHOST;
$mail->Port = EMAIL_SMTPPORT;
$mail->Username = EMAIL_SMTPUSER;
$mail->Password = EMAIL_SMTPPASSWORD;
$mail->SetFrom(EMAIL_SENDER, EMAIL_SENDERNAME);
$mail->Subject = $subject;
foreach ($files as $file) {
$mail->AddAttachment($file, basename($file));
}
$mail->MsgHTML($body);
$mail->AddAddress($to);
ob_start();
$ok = $mail->Send();
$ob = ob_get_contents();
ob_end_clean();
if (!$ok) {
$this->error = $mail->ErrorInfo . "\n" . $ob;
$this->processError();
}
}
示例2: smtpmail
function smtpmail($to, $subject, $content, $attach = false)
{
require_once 'config_app.php';
require_once 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->Host = $__smtp['host'];
$mail->SMTPDebug = $__smtp['debug'];
$mail->SMTPAuth = $__smtp['auth'];
$mail->Host = $__smtp['host'];
$mail->Port = $__smtp['port'];
$mail->Username = $__smtp['username'];
$mail->Password = $__smtp['password'];
$mail->SetFrom($__smtp['addreply'], 'Mashkov Andrey');
$mail->AddReplyTo($__smtp['addreply'], $__smtp['username']);
$mail->AddAddress($to);
$mail->Subject = htmlspecialchars($subject);
$mail->CharSet = 'utf8';
$mail->MsgHTML($content);
if ($attach) {
$mail->AddAttachment($attach);
}
if (!$mail->Send()) {
$returner = "errorSend";
} else {
$returner = "okSend";
}
$mail->ClearAddresses();
$mail->ClearAttachments();
$mail->IsHTML(true);
return $returner;
}
示例3: sendMail
function sendMail($correoUsuario, $correoCliente, $archivo)
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = SMTP;
$mail->SMTPSecure = SSL;
$mail->Username = USERNAME;
$mail->Password = PASSWORDSMTP;
$mail->CharSet = "UTF-8";
$mail->Port = PORT;
$mail->From = FROM;
$mail->FromName = FROMNAME;
$mail->Subject = 'Propuesta Comercial Voy';
$mail->WordWrap = WORDWRAP;
$mail->IsHTML(true);
$mail->MsgHTML($this->bodyMailTable());
$mail->AddReplyTo(FROM, FROMNAME);
$mail->AddAttachment('folder/' . $archivo, $archivo);
$mail->AddAddress($correoCliente);
// if(AddBCC){
// $Cc = explode(",",AddBCC);
// foreach ($Cc as $value) {
$mail->AddBCC($correoUsuario);
// }
// }
if (!$mail->Send()) {
echo "Error de envío de email: " . $mail->ErrorInfo;
exit;
} else {
return;
}
}
示例4: sendMail
function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '')
{
try {
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "sm4.siteground.biz";
$mail->Port = 2525;
$mail->SMTPAuth = true;
$mail->SMTPDebug = 1;
// enables SMTP debug information (for testing)
// Enable SMTP authentication
$mail->Username = 'dileepkumarkonda@gmail.com';
// SMTP username
$mail->Password = 'samarasa@1234';
// SMTP password
$mail->IsHTML(true);
$mail->ClearAddresses();
$find = strpos($to, ',');
if ($find) {
$ids = explode(',', $to);
for ($i = 0; $i < count($ids); $i++) {
$mail->AddAddress($ids[$i]);
}
} else {
$mail->AddAddress($to);
}
if ($fromAddress != '') {
$mail->From = $fromAddress;
} else {
$mail->From = "dileepkumarkonda@gmail.com";
}
if ($fromUserName != '') {
$mail->FromName = $fromUserName;
} else {
$mail->FromName = "Video Collections";
}
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
if ($upload_dir != '') {
foreach ($upload_dir as $uploaddirs) {
$mail->AddAttachment($uploaddirs, $filename);
}
}
if ($mail->Send()) {
return 1;
} else {
return 0;
}
} catch (phpmailerException $e) {
echo $e->errorMessage();
//Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage();
//Boring error messages from anything else!
}
}
示例5: 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();
}
示例6: Send
function Send()
{
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->Host = $this->smtp['smtp_server'];
$mail->Port = $this->smtp['smtp_port'];
if ($this->smtp['smtp_enable']) {
$mail->IsSMTP();
$mail->Username = $this->smtp['smtp_usr'];
$mail->Password = $this->smtp['smtp_psw'];
$mail->SMTPAuth = $this->smtp['smtp_auth'] ? true : false;
}
if ($this->smtp['smtp_from_email']) {
$mail->SetFrom($this->smtp['smtp_from_email'], $this->smtp['smtp_from_name']);
} else {
$mail->SetFrom($this->smtp['smtp_server'], $this->smtp['smtp_usr']);
}
if (is_array($this->to)) {
foreach ($this->to as $key => $val) {
$name = is_numeric($key) ? "" : $key;
$mail->AddAddress($val, $name);
}
} else {
$mail->AddAddress($this->to, $this->to_name);
}
if (!empty($this->smtp['smtp_reply_email'])) {
$mail->AddReplyTo($this->smtp['smtp_reply_email'], $this->smtp['smtp_reply_name']);
}
if ($this->cc) {
if (is_array($this->cc)) {
foreach ($this->cc as $keyc => $valcc) {
$name = is_numeric($keyc) ? "" : $keyc;
$mail->AddCC($valcc, $name);
}
} else {
$mail->AddCC($this->cc, $this->cc_name);
}
}
if ($this->attach) {
if (is_array($this->attach)) {
foreach ($this->attach as $key => $val) {
$mail->AddAttachment($val);
}
} else {
$mail->AddAttachment($this->attach);
}
}
// $mail->SMTPSecure = 'ssl';
$mail->SMTPSecure = "tls";
$mail->WordWrap = 50;
$mail->IsHTML($this->is_html);
$mail->Subject = $this->subject;
$mail->Body = $this->body;
$mail->AltBody = "";
// return $mail->Body;
return $mail->Send();
}
示例7: attachFiles
public function attachFiles($filelist = array())
{
if (!$filelist) {
return;
}
$contentType = "application/octetstream";
foreach ($filelist as $file) {
$this->mail->AddAttachment($file['filepath'], $file['filename'], "base64", $contentType);
}
}
示例8: send
public function send()
{
global $DEVELOPMENT_MODE;
if ($DEVELOPMENT_MODE) {
return;
}
try {
if (!$this->textmsg) {
$this->textmsg = ' ';
}
if (!$this->htmlmsg) {
$this->htmlmsg = ' ';
}
require_once '/var/lib/asterisk/agi-bin/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
// sets the prefix to the servier
$mail->Host = "smtp.gmail.com";
// sets GMAIL as the SMTP server
$mail->Port = 587;
// set the SMTP port for the GMAIL server
$mail->Username = "xxxxxxxx@gmail.com";
// GMAIL username
$mail->Password = "xxxxx";
// GMAIL password
$mail->SetFrom('noreply@discreteevents.com', 'Asterisk @ Taaza Stores');
$mail->AddReplyTo('noreply@discreteevents.com', 'Asterisk @ Taaza Stores');
if (count($this->Attachments)) {
$attachmentCount = count($this->Attachments);
for ($t = 0; $t < $attachmentCount; $t++) {
if (@$this->AttachmentNames[$t]) {
$mail->AddAttachment($this->Attachments[$t], $this->AttachmentNames[$t]);
} else {
$mail->AddAttachment($this->Attachments[$t]);
}
}
}
if (count($this->BCCS)) {
foreach ($this->BCCS as $bccid) {
$mail->AddBCC($bccid);
}
}
$mail->AddAddress($this->mailto);
$mail->Subject = $this->subject;
$mail->AltBody = $this->textmsg;
$mail->MsgHTML($this->htmlmsg);
$mail->Send();
} catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例9: sendEmail
function sendEmail($to, $subject, $message, $from)
{
# initialize PHPMailer object
$mailer = new PHPMailer();
$mailer->From = $from;
$mailer->FromName = "Queens College Incubator";
$mailer->addAddress($to);
$mailer->Subject = $subject;
$mailer->Body = $message;
$mailer->AddAttachment($_FILES["unofficialTranscript"]["tmp_name"], $_FILES["unofficialTranscript"]["name"]);
$mailer->AddAttachment($_FILES["resume"]["tmp_name"], $_FILES["resume"]["name"]);
$mailer->send();
}
示例10: send_mail
/**
* +----------------------------------------------------------
* 功能:系统邮件发送函数
* +----------------------------------------------------------
* @param string $to 接收邮件者邮箱
* @param string $name 接收邮件者名称
* @param string $subject 邮件主题
* @param string $body 邮件内容
* @param string $attachment 附件列表
* +----------------------------------------------------------
* @param string $config
*
* @return boolean
+----------------------------------------------------------
*/
function send_mail($to, $name, $subject = '', $body = '', $attachment = null, $config = '')
{
// $config = is_array($config) ? $config : C('SYSTEM_EMAIL');
//从数据库读取smtp配置
$config = array('smtp_host' => C('smtp_host'), 'smtp_port' => C('smtp_port'), 'smtp_user' => C('smtp_user'), 'smtp_pass' => C('smtp_pass'), 'from_email' => C('from_email'), 'from_name' => C('title'));
include Extend_PATH . 'PHPMailer/phpmailer.class.php';
//从PHPMailer目录导phpmailer.class.php类文件
$mail = new PHPMailer();
//PHPMailer对象
$mail->CharSet = 'UTF-8';
//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP();
// 设定使用SMTP服务
// $mail->IsHTML(true);
$mail->SMTPDebug = 0;
// 关闭SMTP调试功能 1 = errors and messages2 = messages only
$mail->SMTPAuth = true;
// 启用 SMTP 验证功能
if ($config['smtp_port'] == 465) {
$mail->SMTPSecure = 'ssl';
}
// 使用安全协议
$mail->Host = $config['smtp_host'];
// SMTP 服务器
$mail->Port = $config['smtp_port'];
// SMTP服务器的端口号
$mail->Username = $config['smtp_user'];
// SMTP服务器用户名
$mail->Password = $config['smtp_pass'];
// SMTP服务器密码
$mail->SetFrom($config['from_email'], $config['from_name']);
$replyEmail = $config['reply_email'] ? $config['reply_email'] : $config['reply_email'];
$replyName = $config['reply_name'] ? $config['reply_name'] : $config['reply_name'];
$mail->AddReplyTo($replyEmail, $replyName);
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to, $name);
if (is_array($attachment)) {
// 添加附件
foreach ($attachment as $file) {
if (is_array($file)) {
is_file($file['path']) && $mail->AddAttachment($file['path'], $file['name']);
} else {
is_file($file) && $mail->AddAttachment($file);
}
}
} else {
is_file($attachment) && $mail->AddAttachment($attachment);
}
return $mail->Send() ? true : $mail->ErrorInfo;
}
示例11: send_mail_helper
function send_mail_helper($mailto, $subject, $mailcontent, $listfile = array())
{
require_once APPPATH . "helpers/phpmailer/class.phpmailer.php";
require_once APPPATH . "helpers/phpmailer/class.smtp.php";
$mail = new PHPMailer(true);
$mail->IsSMTP();
// telling the class to use SMTP
try {
$mail->Host = "ssl://smtp.gmail.com";
// SMTP server
$mail->SMTPDebug = false;
// enables SMTP debug information (for testing)
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->SMTPSecure = "SMTP";
// sets the prefix to the servier
$mail->Host = "ssl://smtp.gmail.com";
// sets GMAIL as the SMTP server
$mail->Port = 465;
// set the SMTP port for the GMAIL server
$mail->Username = "info@avila.vn";
// GMAIL username
$mail->Password = "dumxkbwohemojknb";
// GMAIL password
$mail->AddReplyTo('info@avila.vn', '' . $_SERVER['HTTP_HOST'] . '');
$mail->AddAddress($mailto, '0');
$mail->SetFrom('info@avila.vn', '' . $_SERVER['HTTP_HOST'] . '');
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
//$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->Body = $mailcontent;
// $mail->MsgHTML($mailcontent);
if (is_array($listfile)) {
foreach ($listfile as $f) {
$mail->AddAttachment($f);
}
} elseif (is_file($listfile)) {
$mail->AddAttachment($listfile);
}
$mail->Send();
return true;
} catch (phpmailerException $e) {
return $e->errorMessage();
//Pretty error messages from PHPMailer
} catch (Exception $e) {
return $e->getMessage();
//Boring error messages from anything else!
}
}
示例12: sendEmail
function sendEmail($to, $subject, $message, $from)
{
# initialize PHPMailer object
$mailer = new PHPMailer();
$mailer->From = $from;
$mailer->FromName = "Queens College Incubator";
$mailer->addAddress($to);
$mailer->Subject = $subject;
$mailer->Body = $message;
$mailer->AddAttachment($_FILES["execSummary"]["tmp_name"], $_FILES["execSummary"]["name"]);
$mailer->AddAttachment($_FILES["presentation"]["tmp_name"], $_FILES["presentation"]["name"]);
$mailer->AddAttachment($_FILES["bios"]["tmp_name"], $_FILES["bios"]["name"]);
$mailer->send();
}
示例13: send
/**
* sends an email using our configs
* @param string/array $to array(array('name'=>'chema','email'=>'chema@'),)
* @param [type] $to_name [description]
* @param [type] $subject [description]
* @param [type] $body [description]
* @param [type] $reply [description]
* @param [type] $replyName [description]
* @param [type] $file [description]
* @return boolean
*/
public static function send($to, $to_name = '', $subject, $body, $reply, $replyName, $file = NULL)
{
require_once Kohana::find_file('vendor', 'php-mailer/phpmailer', 'php');
$body = Text::bb2html($body, TRUE);
//get the template from the html email boilerplate
$body = View::factory('email', array('title' => $subject, 'content' => nl2br($body)))->render();
$mail = new PHPMailer();
$mail->CharSet = Kohana::$charset;
if (core::config('email.smtp_active') == TRUE) {
$mail->IsSMTP();
//SMTP HOST config
if (core::config('email.smtp_host') != "") {
$mail->Host = core::config('email.smtp_host');
// sets custom SMTP server
}
//SMTP PORT config
if (core::config('email.smtp_port') != "") {
$mail->Port = core::config('email.smtp_port');
// set a custom SMTP port
}
//SMTP AUTH config
if (core::config('email.smtp_auth') == TRUE) {
$mail->SMTPAuth = TRUE;
// enable SMTP authentication
$mail->Username = core::config('email.smtp_user');
// SMTP username
$mail->Password = core::config('email.smtp_pass');
// SMTP password
if (core::config('email.smtp_ssl') == TRUE) {
$mail->SMTPSecure = "ssl";
// sets the prefix to the server
}
}
}
$mail->From = core::config('email.notify_email');
$mail->FromName = "no-reply " . core::config('general.site_name');
$mail->Subject = $subject;
$mail->MsgHTML($body);
if ($file !== NULL) {
$mail->AddAttachment($file['tmp_name'], $file['name']);
}
$mail->AddReplyTo($reply, $replyName);
//they answer here
if (is_array($to)) {
foreach ($to as $contact) {
$mail->AddBCC($contact['email'], $contact['name']);
}
} else {
$mail->AddAddress($to, $to_name);
}
$mail->IsHTML(TRUE);
// send as HTML
if (!$mail->Send()) {
//to see if we return a message or a value bolean
Alert::set(Alert::ALERT, "Mailer Error: " . $mail->ErrorInfo);
return FALSE;
} else {
return TRUE;
}
}
示例14: sendMailSent
function sendMailSent($To, $From_Name, $From, $Body, $Subject, $CC_Arr, $attachments, $today)
{
# Let's valid the email address first
#$validEmailResult = validEmail($To);
#echo "validEmailResult = " . $validEmailResult;
#echo "\nValid Email address found: " . $To . " Return Code for valid email is: " . $validEmailResult . "\n";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.2gdigital.com";
$mail->SMTPAuth = false;
$mail->From = $From;
$mail->FromName = $From_Name;
$mail->AddAddress($To);
foreach ($CC_Arr as $CC_dude) {
if ($CC_dude != $To) {
$mail->AddAddress($CC_dude);
}
}
$mail->IsHTML(true);
$mail->Subject = $Subject;
$mail->Body = $Body;
foreach ($attachments as $attachment) {
echo "2nd Attachment " . $attachment;
$mail->AddAttachment($attachment);
}
if (!$mail->Send()) {
echo "Message could not be sent." . "\n";
echo "Mailer Error: " . $mail->ErrorInfo . "\n\n";
exit;
}
}
示例15: sendmail
function sendmail($to, $name, $subject = '', $body = '', $attachment = null){
vendor('PHPMailer.class#phpmailer'); //从PHPMailer目录导class.phpmailer.php类文件
$mail = new PHPMailer(); //PHPMailer对象
$mail->CharSet = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPDebug = 0; // 关闭SMTP调试功能
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->SMTPSecure = ''; // 使用安全协议
$mail->Host = C('email_server'); // SMTP 服务器
$mail->Port = C('email_port'); // SMTP服务器的端口号
$mail->Username = C('email_user'); // SMTP服务器用户名
$mail->Password = C('email_pwd'); // SMTP服务器密码
$mail->SetFrom(C('email_user'), C('pwd_email_title'));
$mail->AddReplyTo(C('email_user'), C('pwd_email_title'));
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to, $name);
if(is_array($attachment)){ // 添加附件
foreach ($attachment as $file){
is_file($file) && $mail->AddAttachment($file);
}
}
return $mail->Send() ? true : $mail->ErrorInfo;
}