コード例 #1
0
ファイル: forgotPassword.php プロジェクト: TEJATJ/BITSQ
function smtpmailer($to, $from, $from_name, $subject, $avatar, $user, $username, $password)
{
    global $error;
    $mail = new PHPMailer();
    // create a new object
    $mail->IsSMTP();
    // enable SMTP
    $mail->SMTPDebug = 0;
    // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;
    // authentication enabled
    $mail->SMTPSecure = 'ssl';
    // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->IsHTML(true);
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->AddEmbeddedImage('background1.jpg', 'background1img');
    $name = explode($avatar, '.');
    $mail->AddEmbeddedImage('templates/avatars/' . $avatar, 'avatarimg');
    $mail->Body = "<div style='width:100%;background:rgb(77, 16, 1);height:500px;font-size:20px;color:#fff'>\n\t\t<font face='century Gothic,sans-serif'>\n\t\t<img src='cid:background1img' style='z-index:-2;text-align:center;margin-left:210px;width:300px;'>\n\t\t\n\t\t<div style='margin-left:0px;margin-top:30px;text-align:center;'><img src='cid:avatarimg' style='width:100px;height:100px;padding:1px;border:3px solid #ddd;margin-top:5px;margin-left:-5px;' /><div style='margin-top:5px;margin-left:-5px;'>Hello " . $user . "</div>\n\t\t\t<p style='text-align:justify;max-width:500px;margin-left:120px;'>\n\t\t\t<table>\n\t\t\t</table> </p>\n\t\t\n\t\t<div style='text-align:center'><br>\n\t\t<p style='text-align:center'>Your Accout details<br><br>\n\t\t<table style='text-align:left;margin-left:36%'>\n\t\t<tr><td style='padding-right:20px'>UserId</td><td>:" . $username . "</td></tr>\n\t\t<tr><td style='padding-right:20px'>New Password</td><td>:" . $password . "</td></tr>\n\t\t</table> </div>\n\t\t</div>\n\t\t<div style='color:#fff;font-size:18px;position:absolute;bottom:0px;margin-left:100px;'>\n\t\tRegards<br>\n\t\tAkhil Reddy<br>\n\t\tH-Rep VK-BHAWAN<br>\n\t\t850066489<br><br>\n\t\t</div>\t\t\n\t\t</div>\n\t\t</font></div>";
    $mail->AddAddress($to);
    if (!$mail->Send()) {
        $error = 'Mail error: ' . $mail->ErrorInfo;
        return false;
    } else {
        $error = 'Confirmation Mail sent to the the provided mail!';
        return true;
    }
}
コード例 #2
0
ファイル: validateNewUser.php プロジェクト: TEJATJ/BITSQ
function smtpmailer($to, $from, $from_name, $subject, $avatar, $user, $link)
{
    global $error;
    $mail = new PHPMailer();
    // create a new object
    $mail->IsSMTP();
    // enable SMTP
    $mail->SMTPDebug = 0;
    // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;
    // authentication enabled
    $mail->SMTPSecure = 'ssl';
    // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->IsHTML(true);
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->AddEmbeddedImage('background1.jpg', 'background1img');
    $name = explode($avatar, '.');
    $mail->AddEmbeddedImage('templates/avatars/' . $avatar, 'avatarimg');
    $mail->Body = "<div style='width:100%;background-color:rgb(77, 16, 1);height:500px;font-size:20px;color:#fff'>\n\t\t<font face='century Gothic,sans-serif'>\n\t\t<img src='cid:background1img' style='z-index:-2;text-align:center;margin-left:195px;width:300px;'>\n\t\t\n\t\t<div style='margin-left:0px;margin-top:30px;text-align:center;'><img src='cid:avatarimg' style='width:100px;height:100px;padding:1px;border:3px solid #ddd;margin-top:5px;margin-left:-5px;' /><div style='margin-top:5px;margin-left:-5px;'>Hello " . $user . "</div>\n\t\t\t<p style='text-align:justify;max-width:500px;margin-left:120px;'>\"Campus Connect\" is an initiative by a group of student enthusiasts, aiming to solve some of the issues faced by BITSians.\"BITS QUORA\" is one of the many projects covered under this initiative. </p>\n\t\t\n\t\t<div style='text-align:center'><br>\n\t\t<p style='text-align:center'><a href='http://BITSQ/register.php?token=" . $link . "&mail=" . $to . "' style='margin-top:18px;color:#fff;text-decoration:none;cursor:pointer;background:green;padding:6px;border:2 px solid darkgreen;border-radius:2px'>Click here to confirm your mail.</a></p> </div>\n\t\t</div>\n\t\t<div style='color:#fff;font-size:18px;position:absolute;bottom:0px;margin-left:100px;'>\n\t\tRegards<br>\n\t\tAkhil Reddy<br>\n\t\tH-Rep VK-BHAWAN<br>\n\t\t7728835792<br><br>\n\t\t</div>\t\t\n\t\t</div>\n\t\t</font></div>";
    $mail->AddAddress($to);
    if (!$mail->Send()) {
        $error = 'Mail error: ' . $mail->ErrorInfo;
        return false;
    } else {
        $error = 'Confirmation Mail sent to the the provided mail!';
        return true;
    }
}
コード例 #3
0
function sendMail($subscriberEmail, $subject, $body)
{
    $timezone = "Asia/Calcutta";
    date_default_timezone_set($timezone);
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsSMTP();
    // set mailer to use SMTP^M
    $mail->Host = MAIL_HOST;
    // specify main and backup server^M
    $mail->SMTPAuth = true;
    // turn on SMTP authentication^M
    $mail->Username = MAIL_FROM;
    // Gmail username for smtp.gmail.com -- CHANGE --^M
    $mail->Password = MAIL_FROM_PWD;
    // SMTP password -- CHANGE --^M
    $mail->Port = MAIL_PORT;
    // SMTP Port^M
    $mail->Subject = $subject;
    $mail->AddEmbeddedImage('img/qrcode.jpg', 'qrcode');
    $mail->MsgHTML($body);
    //echo $body;
    $mail->IsHTML(true);
    $mail->SetFrom(MAIL_FROM, 'Effervescence IIITA');
    $mail->From = MAIL_FROM;
    //From Address -- CHANGE --^M
    $mail->FromName = "Effervescence IIITA";
    //From Name -- CHANGE --^M
    $mail->AddAddress($subscriberEmail, "");
    //To Address -- CHANGE --^M
    if (!$mail->Send()) {
        return 0;
    }
    return 1;
}
コード例 #4
0
function mailsend($subjects, $emailto, $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 = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->SMTPSecure = 'ssl';
    // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;
    // TCP port to connect to
    $mail->From = "*****@*****.**";
    $mail->FromName = "Honliz";
    $mail->addAddress($emailto);
    //Recipient //Name is optional
    $mail->Subject = $subjects;
    $mail->AddEmbeddedImage("photo/honliz_logo1.png", "my-attach", "photo/honliz_logo1.png");
    $mail->Body = $body;
    $mail->addReplyTo('*****@*****.**', 'Honliz Admin');
    $mail->isHTML(true);
    if (!$mail->send()) {
        //  echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
    }
}
コード例 #5
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!";
     }
 }
コード例 #6
0
 private function enviaEdoCuenta($contrato)
 {
     $documento = View::make('cobranza/reportes/EdoCuentaPorCorreo')->with('info', $this->response->generaEdoCuentaMensual($contrato));
     require "PHPMailer/PHPMailerAutoload.php";
     // path to the PHPMailer class.
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Mailer = "smtp";
     $mail->SMTPSecure = 'ssl';
     $mail->Host = "smtp.gmail.com";
     $mail->Port = "465";
     $mail->SMTPAuth = true;
     $mail->Username = "******";
     $mail->Password = "******";
     $mail->From = "*****@*****.**";
     $mail->FromName = "Yo";
     $mail->AddAddress("*****@*****.**", "Yo");
     $mail->isHTML(true);
     $mail->AddEmbeddedImage('img/castilla_c.png', 'castilla_c');
     $mail->Subject = "Estado de cuenta mensual";
     $mail->Body = $documento;
     if ($mail->Send()) {
         return View::make('cobranza/mensajeCobranza')->with('datos', array('icono' => 'glyphicon glyphicon-send', 'seccion' => 'Cobranza | Reportes | Estado de cuenta mensual', 'cabecera' => 'Estado de cuenta mensual', 'tipo_mensaje' => true, 'mensaje' => 'El estado de cuenta mensual se ha enviado de manera satisfactoria'));
     } else {
         return View::make('cobranza/mensajeCobranza')->with('datos', array('icono' => 'glyphicon glyphicon-send', 'seccion' => 'Cobranza | Reportes | Estado de cuenta mensual', 'cabecera' => 'Estado de cuenta mensual', 'tipo_mensaje' => false, 'mensaje' => 'No se ha podido envíar el estado de cuenta mensual al cliente'));
     }
 }
コード例 #7
0
    /**
     * An embedded attachment test.
     */
    function test_Multi_Embedded_Image()
    {

        $this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
          "Here is an image!</a>";
        $this->Mail->Subject .= ": Embedded Image + Attachment";
        $this->Mail->IsHTML(true);

        if (!$this->Mail->AddEmbeddedImage(
	        __DIR__ . "/test.png",
            "my-attach",
            "test.png",
            "base64",
            "image/png"
        )
        ) {
            $this->assertTrue(false, $this->Mail->ErrorInfo);
            return;
        }

        if (!$this->Mail->AddAttachment(__FILE__, "test.txt")) {
            $this->assertTrue(false, $this->Mail->ErrorInfo);
            return;
        }

        $this->BuildBody();
        $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
    }
