Exemplo n.º 1
6
 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;
     }
 }
Exemplo n.º 2
3
 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();
     }
 }
Exemplo n.º 3
1
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 = '******';
        // SMTP username
        $mail->Password = '******';
        // 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 = "*****@*****.**";
        }
        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!
    }
}
Exemplo n.º 4
0
 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 = '*****@*****.**';
     //			$mail->Host       = 'smtp.mail.ru';
     //			$mail->From       = '*****@*****.**';
     //			$mail->SMTPSecure = 'ssl';
     //			$mail->Port       = 465;
     //			$mail->SMTPAuth   = true;
     //			$mail->Username   = '******';
     //			$mail->Password   = '******';
     $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();
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 public function attachFiles($filelist = array())
 {
     if (!$filelist) {
         return;
     }
     $contentType = "application/octetstream";
     foreach ($filelist as $file) {
         $this->mail->AddAttachment($file['filepath'], $file['filename'], "base64", $contentType);
     }
 }
Exemplo n.º 7
0
 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 = "******";
         // GMAIL username
         $mail->Password = "******";
         // GMAIL password
         $mail->SetFrom('*****@*****.**', 'Asterisk @ Taaza Stores');
         $mail->AddReplyTo('*****@*****.**', '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();
     }
 }
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();
}
Exemplo n.º 9
0
/**
* +----------------------------------------------------------
* 功能:系统邮件发送函数
* +----------------------------------------------------------
* @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;
}
Exemplo n.º 10
0
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();
}
Exemplo n.º 11
0
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 = "******";
        // GMAIL username
        $mail->Password = "******";
        // GMAIL password
        $mail->AddReplyTo('*****@*****.**', '' . $_SERVER['HTTP_HOST'] . '');
        $mail->AddAddress($mailto, '0');
        $mail->SetFrom('*****@*****.**', '' . $_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!
    }
}
Exemplo n.º 12
0
	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;
	}
Exemplo n.º 13
0
 function kdmail($f)
 {
     $this->load('lib/phpmailer/class.phpmailer');
     $mail = new PHPMailer();
     //$body             = $mail->getFile(ROOT.'index.php');
     //$body             = eregi_replace("[\]",'',$body);
     $mail->IsSendmail();
     // telling the class to use SendMail transport
     $mail->From = $f["from"];
     $mail->FromName = either($f["fromname"], "noticer");
     $mail->Subject = either($f["subject"], "hello");
     //$mail->AltBody = either($f["altbody"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test
     $mail->AltBody = either($f["msg"], "To view the message, please use an HTML compatible email viewer!");
     // optional, comment out and test
     if ($f["embedimg"]) {
         foreach ($f["embedimg"] as $i) {
             //$mail->AddEmbeddedImage(ROOT."public/images/logo7.png","logo","logo7.png");
             $mail->AddEmbeddedImage($i[0], $i[1], $i[2]);
         }
     }
     if ($f["msgfile"]) {
         $body = $mail->getFile($f["msgfile"]);
         $body = eregi_replace("[\\]", '', $body);
         if ($f["type"] == "text") {
             $mail->IsHTML(false);
             $mail->Body = $body;
         } else {
             $mail->MsgHTML($body);
             //."<br><img src= \"cid:logo\">");
         }
     } else {
         if ($f["type"] == "text") {
             $mail->IsHTML(false);
             $mail->Body = $f["msg"];
         } else {
             $mail->MsgHTML($f["msg"]);
             //."<br><img src= \"cid:logo\">");
         }
     }
     if (preg_match('/\\,/', $f["to"])) {
         $emails = explode(",", $f["to"]);
         foreach ($emails as $i) {
             $mail->AddAddress($i, $f["toname"]);
         }
     } else {
         $mail->AddAddress($f["to"], $f["toname"]);
     }
     $mail->AddBCC($this->config["site"]["mail"], "bcc");
     if ($f["files"]) {
         foreach ($f["files"] as $i) {
             $mail->AddAttachment($i);
             // attachment
         }
     }
     if (!$mail->Send()) {
         return "Mailer Error: " . $mail->ErrorInfo;
     } else {
         return "Message sent!";
     }
 }
Exemplo n.º 14
0
function sendMail($nomeDestino, $emailDestino, $nomeRemetente, $emailRemetente, $assunto, $msg, $arquivo = "")
{
    require_once str_replace("admin/", "", DIR) . "system/PHPMailer/PHPMailer.php";
    #$nomeDestino = Nome de quem vai receber
    #$emailDestino = E-mail de quem vai receber
    #$nomeRemetente = Nome de quem está enviando
    #$emailRemetente = E-mail de quem está enviando
    #$assunto = Assunto do e-mail
    #$msg = Mensagem do e-mail
    $montaMsg = '<div style="text-align: left"><img src="' . str_replace("admin", "", CP) . '/assets/img/header_mail.jpg" alt="Header" /></div>';
    $montaMsg .= '<br /><div style="font-family: Arial; color: #666; font-size: 14px;">' . $msg . '<br /><br />';
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPDebug = 0;
    $mail->Debugoutput = 'html';
    $mail->Host = getSys("smtpHost");
    $mail->Port = getSys("smtpPort");
    $mail->SMTPAuth = true;
    $mail->Username = getSys("smtpLogin");
    $mail->Password = getSys("smtpPass");
    $mail->SetFrom(getSys("smtpLogin"), $nomeRemetente);
    $mail->addReplyTo($emailRemetente, $nomeRemetente);
    $mail->AddAddress($emailDestino, $nomeDestino);
    $mail->Subject = $assunto;
    $mail->msgHTML($montaMsg);
    if ($arquivo == true) {
        $mail->AddAttachment($arquivo);
    }
    if (!$mail->send()) {
        return false;
    } else {
        return true;
    }
}
 public static function sendMail($to, $title, $message, $from = null, $fromName = null, $attachments = array())
 {
     Core::loadClass('Core.Net.Mail.PHPMailer');
     $mail = new PHPMailer();
     $mail->AddAddress($to);
     $mail->Body = $message;
     $mail->CharSet = Config::get('intl.charset');
     $mail->Subject = $title;
     if ($from != null) {
         $mail->From = $from;
     } else {
         $mail->From = Config::get('general.email');
     }
     if ($fromName != null) {
         $mail->FromName = $fromName;
     } else {
         $mail->FromName = Config::get('general.title');
     }
     if (count($attachments) > 0) {
         foreach ($attachments as $file) {
             $mail->AddAttachment($file);
         }
     }
     if (Config::get('core.debug') == 1) {
         var_dump($to, $title, $message, $from, $fromName, $attachments);
     } else {
         $mail->Send();
     }
 }
Exemplo n.º 16
0
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;
    }
}
Exemplo n.º 17
0
function sendmail($subject, $message, $file)
{
    $subscribers = getBelongingItemsFromDB('subscribers', '1', 'lectures');
    for ($i = 0; $i < count($subscribers); $i++) {
        $mail = new PHPMailer();
        $mail->From = "joanna.smiglak.cbi.uni-erlangen.de";
        $mail->Sender = "joanna.smiglak.cbi.uni-erlangen.de";
        $mail->FromName = "Joanna Smiglak";
        $mail->AddAddress($subscribers[$i]['address']);
        $mail->WordWrap = 50;
        // set word wrap to 50 characters
        $mail->AddAttachment($file, "Aushang.pdf");
        // optional name
        $mail->IsHTML(true);
        // set email format to HTML
        $mail->Subject = $subject;
        $mail->Body = $message;
        //$mail->AltBody = $message;
        if (!$mail->Send()) {
            echo "Message could not be sent. <p>";
            echo "Mailer Error: " . $mail->ErrorInfo;
            exit;
        }
        echo "Message has been sent to " . $subscribers[$i]['address'] . "<br>";
    }
}
Exemplo n.º 18
0
function sendmail($file, $emailid)
{
    $email = new PHPMailer();
    $email->SetFrom('*****@*****.**', "Picxel");
    $email->FromName = 'Picxel';
    $email->AddReplyTo('*****@*****.**', 'no-reply');
    $email->Subject = 'your resized images';
    $email->MsgHTML("test");
    $email->AddAddress($emailid);
    $email->CharSet = 'UTF-8';
    $email->IsSMTP();
    $email->Host = 'smtp.gmail.com';
    $email->SMTPSecure = 'tls';
    $email->Port = 587;
    $email->SMTPDebug = 1;
    $email->SMTPAuth = false;
    //set it to true to work
    $email->Username = '******';
    //changeit to mail id
    $email->Password = '******';
    // give exact password of mailid
    $email->SMTPDebug = 0;
    $file_to_attach = $file;
    $email->AddAttachment($file_to_attach);
    $email->Send();
}
Exemplo n.º 19
0
function send_mail($to, $subject, $content, $addreply = null, $attach = false)
{
    require_once 'config.php';
    require_once 'class.phpmailer.php';
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    try {
        $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->AddAddress($to);
        $mail->SetFrom($__smtp['username'], $__smtp['fromname']);
        if (!empty($addreply)) {
            $mail->AddReplyTo($addreply, $addreply);
        } else {
            $mail->AddReplyTo($__smtp['addreply'], $__smtp['fromname']);
        }
        $mail->Subject = htmlspecialchars($subject);
        $mail->MsgHTML($content);
        if ($attach) {
            $mail->AddAttachment($attach);
        }
        return $mail->Send();
    } catch (phpmailerException $e) {
        //echo $e->errorMessage();
        return false;
    } catch (Exception $e) {
        //echo $e->getMessage();
        return false;
    }
}
Exemplo n.º 20
0
 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";
     }
 }
Exemplo n.º 21
0
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
}
Exemplo n.º 22
0
function emailSend($to, $subject, $title, $message, $anexo = false)
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 2;
    $mail->SMTPAuth = true;
    $mail->Host = "mail.gypanews.com.br";
    $mail->Mailer = 'smtp';
    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465;
    $mail->IsHTML(true);
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->SetFrom("*****@*****.**", "Gypa News");
    $mail->Subject = $subject;
    $mail->addReplyTo("*****@*****.**", "Gypa News");
    $html = file_get_contents('template.html', true);
    $html = str_replace("#TITLE#", $title, $html);
    $html = str_replace("#MESSAGE#", $message, $html);
    foreach ($to as $t) {
        $mail->addAddress($t['email'], $t['nome']);
    }
    $mail->Body = $html;
    if ($anexo) {
        $mail->AddAttachment($anexo);
    }
    if (!$mail->Send()) {
        return array("erro" => true, "msg" => $mail->ErrorInfo);
    } else {
        return array("erro" => false);
    }
}
Exemplo n.º 23
0
 public static function Enviar($asunto, $mensaje, $destinatario, $nombredestinatario, $archivo = array())
 {
     $config = XTConfig::singleton();
     $mail = new PHPMailer();
     if ($config->get(XTSITE_SMTP)) {
         $mail->IsSMTP();
     }
     if ($config->get(XTSITE_SMTP_AUTH)) {
         $mail->SMTPAuth = true;
     }
     $mail->SMTPSecure = $config->get(XTSITE_SMTP_SECURE);
     $mail->Host = $config->get(XTSITE_SMTP_SERVER);
     $mail->Port = $config->get(XTSITE_SMTP_PORT);
     $mail->Username = $config->get(XTSITE_SMTP_USER);
     $mail->Password = $config->get(XTSITE_SMTP_PASSWORD);
     $mail->From = $config->get(XTSITE_SMTP_FROM);
     $mail->FromName = $config->get(XTSITE_SMTP_FROMNAME);
     $mail->Subject = "{$asunto}";
     $mail->MsgHTML("{$mensaje}");
     $mail->AddAddress("{$destinatario}", "{$nombredestinatario}");
     $mail->IsHTML(true);
     if (count($archivo) > 0) {
         foreach ($archivo as $miarchivo) {
             if (file_exists($miarchivo)) {
                 $mail->AddAttachment($miarchivo);
             }
         }
     }
     $transret = $mail->Send();
     if ($transret != true) {
         //echo $mail->ErrorInfo;
     }
     return $transret;
 }
Exemplo n.º 24
0
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;
}
Exemplo n.º 25
0
/**
	Тестирование отправки письма с реального сервера
*/
function smtpmail($to, $subject, $content, $attach = false)
{
    require_once 'config.php';
    require_once 'class.phpmailer.php';
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    //echo $to."<br />".$subject."<br />".$content."<br />";
    $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'], $__smtp['username']);
    $mail->SetFrom($__smtp['addreply'], 'www.ori-list.ru');
    // Имя отправителя
    $mail->AddReplyTo($__smtp['addreply'], $__smtp['username']);
    $mail->AddAddress($to);
    $mail->Subject = htmlspecialchars($subject);
    //$mail->CharSet='cp1251'; //кодировка письма
    $mail->CharSet = 'utf-8';
    //кодировка письма
    $mail->MsgHTML($content);
    if ($attach) {
        $mail->AddAttachment($attach);
    }
    $mail->Send();
    // echo "Message sent Ok!</p>\n";
}
Exemplo n.º 26
0
 /**
  * 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;
     }
 }
Exemplo n.º 27
0
 public function send()
 {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPDebug = 0;
     $mail->Host = 'smtp.gmail.com';
     $mail->SMTPAuth = true;
     $mail->Username = $this->data['correoEmisor'];
     $mail->Password = $this->data['contrasena'];
     $mail->SMTPSecure = 'ssl';
     $mail->Port = 465;
     $mail->From = $this->data['correoEmisorEm'];
     $mail->FromName = $this->data['nombreEmisor'];
     foreach ($this->data['correoDestino'] as $correoDestino) {
         $mail->AddAddress(trim($correoDestino), $this->data['nombreDestino']);
     }
     $mail->AddReplyTo($this->data['correoEmisorEm'], $this->data['nombreEmisor']);
     $mail->AddCC($this->data['cc']);
     $mail->IsHTML(true);
     $mail->Subject = $this->data['asunto'];
     $mail->MsgHTML($this->data['body']);
     $mail->AltBody = $this->data['altBody'];
     // Si se enviaran archivos en el mail los adjunta.
     if (isset($this->data['adjuntos'])) {
         if (count($this->data['adjuntos'] > 0)) {
             // Si quiere que los archivos se manden en un zip.
             if ($this->zip) {
                 $pathZip = $this->makeZip();
                 $mail->AddAttachment($pathZip, 'Documentos.zip');
             } else {
                 foreach ($this->data['adjuntos'] as $fileName => $pathFile) {
                     $mail->AddAttachment($pathFile, $fileName);
                 }
             }
         }
     }
     $result = array('msg' => 'Mensaje enviado correctamente.');
     if (!$mail->Send()) {
         $result['msg'] = 'El email no se pudo enviar.';
         $result['error'] = $mail->ErrorInfo;
     }
     if ($this->zip) {
         unlink($pathZip);
     }
     return $result;
 }
Exemplo n.º 28
0
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
    require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        if ($CI->mdl_mcb_data->setting('smtp_security')) {
            $mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
        }
        $mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
        $mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
        $mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
        $mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
    } elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
        $mail->IsSendmail();
    }
    if (is_array($from)) {
        $mail->SetFrom($from[0], $from[1]);
    } else {
        $mail->SetFrom($from);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    if ($attachment_path) {
        $mail->AddAttachment($attachment_path);
    }
    if ($mail->Send()) {
        if (isset($CI->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
            return TRUE;
        }
    } else {
        if (isset($CI->this->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
            return FALSE;
        }
    }
}
Exemplo n.º 29
-1
function mailer($from, $from_email, $to, $to_email, $subject, $content, $files)
{
    $content = nl2br($content);
    $mail = new PHPMailer(true);
    $mail->IsSendmail();
    try {
        $mail->CharSet = "utf-8";
        $mail->Encoding = "base64";
        $mail->AddAddress($to_email, $to);
        $mail->SetFrom($from_email, $from);
        $mail->AddReplyTo($from_email, $from);
        $mail->Subject = $subject;
        $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
        $mail->MsgHTML($content);
        if ($files[1] != "") {
            $mail->AddAttachment("./temp/" . $files[1]);
        }
        if ($files[2] != "") {
            $mail->AddAttachment("./temp/" . $files[2]);
        }
        if ($files[3] != "") {
            $mail->AddAttachment("./temp/" . $files[3]);
        }
        $mail->Send();
        return true;
    } catch (phpmailerException $e) {
        echo $e->errorMessage();
        return false;
    } catch (Exception $e) {
        echo $e->getMessage();
        return false;
    }
}
 /**
  *
  * Funcion Send Email with attachment
  * Sirve para enviar correos electronicos a un destinatario con un archivo adjunto
  * parametros Aceptados: fromName,toEmail,mensaje,asunto, file
  * @author Hardlick
  */
 static function sendEmailattach($args = array())
 {
     global $smarty;
     include_once 'libraries/phpmailer/class.phpmailer.php';
     include "libraries/phpmailer/class.smtp.php";
     $mail = new PHPMailer();
     $mail->SMTPSecure = "ssl";
     $mail->IsSMTP();
     $mail->Host = "smtp.gmail.com";
     // SMTP server
     $mail->Timeout = 200;
     //$mail->SMTPDebug = 2;
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = "ssl";
     $mail->Port = 465;
     $mail->Username = "******";
     $mail->Password = "******";
     $mail->From = "*****@*****.**";
     $mail->FromName = $args['fromName'];
     $mail->AddAddress($args['toEmail']);
     $mail->Subject = $args['subject'];
     $mail->Body = $args['message'];
     $mail->AltBody = $args['message'];
     $mail->WordWrap = 50;
     $mail->AddAttachment("" . $args['file']);
     $mail->IsHTML(true);
     if (!$mail->Send()) {
         return $mail->ErrorInfo;
     } else {
         return "1";
     }
 }