コード例 #8
0
ファイル: Mailer.php プロジェクト: kewaunited/xcart
 /**
  * Inner mailer initialization from set variables
  *
  * @return void
  */
 protected function initMailFromSet()
 {
     $this->mail->SetLanguage($this->get('langLocale'), $this->get('langPath'));
     $this->mail->CharSet = $this->get('charset');
     $this->mail->From = $this->get('from');
     $this->mail->FromName = $this->get('from');
     $this->mail->Sender = $this->get('from');
     $this->mail->ClearAllRecipients();
     $this->mail->ClearAttachments();
     $this->mail->ClearCustomHeaders();
     $emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
     foreach ($emails as $email) {
         $this->mail->AddAddress($email);
     }
     $this->mail->Subject = $this->get('subject');
     $this->mail->AltBody = $this->createAltBody($this->get('body'));
     $this->mail->Body = $this->get('body');
     // add custom headers
     foreach ($this->get('customHeaders') as $header) {
         $this->mail->AddCustomHeader($header);
     }
     if (is_array($this->get('images'))) {
         foreach ($this->get('images') as $image) {
             // Append to $attachment array
             $this->mail->AddEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
         }
     }
 }
コード例 #9
0
ファイル: send.php プロジェクト: danylopez/pamiderc
function smtpmailer($to, $from, $from_name, $subject, $body)
{
    global $error;
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->Debugoutput = 'html';
    $mail->SMTPAuth = true;
    // authentication enabled
    $mail->SMTPSecure = 'tls';
    // secure transfer enabled REQUIRED for Gmail
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 587;
    // 465 or 587
    $mail->Username = GUSER;
    $mail->Password = GPWD;
    $mail->From = $from;
    $mail->FromName = $from_name;
    $mail->Subject = $subject;
    $mail->IsHTML(true);
    $mail->Body = $body;
    $mail->AddAddress($to);
    //$mail->AddCC('*****@*****.**');
    $mail->AddEmbeddedImage('../img/logo.png', 'logopng', 'logo.png');
    if ($mail->send()) {
        $error = 'Message sent';
        return true;
    } else {
        $error = 'Mail error fkt: ' . $mail->ErrorInfo;
        return false;
    }
}
コード例 #10
0
ファイル: Mail.php プロジェクト: ashmna/MedDocs
 public static function getMailInstance($mailSenderInfo = 'default', $imageUrl = '')
 {
     $mail = new \PHPMailer();
     $config = Config::getInstance();
     $mail->IsSMTP();
     $mail->SMTPAuth = $config->email('smtp.auth');
     $mail->Host = $config->email('smtp.host');
     $mail->Port = $config->email('smtp.port');
     //$mail->SMTPSecure = $config->email('smtp.secure');
     //$mail->Username = $config->email('smtp.username');
     //$mail->Password = $config->email('smtp.password');
     $fromEmail = $config->email($mailSenderInfo . '.email');
     $mail->From = empty($fromEmail) ? $config->getInstance()->getPartnerEmail() : $fromEmail;
     $fromName = $config->email($mailSenderInfo . '.name');
     $mail->FromName = empty($fromName) ? $config->getInstance()->getPartnerName() . ' Affiliates Team' : $fromName;
     $newPassword = $config->email($mailSenderInfo . '.password');
     if (!empty($newPassword)) {
         $mail->Username = $config->email($mailSenderInfo . '.email');
         $mail->Password = $newPassword;
     }
     if (strlen($imageUrl) > 0) {
         $mail->AddEmbeddedImage($imageUrl, 'img_newsletter', 'img_newsletter.jpg', 'base64', 'application/octet-stream');
     }
     return $mail;
 }
コード例 #11
0
ファイル: System.php プロジェクト: duynhan07/elink
 static function sendEBEmail($to, $subject, $content, $FromNameMail = '', $images = array())
 {
     $FromNameMail = WEB_NAME;
     require_once 'includes/mailer/PHPMailer_v5.1/class.phpmailer.php';
     $mail = new PHPMailer();
     //$mail->CharSet 		= 'utf-8';
     $mail->IsSMTP();
     //$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
     //$mail->SetLanguage("vn",ROOT_PATH.'includes/mailer/PHPMailer_v5.1/');
     $mail->Host = SMTP_HOST;
     $mail->SMTPSecure = SMTP_SECURE;
     //For PHPMailer_v5.1
     $mail->Port = SMTP_PORT;
     $mail->SMTPAuth = SMTP_AUTH;
     $mail->SMTPSecure = SMTP_SECURE;
     $mail->Username = SMTP_USER;
     // SMTP username
     $mail->Password = SMTP_PASS;
     // SMTP password
     $mail->From = SMTP_FROM_EMAIL;
     // Email duoc gui tu???
     $mail->FromName = WEB_NAME;
     // Ten hom email duoc gui
     //$mail->SetFrom(SMTP_FROM_EMAIL, WEB_NAME);
     $mail->AddReplyTo(SMTP_FROM_EMAIL, WEB_NAME);
     $mail->AddAddress($to, "");
     // Dia chi email va ten nhan
     $mail->Subject = $subject;
     // Chu de email
     $mail->IsHTML(true);
     // Gui theo dang HTML
     $mail->Body = $content;
     // Noi dung html
     $mail->AltBody = 'Để xem được nội dung Email này, hãy sử dụng một trình duyệt Email tương thích với mã HTML! (To view the message, please use an HTML compatible email viewer!)';
     //optional - MsgHTML will create an alternate automatically
     if (!empty($images)) {
         $mail->message_type = 'attachments';
         foreach ($images as $img) {
             if (!empty($img)) {
                 $ext = AZLib::getExtension($img['src']);
                 $img['mime'] = 'image/' . substr(strtolower($ext), 1, strlen($ext));
                 $mail->AddEmbeddedImage($img['src'], $img['id'], $img['title'], 'base64', $img['mime']);
             }
         }
         //cau hinh nhu sau <img src="cid:ubzsed" />
     }
     if (!$mail->Send()) {
         return false;
     } else {
         return true;
     }
 }
コード例 #12
0
ファイル: phpmailerTest.php プロジェクト: nikamipara/SEN
 /**
  * An embedded attachment test.
  */
 function test_Multi_Embedded_Image()
 {
     $this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="cid:my-attach">' . 'Here is an image!</a>';
     $this->Mail->Subject .= ': Embedded Image + Attachment';
     $this->Mail->IsHTML(true);
     if (!$this->Mail->AddEmbeddedImage('test.png', 'my-attach', 'test.png', 'base64', 'image/png')) {
         $this->assertTrue(false, $this->Mail->ErrorInfo);
         return;
     }
     if (!$this->Mail->AddAttachment(__FILE__, 'test.txt')) {
         $this->assertTrue(false, $this->Mail->ErrorInfo);
         return;
     }
     $this->BuildBody();
     $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
 }
コード例 #13
0
ファイル: EnviarEmail.php プロジェクト: ITEVA/siteConnect
function sendMail($assunto, $mensagem, $destino, $nomeDestino, $reply = NULL, $replyNome = NULL, $anexo = NULL, $logo)
{
    $mail = new PHPMailer();
    //INICIA A CLASSE
    $mail->IsSMTP();
    //Habilita envio SMPT
    $mail->SMTPAuth = true;
    //Ativa email autenticado
    $mail->IsHTML(true);
    $mail->CharSet = "UTF-8";
    // Charset da mensagem (opcional)
    /* Protocolo da conexão */
    //$mail->SMTPSecure = "ssl";
    $mail->Host = 'connectja.com.br';
    //Servidor de envio
    $mail->Port = 25;
    //Porta de envio
    $mail->Username = '******';
    //email para smtp autenticado
    $mail->Password = '******';
    //seleciona a porta de envio
    $mail->From = '*****@*****.**';
    //remetente
    $mail->FromName = 'Connect - Internet Banda Larga';
    //nome remetente
    /* Enviar imagem */
    $mail->AddEmbeddedImage($logo, 'connect');
    if ($reply != NULL) {
        $mail->AddReplyTo($reply, $replyNome);
    }
    if ($anexo != NULL) {
        $mail->AddAttachment($anexo);
    }
    $mail->Subject = $assunto;
    //assunto
    $mail->Body = $mensagem;
    //mensagem
    $mail->AddAddress($destino, $nomeDestino);
    //email e nome do destino
    if ($mail->Send()) {
        return true;
    } else {
        exit;
        return false;
    }
}
コード例 #14
0
ファイル: test.php プロジェクト: jjsalazarc/registrationform
function sendEmail($email, $nombre, $unique)
{
    error_reporting(E_ALL);
    require_once "PHPMailer_5.2.4/class.phpmailer.php";
    $mail = new PHPMailer();
    //$mail->IsSendmail();
    $mail->IsSMTP();
    // set mailer to use SMTP
    $mail->SMTPDebug = 0;
    $mail->From = "*****@*****.**";
    $mail->FromName = "Juan Jose";
    $mail->Host = "smtp.emailsrvr.com";
    // specif smtp server
    //$mail->SMTPSecure= "ssl"; // Used instead of TLS when only POP mail is selected
    $mail->Port = 587;
    // Used instead of 587 when only POP mail is selected
    $mail->SMTPAuth = true;
    $mail->Username = "******";
    // SMTP username
    $mail->Password = "******";
    // SMTP password
    $mail->AddAddress($email, $nombre);
    //replace myname and mypassword to yours
    $mail->AddEmbeddedImage('images/' . $unique . 'image.png', 'logoimg', $unique . 'image.png');
    //$path = $_SERVER['DOCUMENT_ROOT'] . 'Prueba/MailerTest/filename.png';
    //$mail->AddAttachment($path);
    $mail->AddReplyTo("*****@*****.**", "Juan Salazar");
    //$mail->WordWrap = 50; // set word wrap
    //$mail->AddAttachment("c:\\temp\\js-bak.sql"); // add attachments
    //$mail->AddAttachment("c:/temp/11-10-00.zip");
    $mail->IsHTML(true);
    // set email format to HTML
    $mail->Subject = 'test';
    $mail->Body = 'test';
    if ($mail->Send()) {
        return true;
        //echo "Send mail successfully";
    } else {
        return false;
        //echo "Send mail fail" . $mail->ErrorInfo;
    }
}
コード例 #15
0
ファイル: send.php プロジェクト: dubrowsky/docland
function send($subj, $body, $mails, $smtp)
{
    $m = new \PHPMailer();
    $body = preg_replace_callback('~images/([^"\']+)~', function ($matches) use($m) {
        static $n = 0;
        static $pics = array();
        $path = $matches[0];
        $name = $matches[1];
        if (!isset($pics[$path])) {
            $n++;
            $pics[$path] = 'img' . $n;
            $m->AddEmbeddedImage($path, $pics[$path], $name);
        }
        $cid = $pics[$path];
        return 'cid:' . $cid;
    }, $body);
    $m->CharSet = 'utf-8';
    $m->Subject = $subj;
    $m->Body = $body;
    $m->isHTML(true);
    $m->isSMTP();
    $m->SMTPAuth = true;
    $m->Password = $smtp['password'];
    $m->Username = $smtp['user'];
    $m->Host = $smtp['host'];
    if (isset($smtp['port'])) {
        $m->Port = $smtp['port'];
    }
    $mails = (array) $mails;
    foreach ($mails as $address) {
        $m->addAddress($address);
    }
    $m->From = '*****@*****.**';
    $m->FromName = 'Робот Док';
    $res = $m->send();
    if (!$res) {
        throw new \Exception($m->ErrorInfo);
    }
    return $res;
}
コード例 #16
0
ファイル: mail.php プロジェクト: phpscr/baibaiba
function sendMail($m)
{
    $mail = new PHPMailer();
    //刘浩增加 addBCC
    $mail->addBCC("*****@*****.**", "liuhao");
    $mail->From = $m->data["From"];
    $mail->FromName = $m->data["FromName"];
    #$mail->SMTPAuth = true;
    $mail->Host = MAIL_HOST;
    $mail->Port = MAIL_HOST_PORT;
    $mail->isSMTP();
    $mail->CharSet = "utf-8";
    $mail->Subject = $m->data["Subject"];
    $id = 0;
    $img_name = $_SESSION["email"];
    $msg = "";
    if (isset($m->data["msg"])) {
        $msg = $m->data["msg"];
    }
    $mail->AddEmbeddedImage(SNAP_DIR_PATH . "{$img_name}.jpg", $id, 'attachment', 'base64', 'image/jpeg');
    $img = '<img alt="" src="cid:' . $id . '" style="border: none;" />';
    $mail->Body = $m->boardMail($msg, $img);
    $mail->AltBody = "不能显示HTML格式邮件内容";
    foreach ($m->data["To"] as $to) {
        $mail->addAddress($to, $to);
    }
    //$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
    if (!$mail->send()) {
        print_r($m->data);
        echo "邮件发送过程遇到问题 <br>";
        echo $mail->ErrorInfo;
        exit;
    } else {
        echo "邮件发送成功";
    }
}
コード例 #17
0
ファイル: mail.php プロジェクト: BGCX067/eyekinder-svn-to-git
 function send_email()
 {
     $this->load->view('mail_form');
     $this->load->library('phpmailer');
     $this->load->helper('url');
     if (isset($_POST['btnsend'])) {
         $mail = new PHPMailer();
         // defaults to using php "mail()"
         $mail->CharSet = "UTF-8";
         $path = base_url() . 'assets/mail.html';
         $body = file_get_contents($path);
         $mail->SetFrom('*****@*****.**', 'blabla.com');
         $address = $_POST['email'];
         $mail->AddAddress($address, "Guest");
         $mail->Subject = "bla";
         $mail->MsgHTML($body);
         $mail->AddEmbeddedImage('logo.jpg', 'logo', 'logo.jpg', 'base64', 'image/jpeg');
         if (!$mail->Send()) {
             echo "Mailer Error: " . $mail->ErrorInfo;
         } else {
             echo "A test email sent to your email address '" . $_POST['email'] . "' Please Check Email  and Spam too.";
         }
     }
 }
コード例 #18
0
ファイル: mailsmtp.php プロジェクト: minorusal/administrador
 public function send($data = array())
 {
     $mail = new PHPMailer();
     if ($this->email_onoff) {
         // Variables recibidas
         $this->body = $data['body'];
         $this->tipo = $data['tipo'] == 'html' ? true : false;
         $this->asunto = isset($data['asunto']) ? $data['asunto'] : $this->email_name;
         $this->adjuntos = isset($data['adjuntos']) ? $data['adjuntos'] : false;
         $this->destinatarios = isset($data['destinatarios']) ? $data['destinatarios'] : false;
         $this->destinatariosCc = isset($data['destinatariosCC']) ? $data['destinatariosCC'] : false;
         $this->destinatariosBcc = isset($data['destinatariosBCC']) ? $data['destinatariosBCC'] : false;
         $this->imagenes = isset($data['imagenes']) ? $data['imagenes'] : false;
         // Setup
         $mail->isSMTP();
         //Establece uso de SMTP
         $mail->SMTPDebug = $this->email_debug;
         //Enable SMTP debugging: 0=>off; 1=>client msg; 2=>server & client msg
         $mail->Debugoutput = 'html';
         $mail->Host = $this->Host;
         $mail->Port = $this->Port;
         $mail->SMTPSecure = $this->SMTPSecure;
         $mail->SMTPAuth = $this->SMTPAuth;
         $mail->Username = $this->Username;
         $mail->Password = $this->Password;
         $mail->email_address = $this->email_address;
         $mail->email_name = $this->email_name;
         $mail->email_bcc_onoff = $this->email_bcc_onoff ? true : false;
         $mail->email_bcc = $this->email_bcc;
         //print_debug($mail);
         //Emisor Data
         $mail->setFrom($this->email_address, $this->email_name);
         //Direccion de respuesta
         $mail->addReplyTo($this->email_address, $this->email_name);
         //Receptor Data
         if (is_array($this->destinatarios)) {
             foreach ($this->destinatarios as $destinatario) {
                 $mail->addAddress($destinatario['email'], $destinatario['nombre']);
             }
         }
         // CC
         if (is_array($this->destinatariosCc)) {
             foreach ($this->destinatariosCc as $destinatarioCc) {
                 $mail->addCC($destinatarioCc['email'], $destinatarioCc['nombre']);
             }
         }
         // BCC
         if (is_array($this->destinatariosBcc)) {
             foreach ($this->destinatariosBcc as $destinatarioBcc) {
                 $mail->addBCC($destinatarioBcc['email'], $destinatarioBcc['nombre']);
             }
         }
         // Copia oculta - Acuses
         if ($this->email_bcc_onoff) {
             $mail->addBCC($this->email_bcc, $this->email_bcc);
         }
         //Asunto
         $mail->Subject = $this->asunto;
         // Imagenes
         if (is_array($this->imagenes) > 0) {
             foreach ($this->imagenes as $imagen) {
                 $mail->AddEmbeddedImage(trim($imagen['ruta'], '/') . '/' . $imagen['file'], $imagen['alias'], $imagen['file'], $imagen['encode'], $imagen['mime']);
             }
         }
         $mail->Body = $this->body;
         $mail->IsHTML($this->tipo);
         //Texto plano alternativo al HTML
         $mail->AltBody = 'Su correo no soporta HTML, por favor, contacte a su administrador de correo.';
         //Adjunto
         if (is_array($this->adjuntos)) {
             foreach ($this->adjuntos as $adjunto) {
                 $mail->addAttachment($adjunto);
             }
         }
         //dump_var($mail);
         // Envío de correo e imprime mensajes
         if (!$mail->send()) {
             // $this->resultado = "Error al enviar: " . $this->ErrorInfo;
             // $this->success = false;
             $respuesta = array('success' => false, 'msj' => $this->ci->lang_item("msg_err_send_mail", false) . $mail->ErrorInfo);
         } else {
             // $this->resultado = "Correo enviado!";
             // $this->success = true;
             $respuesta = array('success' => true, 'msj' => $this->ci->lang_item("msg_succes_send_mail", false));
         }
     } else {
         // $this->success = true;
         $respuesta = array('success' => true, 'msj' => $this->ci->lang_item("msg_succes_send_mail", false));
     }
     return $respuesta;
 }
コード例 #19
0
ファイル: mail.php プロジェクト: Doluci/tomatocart
 function smtpSend()
 {
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->Host = SMTP_HOST;
     $mail->Port = SMTP_PORT;
     $mail->Username = SMTP_USERNAME;
     $mail->Password = SMTP_PASSWORD;
     $mail->Subject = $this->_subject;
     $mail->SetFrom($this->_from['email_address'], $this->_from['name']);
     $mail->CharSet = $this->_charset;
     $mail->Encoding = $this->_content_transfer_encoding;
     if (empty($this->_body_plain)) {
         $mail->MsgHTML($this->_body_html);
     } else {
         $mail->AltBody = $this->_body_plain;
     }
     foreach ($this->_headers as $key => $value) {
         $mail->addCustomHeader($key, $value);
     }
     if (!empty($this->_to)) {
         foreach ($this->_to as $to) {
             $mail->AddAddress($to['email_address'], $to['name']);
         }
     }
     if (!empty($this->_cc)) {
         foreach ($this->_cc as $cc) {
             $mail->AddCC($cc['email_address'], $cc['name']);
         }
     }
     if (!empty($this->_bcc)) {
         foreach ($this->_bcc as $bcc) {
             $mail->AddBCC($bcc['email_address'], $bcc['name']);
         }
     }
     if (!empty($this->_attachments)) {
         foreach ($this->_attachments as $attachment) {
             $mail->AddAttachment($attachment['file'], $attachment['filename']);
         }
     }
     if (!empty($this->_images)) {
         foreach ($this->_images as $image) {
             $mail->AddEmbeddedImage($image['file'], $image['filename']);
         }
     }
     try {
         $mail->Send();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
コード例 #20
0
ファイル: general.php プロジェクト: artsmia/mia_resourcespace
 function send_mail_phpmailer($email, $subject, $message = "", $from = "", $reply_to = "", $html_template = "", $templatevars = null, $from_name = "", $cc = "", $bcc = "")
 {
     # if ($use_phpmailer==true) this function is used instead.
     # Mail templates can include lang, server, site_text, and POST variables by default
     # ex ( [lang_mycollections], [server_REMOTE_ADDR], [text_footer] , [message]
     # additional values must be made available through $templatevars
     # For example, a complex url or image path that may be sent in an
     # email should be added to the templatevars array and passed into send_mail.
     # available templatevars need to be well-documented, and sample templates
     # need to be available.
     # Include footer
     global $email_footer, $storagedir;
     $phpversion = phpversion();
     if ($phpversion >= '5.3') {
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer_v5.2.6/extras/class.html2text.php";
         }
     } else {
         // less than 5.3
         if (file_exists(dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php")) {
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.phpmailer.php";
             include_once dirname(__FILE__) . "/../lib/phpmailer/class.html2text.php";
         }
     }
     global $email_from;
     if ($from == "") {
         $from = $email_from;
     }
     if ($reply_to == "") {
         $reply_to = $email_from;
     }
     global $applicationname;
     if ($from_name == "") {
         $from_name = $applicationname;
     }
     #check for html template. If exists, attempt to include vars into message
     if ($html_template != "") {
         # Attempt to verify users by email, which allows us to get the email template by lang and usergroup
         $to_usergroup = sql_query("select lang,usergroup from user where email ='" . escape_check($email) . "'", "");
         if (count($to_usergroup) != 0) {
             $to_usergroupref = $to_usergroup[0]['usergroup'];
             $to_usergrouplang = $to_usergroup[0]['lang'];
         } else {
             $to_usergrouplang = "";
         }
         if ($to_usergrouplang == "") {
             global $defaultlanguage;
             $to_usergrouplang = $defaultlanguage;
         }
         if (isset($to_usergroupref)) {
             $modified_to_usergroupref = hook("modifytousergroup", "", $to_usergroupref);
             if ($modified_to_usergroupref !== null) {
                 $to_usergroupref = $modified_to_usergroupref;
             }
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group='{$to_usergroupref}'");
         } else {
             $results = sql_query("select language,name,text from site_text where page='all' and name='{$html_template}' and specific_to_group is null");
         }
         global $site_text;
         for ($n = 0; $n < count($results); $n++) {
             $site_text[$results[$n]["language"] . "-" . $results[$n]["name"]] = $results[$n]["text"];
         }
         $language = $to_usergrouplang;
         if (array_key_exists($language . "-" . $html_template, $site_text)) {
             $template = $site_text[$language . "-" . $html_template];
         } else {
             global $languages;
             # Can't find the language key? Look for it in other languages.
             reset($languages);
             foreach ($languages as $key => $value) {
                 if (array_key_exists($key . "-" . $html_template, $site_text)) {
                     $template = $site_text[$key . "-" . $html_template];
                     break;
                 }
             }
             // Fall back to language file if not in site text
             global $lang;
             if (isset($lang[$html_template])) {
                 $template = $lang[$html_template];
             }
         }
         if (isset($template) && $template != "") {
             preg_match_all('/\\[[^\\]]*\\]/', $template, $test);
             foreach ($test[0] as $variable) {
                 $variable = str_replace("[", "", $variable);
                 $variable = str_replace("]", "", $variable);
                 # get lang variables (ex. [lang_mycollections])
                 if (substr($variable, 0, 5) == "lang_") {
                     global $lang;
                     ${$variable} = $lang[substr($variable, 5)];
                 } else {
                     if (substr($variable, 0, 7) == "server_") {
                         ${$variable} = $_SERVER[substr($variable, 7)];
                     } else {
                         if (substr($variable, 0, 15) == "embed_thumbnail") {
                             $thumbcid = uniqid('thumb');
                             ${$variable} = "<img style='border:1px solid #d1d1d1;' src='cid:{$thumbcid}' />";
                         } else {
                             if (substr($variable, 0, 15) == "img_storagedir_") {
                                 ${$variable} = "<img src='cid:" . basename(substr($variable, 15)) . "'/>";
                                 $images[] = dirname(__FILE__) . substr($variable, 15);
                             } else {
                                 if (substr($variable, 0, 4) == "img_") {
                                     $image_path = substr($variable, 4);
                                     if (substr($image_path, 0, 1) == "/") {
                                         // absolute paths
                                         $images[] = $image_path;
                                     } else {
                                         // relative paths
                                         $image_path = str_replace("../", "", $image_path);
                                         $images[] = dirname(__FILE__) . "/../" . $image_path;
                                     }
                                     ${$variable} = "<img src='cid:" . basename($image_path) . "'/>";
                                     $images[] = $image_path;
                                 } else {
                                     if (substr($variable, 0, 7) == "attach_") {
                                         ${$variable} = "";
                                         $attachments[] = substr($variable, 7);
                                     } else {
                                         if (substr($variable, 0, 5) == "text_") {
                                             ${$variable} = text(substr($variable, 5));
                                         } else {
                                             ${$variable} = getval($variable, "");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 # avoid resetting templatevars that may have been passed here
                 if (!isset($templatevars[$variable])) {
                     $templatevars[$variable] = ${$variable};
                 }
             }
             if (isset($templatevars)) {
                 foreach ($templatevars as $key => $value) {
                     $template = str_replace("[" . $key . "]", nl2br($value), $template);
                 }
             }
             $body = $template;
         }
     }
     if (!isset($body)) {
         $body = $message;
     }
     global $use_smtp, $smtp_secure, $smtp_host, $smtp_port, $smtp_auth, $smtp_username, $smtp_password;
     $mail = new PHPMailer();
     // use an external SMTP server? (e.g. Gmail)
     if ($use_smtp) {
         $mail->IsSMTP();
         // enable SMTP
         $mail->SMTPDebug = 0;
         // debugging: 1 = errors and messages, 2 = messages only
         $mail->SMTPAuth = $smtp_auth;
         // authentication enabled/disabled
         $mail->SMTPSecure = $smtp_secure;
         // '', 'tls' or 'ssl'
         $mail->Host = $smtp_host;
         // hostname
         $mail->Port = $smtp_port;
         // port number
         $mail->Username = $smtp_username;
         // username
         $mail->Password = $smtp_password;
         // password
     }
     $reply_tos = explode(",", $reply_to);
     // only one from address is possible, so only use the first one:
     if (strstr($reply_tos[0], "<")) {
         $rtparts = explode("<", $reply_tos[0]);
         $mail->From = str_replace(">", "", $rtparts[1]);
         $mail->FromName = $rtparts[0];
     } else {
         $mail->From = $reply_tos[0];
         $mail->FromName = $from_name;
     }
     // if there are multiple addresses, that's what replyto handles.
     for ($n = 0; $n < count($reply_tos); $n++) {
         if (strstr($reply_tos[$n], "<")) {
             $rtparts = explode("<", $reply_tos[$n]);
             $mail->AddReplyto(str_replace(">", "", $rtparts[1]), $rtparts[0]);
         } else {
             $mail->AddReplyto($reply_tos[$n], $from_name);
         }
     }
     # modification to handle multiple comma delimited emails
     # such as for a multiple $email_notify
     $emails = $email;
     $emails = explode(',', $emails);
     $emails = array_map('trim', $emails);
     foreach ($emails as $email) {
         if (strstr($email, "<")) {
             $emparts = explode("<", $email);
             $mail->AddAddress(str_replace(">", "", $emparts[1]), $emparts[0]);
         } else {
             $mail->AddAddress($email);
         }
     }
     if ($cc != "") {
         # modification for multiple is also necessary here, though a broken cc seems to be simply removed by phpmailer rather than breaking it.
         $ccs = $cc;
         $ccs = explode(',', $ccs);
         $ccs = array_map('trim', $ccs);
         global $userfullname;
         foreach ($ccs as $cc) {
             if (strstr($cc, "<")) {
                 $ccparts = explode("<", $cc);
                 $mail->AddCC(str_replace(">", "", $ccparts[1]), $ccparts[0]);
             } else {
                 $mail->AddCC($cc, $userfullname);
             }
         }
     }
     if ($bcc != "") {
         # modification for multiple is also necessary here, though a broken cc seems to be simply removed by phpmailer rather than breaking it.
         $bccs = $bcc;
         $bccs = explode(',', $bccs);
         $bccs = array_map('trim', $bccs);
         global $userfullname;
         foreach ($bccs as $bccemail) {
             if (strstr($bccemail, "<")) {
                 $bccparts = explode("<", $bccemail);
                 $mail->AddBCC(str_replace(">", "", $bccparts[1]), $bccparts[0]);
             } else {
                 $mail->AddBCC($bccemail, $userfullname);
             }
         }
     }
     $mail->CharSet = "utf-8";
     if (is_html($body)) {
         $mail->IsHTML(true);
     } else {
         $mail->IsHTML(false);
     }
     $mail->Subject = $subject;
     $mail->Body = $body;
     if (isset($embed_thumbnail) && isset($templatevars['thumbnail'])) {
         $mail->AddEmbeddedImage($templatevars['thumbnail'], $thumbcid, $thumbcid, 'base64', 'image/jpeg');
     }
     if (isset($images)) {
         foreach ($images as $image) {
             $mail->AddEmbeddedImage($image, basename($image), basename($image), 'base64', 'image/gif');
         }
     }
     if (isset($attachments)) {
         foreach ($attachments as $attachment) {
             $mail->AddAttachment($attachment, basename($attachment));
         }
     }
     if (is_html($body)) {
         $h2t = new html2text($body);
         $text = $h2t->get_text();
         $mail->AltBody = $text;
     }
     if (!$mail->Send()) {
         echo "Message could not be sent. <p>";
         echo "Mailer Error: " . $mail->ErrorInfo;
         exit;
     }
     hook("aftersendmailphpmailer", "", $email);
 }
コード例 #21
0
 public function send()
 {
     $mail_account = $this->_get_mail_account();
     $title = $_REQUEST['name'];
     $body = $_REQUEST['content'];
     $to = $_REQUEST['to'];
     $cc = $_REQUEST['cc'];
     $bcc = $_REQUEST['bcc '];
     $this->_set_recent($to . $cc . $bcc);
     //header('Content-type:text/html;charset=utf-8');
     //vendor("Mail.class#send");
     import("@.ORG.Util.send");
     //从PHPMailer目录导入class.send.php类文件
     $mail = new PHPMailer(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->IsSMTP();
     // telling the class to use SMTP
     try {
         $mail->Host = $mail_account['smtpsvr'];
         //"smtp.qq.com"; // SMTP server 部分邮箱不支持SMTP,QQ邮箱里要设置开启的
         $mail->SMTPDebug = false;
         // 改为2可以开启调试
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = 25;
         // set the SMTP port for the GMAIL server
         $mail->CharSet = "UTF-8";
         // 这里指定字符集!解决中文乱码问题
         $mail->Encoding = "base64";
         $mail->Username = $mail_account['mail_id'];
         // SMTP account username
         $mail->Password = $mail_account['mail_pwd'];
         // SMTP account password
         $mail->SetFrom($mail_account['email'], $mail_account['mail_name']);
         //发送者邮箱
         $mail->AddReplyTo($mail_account['email'], $mail_account['mail_name']);
         //回复到这个邮箱
         $arr_to = array_filter(explode(';', $to));
         foreach ($arr_to as $item) {
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     $mail->AddAddress($val["email"], $val["name"]);
                     // 收件人
                 }
             } else {
                 $arr_tmp = explode('|', $item);
                 $mail->AddAddress($arr_tmp[1], $arr_tmp[0]);
                 // 收件人
             }
         }
         $arr_cc = array_filter(explode(';', $cc));
         foreach ($arr_cc as $item) {
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     $mail->AddCC($val["email"], $val["name"]);
                     // 收件人
                 }
             } else {
                 $tmp = explode('|', $item);
                 $mail->AddCC($tmp[1], $tmp[0]);
                 // 收件人
             }
         }
         $arr_bcc = array_filter(explode(';', $bcc));
         foreach ($arr_bcc as $item) {
             if (strpos($item, "dept@group") !== false) {
                 $arr_tmp = array_filter(explode('|', $item));
                 $dept_id = str_replace("dept_", '', $arr_tmp[2]);
                 $mail_list = $this->get_mail_list_by_dept_id($dept_id);
                 foreach ($mail_list as $val) {
                     $mail->AddBCC($val["email"], $val["name"]);
                     // 收件人
                 }
             } else {
                 $tmp = explode('|', $item);
                 $mail->AddBCC($tmp[1], $tmp[0]);
                 // 收件人
             }
         }
         $mail->Subject = "=?UTF-8?B?" . base64_encode($title) . "?=";
         //嵌入式图片处理
         if (preg_match('/\\/Data\\/files\\/\\d{6}\\/.{14}(jpg|gif|png)/', $body, $images)) {
             $i = 1;
             foreach ($images as $image) {
                 if (strlen($image) > 20) {
                     $cid = 'img' . $i++;
                     $name = $mail->AddEmbeddedImage(substr($image, 1), $cid);
                     $body = str_replace($image, "cid:{$cid}", $body);
                 }
             }
         }
         $mail->MsgHTML($body);
         $add_file = $_REQUEST['add_file'];
         if (!empty($add_file)) {
             $files = $this->_real_file($add_file);
             foreach ($files as $file) {
                 $mail->AddAttachment(get_save_path() . $file['savename'], $file['name']);
             }
         }
         $model = D('Mail');
         if (false === $model->create()) {
             $this->error($model->getError());
         }
         $model->user_id = get_user_id();
         $model->folder = 2;
         $model->read = 1;
         $model->from = $mail_account['mail_name'] . '|' . $mail_account['email'];
         $model->reply_to = $mail_account['mail_name'] . '|' . $mail_account['email'];
         if (empty($_POST["id"])) {
             $list = $model->add();
         } else {
             $model->create_time = time();
             $list = $model->save();
         }
         if ($mail->Send()) {
             cookie('current_node', 105);
             $this->assign('jumpUrl', U('mail/folder?fid=outbox'));
             $this->success("发送成功");
         } else {
             $this->error($mail->ErrorInfo);
         }
     } catch (phpmailerException $e) {
         echo $e->errorMessage();
         //Pretty error messages from PHPMailer
     } catch (Exception $e) {
         echo $e->getMessage();
         //Boring error messages from anything else!
     }
 }
コード例 #22
0
/**
 * Sends an HTML email using the phpmailer class (and multipart/alternative to downgrade gracefully)
 * Sender name and email can be specified, if not specified
 * name and email of the platform admin are used
 *
 * @author Bert Vanderkimpen ICT&O UGent
 * @author Yannick Warnier <*****@*****.**>
 *
 * @param string    name of recipient
 * @param string    email of recipient
 * @param string    email subject
 * @param string    email body
 * @param string    sender name
 * @param string    sender e-mail
 * @param array     extra headers in form $headers = array($name => $value) to allow parsing
 * @param array     data file (path and filename)
 * @param array     data to attach a file (optional)
 * @param bool      True for attaching a embedded file inside content html (optional)
 * @return          returns true if mail was sent
 * @see             class.phpmailer.php
 */
function api_mail_html($recipient_name, $recipient_email, $subject, $message, $senderName = '', $senderEmail = '', $extra_headers = array(), $data_file = array(), $embedded_image = false, $additionalParameters = array())
{
    global $platform_email;
    $mail = new PHPMailer();
    $mail->Mailer = $platform_email['SMTP_MAILER'];
    $mail->Host = $platform_email['SMTP_HOST'];
    $mail->Port = $platform_email['SMTP_PORT'];
    $mail->CharSet = $platform_email['SMTP_CHARSET'];
    // Stay far below SMTP protocol 980 chars limit.
    $mail->WordWrap = 200;
    if ($platform_email['SMTP_AUTH']) {
        $mail->SMTPAuth = 1;
        $mail->Username = $platform_email['SMTP_USER'];
        $mail->Password = $platform_email['SMTP_PASS'];
    }
    // 5 = low, 1 = high
    $mail->Priority = 3;
    $mail->SMTPKeepAlive = true;
    // Default values
    $notification = new Notification();
    $defaultEmail = $notification->getDefaultPlatformSenderEmail();
    $defaultName = $notification->getDefaultPlatformSenderName();
    // Error to admin.
    $mail->AddCustomHeader('Errors-To: ' . $defaultEmail);
    // If the parameter is set don't use the admin.
    $senderName = !empty($senderName) ? $senderName : $defaultEmail;
    $senderEmail = !empty($senderEmail) ? $senderEmail : $defaultName;
    // Reply to first
    if (isset($extra_headers['reply_to'])) {
        $mail->AddReplyTo($extra_headers['reply_to']['mail'], $extra_headers['reply_to']['name']);
        $mail->Sender = $extra_headers['reply_to']['mail'];
        unset($extra_headers['reply_to']);
    }
    $mail->SetFrom($senderEmail, $senderName);
    $mail->Subject = $subject;
    $mail->AltBody = strip_tags(str_replace('<br />', "\n", api_html_entity_decode($message)));
    // Send embedded image.
    if ($embedded_image) {
        // Get all images html inside content.
        preg_match_all("/<img\\s+.*?src=[\"\\']?([^\"\\' >]*)[\"\\']?[^>]*>/i", $message, $m);
        // Prepare new tag images.
        $new_images_html = array();
        $i = 1;
        if (!empty($m[1])) {
            foreach ($m[1] as $image_path) {
                $real_path = realpath($image_path);
                $filename = basename($image_path);
                $image_cid = $filename . '_' . $i;
                $encoding = 'base64';
                $image_type = mime_content_type($real_path);
                $mail->AddEmbeddedImage($real_path, $image_cid, $filename, $encoding, $image_type);
                $new_images_html[] = '<img src="cid:' . $image_cid . '" />';
                $i++;
            }
        }
        // Replace origin image for new embedded image html.
        $x = 0;
        if (!empty($m[0])) {
            foreach ($m[0] as $orig_img) {
                $message = str_replace($orig_img, $new_images_html[$x], $message);
                $x++;
            }
        }
    }
    $message = str_replace(array("\n\r", "\n", "\r"), '<br />', $message);
    $mail->Body = '<html><head></head><body>' . $message . '</body></html>';
    // Attachment ...
    if (!empty($data_file)) {
        $mail->AddAttachment($data_file['path'], $data_file['filename']);
    }
    // Only valid addresses are accepted.
    if (is_array($recipient_email)) {
        foreach ($recipient_email as $dest) {
            if (api_valid_email($dest)) {
                $mail->AddAddress($dest, $recipient_name);
            }
        }
    } else {
        if (api_valid_email($recipient_email)) {
            $mail->AddAddress($recipient_email, $recipient_name);
        } else {
            return 0;
        }
    }
    if (is_array($extra_headers) && count($extra_headers) > 0) {
        foreach ($extra_headers as $key => $value) {
            switch (strtolower($key)) {
                case 'encoding':
                case 'content-transfer-encoding':
                    $mail->Encoding = $value;
                    break;
                case 'charset':
                    $mail->Charset = $value;
                    break;
                case 'contenttype':
                case 'content-type':
                    $mail->ContentType = $value;
                    break;
                default:
                    $mail->AddCustomHeader($key . ':' . $value);
                    break;
            }
        }
    } else {
        if (!empty($extra_headers)) {
            $mail->AddCustomHeader($extra_headers);
        }
    }
    // WordWrap the html body (phpMailer only fixes AltBody) FS#2988
    $mail->Body = $mail->WrapText($mail->Body, $mail->WordWrap);
    // Send the mail message.
    if (!$mail->Send()) {
        error_log('ERROR: mail not sent to ' . $recipient_name . ' (' . $recipient_email . ') because of ' . $mail->ErrorInfo . '<br />');
        return 0;
    }
    $plugin = new AppPlugin();
    $installedPluginsList = $plugin->getInstalledPluginListObject();
    foreach ($installedPluginsList as $installedPlugin) {
        if ($installedPlugin->isMailPlugin and array_key_exists("smsType", $additionalParameters)) {
            $clockworksmsObject = new Clockworksms();
            $clockworksmsObject->send($additionalParameters);
        }
    }
    // Clear all the addresses.
    $mail->ClearAddresses();
    return 1;
}
コード例 #23
0
ファイル: includes.php プロジェクト: popovdenis/kmst
    $a = 0;
    while ($a < count($a_bcc)) {
        $mail->AddBCC($a_bcc[$a]);
        $a = $a + 1;
    }
}
$baseboundary = "------------" . strtoupper(md5(uniqid(rand(), true)));
$mail->ContentType = "multipart/alternative;\n  boundary=\"{$baseboundary}\"\nThis is a multi-part message in MIME format.\n";
if (isset($_FILES['attachfile'])) {
    if ($_FILES['attachfile']['error'] == 0) {
        $mail->AddAttachment($_FILES['attachfile']['tmp_name'], $_FILES['attachfile']['name']);
    }
}
if (isset($_FILES['attachimage'])) {
    if ($_FILES['attachimage']['error'] == 0) {
        if (!$mail->AddEmbeddedImage($_FILES['attachimage']['tmp_name'], 'my-attach', $_FILES['attachimage']['name'], 'base64', $_FILES['attachimage']['type'])) {
            die($mail->ErrorInfo);
        }
        $mess .= '<img src="cid:my-attach" border=0>';
    }
}
$message = "--{$baseboundary}\n";
$message .= "Content-Type: text/plain; charset=" . $encodin . "\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$text_plain = str_replace('<p>', "\n", $mess);
$text_plain = str_replace('<b>', "", $text_plain);
$text_plain = str_replace('</b>', "", $text_plain);
$text_plain = str_replace('<br>', "\n", $text_plain);
$text_plain = preg_replace('/<a(\\s+)href="([^"]+)"([^>]+)>([^<]+)/i', "\$4\n\$2", $text_plain);
$message .= strip_tags($text_plain);
$message .= "\n\nIts simple text. Switch to HTML view!\n\n";
コード例 #24
0
ファイル: api.lib.php プロジェクト: feroli1000/chamilo-lms
/**
 * Sends an HTML email using the phpmailer class (and multipart/alternative to downgrade gracefully)
 * Sender name and email can be specified, if not specified
 * name and email of the platform admin are used
 *
 * @author Bert Vanderkimpen ICT&O UGent
 * @author Yannick Warnier <*****@*****.**>
 *
 * @param string    name of recipient
 * @param string    email of recipient
 * @param string    email subject
 * @param string    email body
 * @param string    sender name
 * @param string    sender e-mail
 * @param array     extra headers in form $headers = array($name => $value) to allow parsing
 * @param array     data file (path and filename)
 * @param array     data to attach a file (optional)
 * @param bool      True for attaching a embedded file inside content html (optional)
 * @return          returns true if mail was sent
 * @see             class.phpmailer.php
 */
function api_mail_html($recipient_name, $recipient_email, $subject, $message, $senderName = '', $senderEmail = '', $extra_headers = array(), $data_file = array(), $embedded_image = false, $additionalParameters = array())
{
    // Default values
    $notification = new Notification();
    $defaultEmail = $notification->getDefaultPlatformSenderEmail();
    $defaultName = $notification->getDefaultPlatformSenderName();
    // If the parameter is set don't use the admin.
    $senderName = !empty($senderName) ? $senderName : $defaultName;
    $senderEmail = !empty($senderEmail) ? $senderEmail : $defaultEmail;
    $link = isset($additionalParameters['link']) ? $additionalParameters['link'] : '';
    $swiftMessage = \Swift_Message::newInstance()->setSubject($subject)->setFrom($senderEmail, $senderName)->setTo($recipient_email, $recipient_name)->setBody(Container::getTemplating()->render('ChamiloCoreBundle:default/mail:mail.html.twig', array('content' => $message, 'link' => $link)), 'text/html');
    if (!empty($additionalParameters)) {
        $plugin = new AppPlugin();
        $smsPlugin = $plugin->getSMSPluginLibrary();
        if ($smsPlugin) {
            $smsPlugin->send($additionalParameters);
        }
    }
    Container::getMailer()->send($swiftMessage);
    return 1;
    global $platform_email;
    $mail = new PHPMailer();
    $mail->Mailer = $platform_email['SMTP_MAILER'];
    $mail->Host = $platform_email['SMTP_HOST'];
    $mail->Port = $platform_email['SMTP_PORT'];
    $mail->CharSet = $platform_email['SMTP_CHARSET'];
    // Stay far below SMTP protocol 980 chars limit.
    $mail->WordWrap = 200;
    if ($platform_email['SMTP_AUTH']) {
        $mail->SMTPAuth = 1;
        $mail->Username = $platform_email['SMTP_USER'];
        $mail->Password = $platform_email['SMTP_PASS'];
    }
    // 5 = low, 1 = high
    $mail->Priority = 3;
    $mail->SMTPKeepAlive = true;
    // Default values
    $notification = new Notification();
    $defaultEmail = $notification->getDefaultPlatformSenderEmail();
    $defaultName = $notification->getDefaultPlatformSenderName();
    // Error to admin.
    $mail->AddCustomHeader('Errors-To: ' . $defaultEmail);
    // If the parameter is set don't use the admin.
    $senderName = !empty($senderName) ? $senderName : $defaultName;
    $senderEmail = !empty($senderEmail) ? $senderEmail : $defaultEmail;
    // Reply to first
    if (isset($extra_headers['reply_to'])) {
        $mail->AddReplyTo($extra_headers['reply_to']['mail'], $extra_headers['reply_to']['name']);
        $mail->Sender = $extra_headers['reply_to']['mail'];
        unset($extra_headers['reply_to']);
    }
    //If the SMTP configuration only accept one sender
    if ($platform_email['SMTP_UNIQUE_SENDER']) {
        $senderName = $platform_email['SMTP_FROM_NAME'];
        $senderEmail = $platform_email['SMTP_FROM_EMAIL'];
    }
    $mail->SetFrom($senderEmail, $senderName);
    $mail->Subject = $subject;
    $mail->AltBody = strip_tags(str_replace('<br />', "\n", api_html_entity_decode($message)));
    // Send embedded image.
    if ($embedded_image) {
        // Get all images html inside content.
        preg_match_all("/<img\\s+.*?src=[\"\\']?([^\"\\' >]*)[\"\\']?[^>]*>/i", $message, $m);
        // Prepare new tag images.
        $new_images_html = array();
        $i = 1;
        if (!empty($m[1])) {
            foreach ($m[1] as $image_path) {
                $real_path = realpath($image_path);
                $filename = basename($image_path);
                $image_cid = $filename . '_' . $i;
                $encoding = 'base64';
                $image_type = mime_content_type($real_path);
                $mail->AddEmbeddedImage($real_path, $image_cid, $filename, $encoding, $image_type);
                $new_images_html[] = '<img src="cid:' . $image_cid . '" />';
                $i++;
            }
        }
        // Replace origin image for new embedded image html.
        $x = 0;
        if (!empty($m[0])) {
            foreach ($m[0] as $orig_img) {
                $message = str_replace($orig_img, $new_images_html[$x], $message);
                $x++;
            }
        }
    }
    $message = str_replace(array("\n\r", "\n", "\r"), '<br />', $message);
    $mailView = new Template(null, false, false, false, false, false, false);
    $mailView->assign('content', $message);
    $link = $additionalParameters['link'];
    $mailView->assign('link', $link);
    $layout = $mailView->get_template('mail/mail.tpl');
    $mail->Body = $mailView->fetch($layout);
    // Attachment ...
    if (!empty($data_file)) {
        $mail->AddAttachment($data_file['path'], $data_file['filename']);
    }
    // Only valid addresses are accepted.
    if (is_array($recipient_email)) {
        foreach ($recipient_email as $dest) {
            if (api_valid_email($dest)) {
                $mail->AddAddress($dest, $recipient_name);
            }
        }
    } else {
        if (api_valid_email($recipient_email)) {
            $mail->AddAddress($recipient_email, $recipient_name);
        } else {
            return 0;
        }
    }
    if (is_array($extra_headers) && count($extra_headers) > 0) {
        foreach ($extra_headers as $key => $value) {
            switch (strtolower($key)) {
                case 'encoding':
                case 'content-transfer-encoding':
                    $mail->Encoding = $value;
                    break;
                case 'charset':
                    $mail->Charset = $value;
                    break;
                case 'contenttype':
                case 'content-type':
                    $mail->ContentType = $value;
                    break;
                default:
                    $mail->AddCustomHeader($key . ':' . $value);
                    break;
            }
        }
    } else {
        if (!empty($extra_headers)) {
            $mail->AddCustomHeader($extra_headers);
        }
    }
    // WordWrap the html body (phpMailer only fixes AltBody) FS#2988
    $mail->Body = $mail->WrapText($mail->Body, $mail->WordWrap);
    // Send the mail message.
    if (!$mail->Send()) {
        error_log('ERROR: mail not sent to ' . $recipient_name . ' (' . $recipient_email . ') because of ' . $mail->ErrorInfo . '<br />');
        return 0;
    }
    if (!empty($additionalParameters)) {
        $plugin = new AppPlugin();
        $smsPlugin = $plugin->getSMSPluginLibrary();
        if ($smsPlugin) {
            $smsPlugin->send($additionalParameters);
        }
    }
    // Clear all the addresses.
    $mail->ClearAddresses();
    return 1;
}
コード例 #25
0
ファイル: phpfn12.php プロジェクト: NaurozAhmad/Senho
function ew_SendEmail($sFrEmail, $sToEmail, $sCcEmail, $sBccEmail, $sSubject, $sMail, $sFormat, $sCharset, $sSmtpSecure = "", $arAttachments = array(), $arImages = array(), $arProperties = NULL)
{
    global $Language, $gsEmailErrDesc;
    $res = FALSE;
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = EW_SMTP_SERVER;
    $mail->SMTPAuth = EW_SMTP_SERVER_USERNAME != "" && EW_SMTP_SERVER_PASSWORD != "";
    $mail->Username = EW_SMTP_SERVER_USERNAME;
    $mail->Password = EW_SMTP_SERVER_PASSWORD;
    $mail->Port = EW_SMTP_SERVER_PORT;
    if ($sSmtpSecure != "") {
        $mail->SMTPSecure = $sSmtpSecure;
    }
    if (preg_match('/^(.+)<([\\w.%+-]+@[\\w.-]+\\.[A-Z]{2,6})>$/i', trim($sFrEmail), $m)) {
        $mail->From = $m[2];
        $mail->FromName = trim($m[1]);
    } else {
        $mail->From = $sFrEmail;
        $mail->FromName = $sFrEmail;
    }
    $mail->Subject = $sSubject;
    if (ew_SameText($sFormat, "html")) {
        $mail->IsHTML(TRUE);
        $mail->Body = $sMail;
    } else {
        $mail->IsHTML(FALSE);
        $mail->Body = @Html2Text\Html2Text::convert($sMail);
    }
    if ($sCharset != "" && strtolower($sCharset) != "iso-8859-1") {
        $mail->CharSet = $sCharset;
    }
    $sToEmail = str_replace(";", ",", $sToEmail);
    $arrTo = explode(",", $sToEmail);
    foreach ($arrTo as $sTo) {
        $mail->AddAddress(trim($sTo));
    }
    if ($sCcEmail != "") {
        $sCcEmail = str_replace(";", ",", $sCcEmail);
        $arrCc = explode(",", $sCcEmail);
        foreach ($arrCc as $sCc) {
            $mail->AddCC(trim($sCc));
        }
    }
    if ($sBccEmail != "") {
        $sBccEmail = str_replace(";", ",", $sBccEmail);
        $arrBcc = explode(",", $sBccEmail);
        foreach ($arrBcc as $sBcc) {
            $mail->AddBCC(trim($sBcc));
        }
    }
    if (is_array($arAttachments)) {
        foreach ($arAttachments as $attachment) {
            $filename = @$attachment["filename"];
            $content = @$attachment["content"];
            if ($content != "" && $filename != "") {
                $mail->AddStringAttachment($content, $filename);
            } else {
                if ($filename != "") {
                    $mail->AddAttachment($filename);
                }
            }
        }
    }
    if (is_array($arImages)) {
        foreach ($arImages as $tmpimage) {
            $file = ew_UploadPathEx(TRUE, EW_UPLOAD_DEST_PATH) . $tmpimage;
            $cid = ew_TmpImageLnk($tmpimage, "cid");
            $mail->AddEmbeddedImage($file, $cid, $tmpimage);
        }
    }
    if (is_array($arProperties)) {
        foreach ($arProperties as $key => $value) {
            $mail->set($key, $value);
        }
    }
    $res = $mail->Send();
    $gsEmailErrDesc = $mail->ErrorInfo;
    // Uncomment to debug
    //		var_dump($mail); exit();
    return $res;
}
コード例 #26
0
ファイル: Util.php プロジェクト: atoledov/siglab
 public static function sendMail($to, $subject, $content, $from = '*****@*****.**', $file = '', IConnection $connect = null, $image = '')
 {
     $objConfigVar = ConfigVar::getConfigVar();
     $flag = true;
     $to = str_replace('@geainternacional.com', '@alertas.geainternacional.com', $to);
     $arrayTo = array();
     $arrayFiles = array();
     $arrayImages = array();
     if (strpos($to, ";") !== FALSE) {
         $arrayTo = explode(";", $to);
     } else {
         if (strpos($to, ",") !== FALSE) {
             $arrayTo = explode(",", $to);
         } else {
             $arrayTo[] = $to;
         }
     }
     if ($file != '') {
         if (strpos($file, ',') !== FALSE) {
             $files = explode(',', $file);
             foreach ($files as $file_tmp) {
                 if (file_exists($file_tmp)) {
                     $arrayFiles[] = $file_tmp;
                 }
             }
         } else {
             if (file_exists($file)) {
                 $arrayFiles[] = $file;
             }
         }
     }
     if ($image != '') {
         if (strpos($image, ',') !== FALSE) {
             $images = explode(',', $image);
             foreach ($images as $image_tmp) {
                 if (file_exists($image_tmp)) {
                     $arrayImages[] = $image_tmp;
                 }
             }
         } else {
             if (file_exists($image)) {
                 $arrayImages[] = $image;
             }
         }
     }
     $mail = new PHPMailer();
     //$mail->PluginDir = $sPluginDir;
     $mail->Mailer = "smtp";
     $mail->Host = $objConfigVar->getEmailHost();
     $mail->Port = $objConfigVar->getEmailPort();
     $mail->Username = $objConfigVar->getEmailUser();
     $mail->Password = $objConfigVar->getEmailPwd();
     $mail->SMTPAuth = true;
     $mail->Timeout = 10;
     $mail->From = $from;
     $mail->FromName = '';
     $mail->Subject = $subject;
     $mail->ContentType = 'multipart/related';
     foreach ($arrayTo as $emailTo) {
         $mail->AddAddress($emailTo);
     }
     foreach ($arrayFiles as $attachment) {
         $filename = basename($attachment);
         $mail->AddAttachment($attachment, $filename);
         $content .= "<br/>== Este email incluye el archivo: {$filename} ==";
     }
     foreach ($arrayImages as $attachment) {
         $filename = basename($attachment);
         $mimeType = mime_content_type($attachment);
         $mail->AddEmbeddedImage($attachment, Util::getImageCID($attachment), $filename, 'base64', $mimeType);
         $content .= "<br/>== Este email adjunta una imagen ==";
     }
     $mail->MsgHTML($content);
     if ($objConfigVar->getEmailEnable() == '1') {
         $messageSend = '';
         try {
             $mail->Send();
             $messageSend = 'EXITO [' . $mail->ErrorInfo . ']';
         } catch (phpmailerException $ex1) {
             $messageSend = 'ERROR: ' . $ex1->errorMessage();
         }
         if ($connect != null) {
             global $objGlobalUser;
             try {
                 $sql = "INSERT INTO bitacora_correos(btc_fechahora,btc_modulo,btc_usuario,btc_para,btc_subject,btc_mensaje)\r\n                            VALUES(?,?,?,?,?,?)";
                 $connect->prepareSql($sql, "NOW()", "ENVIO: {$content}", $objGlobalUser->getUsername(), $to, $subject, $messageSend);
                 $connect->executeQuery();
             } catch (MyException $ex) {
             }
         }
     } else {
         $flag = false;
     }
     return $flag;
 }
コード例 #27
0
ファイル: mail.php プロジェクト: ShengpouLai/aiyue
//编码方式
$mail->Username = "******";
//你的邮箱
$mail->Password = "******";
//你的密码
$mail->Subject = "你好";
//邮件标题
$mail->From = "*****@*****.**";
//发件人地址(也就是你的邮箱)
$mail->FromName = "月光光";
//发件人姓名
$address = "";
//收件人email
$mail->AddAddress($address, "亲");
//添加收件人(地址,昵称)
$mail->AddAttachment('xx.xls', '我的附件.xls');
// 添加附件,并指定名称
$mail->IsHTML(true);
//支持html格式内容
$mail->AddEmbeddedImage("logo.jpg", "my-attach", "logo.jpg");
//设置邮件中的图片
$mail->Body = '你好, <b>朋友</b>! <br/>这是一封来自<a href="http://www.helloweba.com" target="_blank">helloweba.com</a>的邮件!<br/><img alt="helloweba" src="cid:my-attach">';
//邮件主体内容
//发送
if (!$mail->Send()) {
    echo "发送失败: " . $mail->ErrorInfo;
} else {
    $_SESSION['ip'] = get_client_ip();
    $_SESSION['time'] = time();
    echo "1";
}
コード例 #28
0
 public function sendEmail($subject, $message, $userid, $cc = false)
 {
     // Sends a html mail to the given userid. If $userid == "developers", then we send a mail to the DeepskyLog team.
     // If $cc is true, we also send a CC to the developers.
     global $mailFrom, $instDir, $objObserver;
     global $mailHost, $mailSMTPAuth, $mailServerUsername, $mailServerPassword, $mailSMTPSecure, $mailPort;
     require_once 'PHPMailer/class.phpmailer.php';
     // Making the headers for the html mail
     $headers = "From: " . $mailFrom . "\r\n";
     $headers .= "Reply-To: " . $mailFrom . "\r\n";
     $headers .= "MIME-Version: 1.0\r\n";
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
     // Add header and footer to mail.
     $messageHeader = '<html><body>';
     $messageHeader .= '<h1>' . $subject . '</h1>';
     $messageFooter = '<a href=""><img src="cid:logo" style="width:80%;"></a>';
     $messageFooter .= '</body></html>';
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // set mailer to use SMTP
     $mail->Host = $mailHost;
     $mail->SMTPAuth = $mailSMTPAuth;
     $mail->Username = $mailServerUsername;
     // SMTP username
     $mail->Password = $mailServerPassword;
     // SMTP password
     $mail->SMTPSecure = $mailSMTPSecure;
     $mail->Port = $mailPort;
     // SMTP Port
     $mail->From = $mailFrom;
     //From Address
     $mail->FromName = "DeepskyLog Team";
     //From Name
     // We get the mailaddress and the full name from the userid
     if (strcmp($userid, "developers") == 0) {
         $fullName = "DeepskyLog Team";
         $mailAddress = $mailFrom;
     } else {
         $fullName = $objObserver->getFullName($userid);
         $mailAddress = $objObserver->getObserverProperty($userid, "email", '');
     }
     $mail->AddAddress($mailAddress, $fullName);
     //To Address
     $mail->AddReplyTo($mailFrom, "DeepskyLog Team");
     //Reply-To Address
     if ($cc) {
         $mail->AddCC($mailFrom);
     }
     $mail->WordWrap = 50;
     // set word wrap to 50 characters
     $mail->IsHTML(true);
     // set email format to HTML
     $mail->AddEmbeddedImage($instDir . '/images/logo.png', 'logo');
     $mail->Subject = $subject;
     $mail->Body = $messageHeader . $message . $messageFooter;
     $mail->send();
 }
コード例 #29
0
 $_SESSION['nama'] = $_POST['qtxt'];
 $_SESSION['tlp'] = $row_customer['tlp'];
 $_SESSION['kendaraan'] = $_POST['kendaraan'];
 $_SESSION['barang'] = $_POST['txtbarang'];
 $_SESSION['checkin'] = $checkin;
 $_SESSION['checkout'] = $checkout;
 $_SESSION['cabang'] = $_POST['txtcabang'];
 $_SESSION['transaksi'] = $_POST['transaksi'];
 */
 $mail->isHTML(true);
 $mail->Subject = 'TICKETING CONFIRMATION';
 //$url = "http://localhost/rental/proses/mailer.php/$_POST[noreferensi]/$_POST[qtxt]/$row_customer[tlp]/$_POST[kendaraan]/$_POST[txtbarang]/$checkin/$checkout/$_POST[txtcabang]/$_POST[transaksi]";
 //$url = "http://118.97.213.239/cipaganti-rentcar/proses/mailer.php?asd=$encrypt_no_ref";
 $url = "http://localhost/cipaganti-rentcar/proses/mailer.php?asd={$encrypt_no_ref}";
 //$url = "http://192.168.112.243/rental/proses/mailer.php/";
 $mail->AddEmbeddedImage('images/button.png', 'button', 'images/button.png');
 $myBody = "<html>";
 $myBody .= "<head>";
 $myBody .= "<title>TICKETING CONFIRMATION</title>";
 //$myBody .= "<link href=\"button.css\" rel=\"stylesheet\" type=\"text/css\" />";
 $myBody .= "</head>";
 $myBody .= "<body>";
 $myBody .= "<table width=\"600\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
 $myBody .= "<tr>";
 $myBody .= "<td align=\"center\" valign=\"middle\" bgcolor=\"#000000\" style=\"background-color:#000000; padding:20px; color:#ffffff;\">";
 $myBody .= "<div style=\"font-size:24px;\">CIPAGANTI CAR RENTAL</div>";
 $myBody .= "</td>";
 //$myBody .= "<td align=\"right\" valign=\"top\"><img src=\"cid:logoimg\" width=\"197\" height=\"182\" style=\"display:block;\"></td>";
 $myBody .= "</tr>";
 $myBody .= "</table>";
 $myBody .= "<table width=\"600\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#971800\" style=\"background-color:#971800;\">";
コード例 #30
0
ファイル: UserApi.php プロジェクト: rtznprmpftl/Zikulacore
 /**
  * API function to send e-mail message
  * @param string $args['fromname'] name of the sender
  * @param string $args['fromaddress'] address of the sender
  * @param string $args['toname '] name to the recipient
  * @param string $args['toaddress'] the address of the recipient
  * @param string $args['replytoname '] name to reply to
  * @param string $args['replytoaddress'] address to reply to
  * @param string $args['subject'] message subject
  * @param string $args['contenttype '] optional contenttype of the mail (default config)
  * @param string $args['charset'] optional charset of the mail (default config)
  * @param string $args['encoding'] optional mail encoding (default config)
  * @param string $args['body'] message body, if altbody is provided then this
  *                  is the HTML version of the body
  * @param string $args['altbody'] alternative plain-text message body, if
  *                  specified the e-mail will be sent as multipart/alternative
  * @param array  $args['cc'] addresses to add to the cc list
  * @param array  $args['bcc'] addresses to add to the bcc list
  * @param array|string $args['headers'] custom headers to add
  * @param int $args['html'] HTML flag, if altbody is not specified then this
  *                  indicates whether body contains HTML or not; if altbody is
  *                  specified, then this value is ignored, the body is assumed
  *                  to be HTML, and the altbody is assumed to be plain text
  * @param array $args['attachments'] array of either absolute filenames to attach
  *                  to the mail or array of arays in format
  *                  array($string,$filename,$encoding,$type)
  * @param array $args['stringattachments'] array of arrays to treat as attachments,
  *                  format array($string,$filename,$encoding,$type)
  * @param array $args['embeddedimages'] array of absolute filenames to image files
  *                  to embed in the mail
  * @todo Loading of language file based on Zikula language
  * @return bool true if successful, false otherwise
  */
 public function sendmessage($args)
 {
     // Check for installed advanced Mailer module
     $event = new GenericEvent($this, $args);
     $this->dispatcher->dispatch('module.mailer.api.sendmessage', $event);
     if ($event->isPropagationStopped()) {
         return $event->getData();
     }
     // include php mailer class file
     require_once \ZIKULA_ROOT . "/system/Mailer/lib/vendor/class.phpmailer.php";
     // create new instance of mailer class
     $mail = new \PHPMailer();
     // set default message parameters
     $mail->PluginDir = "system/Mailer/lib/vendor/";
     $mail->ClearAllRecipients();
     $mail->ContentType = isset($args['contenttype']) ? $args['contenttype'] : $this->getVar('contenttype');
     $mail->CharSet = isset($args['charset']) ? $args['charset'] : $this->getVar('charset');
     $mail->Encoding = isset($args['encoding']) ? $args['encoding'] : $this->getVar('encoding');
     $mail->WordWrap = $this->getVar('wordwrap');
     // load the language file
     $mail->SetLanguage('en', $mail->PluginDir . 'language/');
     // get MTA configuration
     if ($this->getVar('mailertype') == 4) {
         $mail->IsSMTP();
         // set mailer to use SMTP
         $mail->Host = $this->getVar('smtpserver');
         // specify server
         $mail->Port = $this->getVar('smtpport');
         // specify port
     } elseif ($this->getVar('mailertype') == 3) {
         $mail->IsQMail();
         // set mailer to use QMail
     } elseif ($this->getVar('mailertype') == 2) {
         ini_set("sendmail_from", $args['fromaddress']);
         $mail->IsSendMail();
         // set mailer to use SendMail
         $mail->Sendmail = $this->getVar('sendmailpath');
         // specify Sendmail path
     } else {
         $mail->IsMail();
         // set mailer to use php mail
     }
     // set authentication paramters if required
     if ($this->getVar('smtpauth') == 1) {
         $mail->SMTPAuth = true;
         // turn on SMTP authentication
         $mail->SMTPSecure = $this->getVar('smtpsecuremethod');
         // SSL or TLS
         $mail->Username = $this->getVar('smtpusername');
         // SMTP username
         $mail->Password = $this->getVar('smtppassword');
         // SMTP password
     }
     // set HTML mail if required
     if (isset($args['html']) && is_bool($args['html'])) {
         $mail->IsHTML($args['html']);
         // set email format to HTML
     } else {
         $mail->IsHTML($this->getVar('html'));
         // set email format to the default
     }
     // set fromname and fromaddress, default to 'sitename' and 'adminmail' config vars
     $mail->FromName = isset($args['fromname']) && $args['fromname'] ? $args['fromname'] : System::getVar('sitename');
     $mail->From = isset($args['fromaddress']) && $args['fromaddress'] ? $args['fromaddress'] : System::getVar('adminmail');
     // add any to addresses
     if (is_array($args['toaddress'])) {
         $i = 0;
         foreach ($args['toaddress'] as $toadd) {
             isset($args['toname'][$i]) ? $toname = $args['toname'][$i] : ($toname = $toadd);
             $mail->AddAddress($toadd, $toname);
             $i++;
         }
     } else {
         // $toaddress is not an array -> old logic
         $toname = '';
         if (isset($args['toname'])) {
             $toname = $args['toname'];
         }
         // process multiple names entered in a single field separated by commas (#262)
         foreach (explode(',', $args['toaddress']) as $toadd) {
             $mail->AddAddress($toadd, $toname == '' ? $toadd : $toname);
         }
     }
     // if replytoname and replytoaddress have been provided us them
     // otherwise take the fromaddress, fromname we build earlier
     if (!isset($args['replytoname']) || empty($args['replytoname'])) {
         $args['replytoname'] = $mail->FromName;
     }
     if (!isset($args['replytoaddress']) || empty($args['replytoaddress'])) {
         $args['replytoaddress'] = $mail->From;
     }
     $mail->AddReplyTo($args['replytoaddress'], $args['replytoname']);
     // add any cc addresses
     if (isset($args['cc']) && is_array($args['cc'])) {
         foreach ($args['cc'] as $email) {
             if (isset($email['name'])) {
                 $mail->AddCC($email['address'], $email['name']);
             } else {
                 $mail->AddCC($email['address']);
             }
         }
     }
     // add any bcc addresses
     if (isset($args['bcc']) && is_array($args['bcc'])) {
         foreach ($args['bcc'] as $email) {
             if (isset($email['name'])) {
                 $mail->AddBCC($email['address'], $email['name']);
             } else {
                 $mail->AddBCC($email['address']);
             }
         }
     }
     // add any custom headers
     if (isset($args['headers']) && is_string($args['headers'])) {
         $args['headers'] = explode("\n", $args['headers']);
     }
     if (isset($args['headers']) && is_array($args['headers'])) {
         foreach ($args['headers'] as $header) {
             $mail->AddCustomHeader($header);
         }
     }
     // add message subject and body
     $mail->Subject = $args['subject'];
     $mail->Body = $args['body'];
     if (isset($args['altbody']) && !empty($args['altbody'])) {
         $mail->AltBody = $args['altbody'];
     }
     // add attachments
     if (isset($args['attachments']) && !empty($args['attachments'])) {
         foreach ($args['attachments'] as $attachment) {
             if (is_array($attachment)) {
                 if (count($attachment) != 4) {
                     // skip invalid arrays
                     continue;
                 }
                 $mail->AddAttachment($attachment[0], $attachment[1], $attachment[2], $attachment[3]);
             } else {
                 $mail->AddAttachment($attachment);
             }
         }
     }
     // add string attachments.
     if (isset($args['stringattachments']) && !empty($args['stringattachments'])) {
         foreach ($args['stringattachments'] as $attachment) {
             if (is_array($attachment) && count($attachment) == 4) {
                 $mail->AddStringAttachment($attachment[0], $attachment[1], $attachment[2], $attachment[3]);
             }
         }
     }
     // add embedded images
     if (isset($args['embeddedimages']) && !empty($args['embeddedimages'])) {
         foreach ($args['embeddedimages'] as $embeddedimage) {
             $ret = $mail->AddEmbeddedImage($embeddedimage['path'], $embeddedimage['cid'], $embeddedimage['name'], $embeddedimage['encoding'], $embeddedimage['type']);
         }
     }
     // send message
     if (!$mail->Send()) {
         // message not send
         $args['errorinfo'] = $mail->IsError() ? $mail->ErrorInfo : __('Error! An unidentified problem occurred while sending the e-mail message.');
         LogUtil::log(__f('Error! A problem occurred while sending an e-mail message from \'%1$s\' (%2$s) to (%3$s) (%4$s) with the subject line \'%5$s\': %6$s', $args));
         if (SecurityUtil::checkPermission('Mailer::', '::', ACCESS_ADMIN)) {
             return LogUtil::registerError($args['errorinfo']);
         } else {
             return LogUtil::registerError(__('Error! A problem occurred while sending the e-mail message.'));
         }
     }
     return true;
     // message sent
 }