isSendmail() public method

Send messages using $Sendmail.
public isSendmail ( ) : void
return void
Esempio n. 1
0
 public function init()
 {
     $this->_mailer = new \PHPMailer();
     switch ($this->method) {
         case 'smtp':
             $this->_mailer->isSMTP();
             $this->_mailer->Host = $this->smtp['host'];
             if (!empty($this->smtp['username'])) {
                 $this->_mailer->SMTPAuth = true;
                 $this->_mailer->Username = $this->smtp['username'];
                 $this->_mailer->Password = $this->smtp['password'];
             } else {
                 $this->_mailer->SMTPAuth = false;
             }
             if (isset($this->smtp['port'])) {
                 $this->_mailer->Port = $this->smtp['port'];
             }
             if (isset($this->smtp['secure'])) {
                 $this->_mailer->SMTPSecure = $this->smtp['secure'];
             }
             if (isset($this->smtp['debug'])) {
                 $this->_mailer->SMTPDebug = (int) $this->smtp['debug'];
             }
             break;
         case 'sendmail':
             $this->_mailer->isSendmail();
             break;
         default:
             $this->_mailer->isMail();
     }
     $this->_mailer->CharSet = \Yii::app()->charset;
     parent::init();
 }
 /**
  * Create the PHPMailer instance
  *
  * @return PHPMailer
  */
 private function createMailer()
 {
     $this->mailer = new PHPMailer(true);
     if ($this->attributes['smtp']) {
         $this->smtp();
     } elseif (array_get($this->attributes, 'sendmail')) {
         $this->mailer->isSendmail();
     } else {
         $this->mailer->isMail();
     }
     return $this->mailer;
 }
Esempio n. 3
0
function sendEmail($expediteur, $destinataires, $messageHTML, $objet = "", $attachmentEmail = "")
{
    global $thisSite;
    global $pathRacine;
    if ($expediteur == "") {
        return 0;
    }
    if ($destinataires == "") {
        return 0;
    }
    if (!is_array($destinataires)) {
        $destinataires = array($destinataires);
    }
    require_once $pathRacine . $thisSite->DOS_BASE_LIB . 'phpmailer/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    if ($thisSite->MAIL_SENDMODE == "smtp") {
        $mail->isSMTP();
        //$mail->SMTPDebug = 2;
        //$mail->Debugoutput = 'html';
        $mail->Host = $thisSite->MAIL_HOST;
        //Set the hostname of the mail server
        $mail->Port = $thisSite->MAIL_PORT;
        //Set the SMTP port number - likely to be 25, 465 or 587
        $mail->SMTPAuth = $thisSite->SMTPAuth;
        //Whether to use SMTP authentication
        $mail->Username = $thisSite->MAIL_Username;
        //Username to use for SMTP authentication
        $mail->Password = $thisSite->MAIL_Password;
        //Password to use for SMTP authentication
    } else {
        if ($thisSite->MAIL_SENDMODE == "mail") {
            $mail->isMail();
        } else {
            if ($thisSite->MAIL_SENDMODE == "sendmail") {
                $mail->isSendmail();
            }
        }
    }
    $mail->From = $thisSite->MAIL_SENDER;
    $mail->addReplyTo($expediteur, $expediteur);
    $mail->From = $expediteur;
    $mail->FromName = '';
    foreach ($destinataires as $destinataire) {
        $mail->addAddress($destinataire);
    }
    $mail->isHTML(true);
    $mail->Subject = utf8_decode($objet);
    $mail->Body = utf8_decode($messageHTML);
    if (is_array($attachmentEmail)) {
        foreach ($attachmentEmail as $fichier) {
            $rr = $mail->addAttachment($fichier);
        }
    }
    if (!$mail->send()) {
        $res = $mail->ErrorInfo;
    } else {
        $res = true;
    }
    return $res;
}
Esempio n. 4
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     $checkNewsletter = nNewsletterRecord::finder()->findByStatus(1);
     if ($checkNewsletter) {
         $layout = nLayoutRecord::finder()->findBy_nNewsletterID($checkNewsletter->ID);
         $mail = new PHPMailer();
         $mail->isSendmail();
         $mail->setFrom('*****@*****.**', 'First Last');
         $mail->addReplyTo('*****@*****.**');
         $lista = nSenderRecord::finder()->findAll('nLayoutID = ? AND Status = 0 LIMIT 25', $layout->ID);
         foreach ($lista as $person) {
             $mail->addAddress($person->Email);
             $mail->Subject = $checkNewsletter->Name;
             $mail->msgHTML($layout->HtmlText);
             if ($mail->send()) {
                 $person->Status = 1;
                 $person->save();
             } else {
                 $person->Status = 5;
                 $person->save();
                 echo "Mailer Error: " . $mail->ErrorInfo;
             }
         }
         if (empty($lista)) {
             $checkNewsletter->Status = 0;
             $checkNewsletter->save();
         }
     }
     die;
 }
Esempio n. 5
0
function sendEmail($userEmail, $userFName, $userLName, $date, $price)
{
    $mail = new PHPMailer();
    $mail->isSendmail();
    $mail->setFrom('*****@*****.**', 'Help Desk');
    $mail->addReplyTo('*****@*****.**', 'Efraim Krug');
    $mail->addAddress($userEmail, 'User Krug');
    $message = "<html><body style=\"font:14px Arial,Helvetica,sans-serif; color:#000; background:#fff\">";
    $message .= "\n<p>Dear " . $userFName . " " . $userLName . "</p>";
    $message .= "\n<p>Please do not reply to this message, as it was sent from an unattended mail box.</p>";
    $message .= "\n<p>This is an automated invoice for the Caneur!</p>";
    $message .= "\n<p>For service rendered on " . $date . "</p>";
    $message .= "\n<p>For the amount of " . number_format($price, 2) . "</p>";
    $message .= "\n<p>Thank you so much for your patronage!</p>";
    $message .= "\n<p>Best to you and your family!</p>";
    $message .= "\n<p>Your local Caneur!</p>";
    $message .= "</body></html>";
    $mail->Subject = 'Caneur invoice - ' . $date;
    $mail->msgHTML($message);
    #$mail->addAttachment($FileName);
    #if (!$mail->send()) {
    #    echo "Mailer Error: " . $mail->ErrorInfo;
    #} else {
    #    echo "Message sent!";
    #}
    return;
}
Esempio n. 6
0
 public function execute($_options = null)
 {
     $eqLogic = $this->getEqLogic();
     if ($_options === null) {
         throw new Exception('[Mail] Les options de la fonction ne peuvent etre null');
     }
     if ($_options['message'] == '' && $_options['title'] == '') {
         throw new Exception('[Mail] Le message et le sujet ne peuvent être vide');
         return false;
     }
     if ($_options['title'] == '') {
         $_options['title'] = '[Jeedom] - Notification';
     }
     $mail = new PHPMailer(true);
     //PHPMailer instance with exceptions enabled
     $mail->CharSet = 'utf-8';
     $mail->SMTPDebug = 0;
     switch ($eqLogic->getConfiguration('sendMode', 'mail')) {
         case 'smtp':
             $mail->isSMTP();
             $mail->Host = $eqLogic->getConfiguration('smtp::server');
             $mail->Port = (int) $eqLogic->getConfiguration('smtp::port');
             $mail->SMTPSecure = $eqLogic->getConfiguration('smtp::security');
             if ($eqLogic->getConfiguration('smtp::username') != '') {
                 $mail->SMTPAuth = true;
                 $mail->Username = $eqLogic->getConfiguration('smtp::username');
                 // SMTP account username
                 $mail->Password = $eqLogic->getConfiguration('smtp::password');
                 // SMTP account password
             }
             break;
         case 'mail':
             $mail->isMail();
             break;
         case 'sendmail':
             $mail->isSendmail();
         case 'qmail':
             $mail->isQmail();
             break;
         default:
             throw new Exception('Mode d\'envoi non reconnu');
     }
     if ($eqLogic->getConfiguration('fromName') != '') {
         $mail->addReplyTo($eqLogic->getConfiguration('fromMail'), $eqLogic->getConfiguration('fromName'));
         $mail->FromName = $eqLogic->getConfiguration('fromName');
     } else {
         $mail->addReplyTo($eqLogic->getConfiguration('fromMail'));
         $mail->FromName = $eqLogic->getConfiguration('fromMail');
     }
     $mail->From = $eqLogic->getConfiguration('fromMail');
     $mail->addAddress($this->getConfiguration('recipient'));
     $mail->Subject = $_options['title'];
     $mail->msgHTML(htmlentities($_options['message']), dirname(__FILE__), true);
     return $mail->send();
 }
Esempio n. 7
0
function sendEmail($data)
{
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->isSendmail();
    $mail->setFrom('*****@*****.**', $data['name']);
    $mail->addAddress('*****@*****.**', "Ирине Тишкевич");
    $mail->Subject = "Отправка письма с shop.ru";
    $mail->msgHTML('Заказан звонок от: ' . $data['name'] . '.  Дата: ' . $data['day'] . '.' . $data['month'] . '. Телефон: ' . $data['phone'] . '. Комментарий: ' . $data['message']);
    return $mail->send();
}
 /**
  * @param User $user
  *
  * @throws \phpmailerException
  */
 protected function sendVerificationMail($user)
 {
     $mail = new \PHPMailer();
     $mail->isSendmail();
     $mail->setFrom('*****@*****.**', 'Sample Blog News');
     $mail->addAddress($user->email, $user->email);
     $mail->Subject = 'Confirm your Sample Blog News account';
     $body = "You need to confirm your email address " . $user->email . " in order to activate your Sample Blog News\n            account. <br/> Activating your account will give you more benefits and better control.<br />\n            Please click the link below to confirm your account <br />\n            http://" . $this->getRequest()->getUri()->getHost() . "/account/confirm/" . $user->token;
     $mail->msgHTML($body);
     $mail->send();
 }
Esempio n. 9
0
 /**
  * Miscellaneous calls to improve test coverage and some small tests.
  */
 public function testMiscellaneous()
 {
     $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
     $this->Mail->addCustomHeader('SomeHeader: Some Value');
     $this->Mail->clearCustomHeaders();
     $this->Mail->clearAttachments();
     $this->Mail->isHTML(false);
     $this->Mail->isSMTP();
     $this->Mail->isMail();
     $this->Mail->isSendmail();
     $this->Mail->isQmail();
     $this->Mail->setLanguage('fr');
     $this->Mail->Sender = '';
     $this->Mail->createHeader();
     $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
     $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
     //Test pathinfo
     $a = '/mnt/files/飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_BASENAME), '飛兒樂 團光茫.mp3', 'Basename path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
     $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
     $this->assertEquals(PHPMailer::filenameToType('abc.jpg?xyz=1'), 'image/jpeg', 'Query string not ignored in filename');
     $this->assertEquals(PHPMailer::filenameToType('abc.xyzpdq'), 'application/octet-stream', 'Default MIME type not applied to unknown extension');
     //Line break normalization
     $eol = $this->Mail->LE;
     $b1 = "1\r2\r3\r";
     $b2 = "1\n2\n3\n";
     $b3 = "1\r\n2\r3\n";
     $this->Mail->LE = "\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (1)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (2)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (3)');
     $this->Mail->LE = "\r\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (4)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (5)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (6)');
     $this->Mail->LE = $eol;
 }
 public function actionCronbalance()
 {
     echo "Running Script...<br>";
     // Yii::app()->db->createCommand($sql)->queryAll();
     // Get all of the current asset accounts
     $sql = "SELECT Account.code AS accountcode, Account.name AS accountname, Account.email AS email, Account.balance_threshold AS threshold, Account.days AS days, e1.amount AS balance\n\t\t\t\tFROM Account\n\t\t\t\tJOIN (\n\t\t\t\tselect accountId, TRIM( TRAILING 0 FROM ROUND( SUM( amount ) , 5 ) ) AS 'amount'\n\t\t\t\tFROM TransRow\n\t\t\t\tjoin Account on Account.id=accountId\n\t\t\t\tWHERE accountId = Account.id\n\t\t\t\tgroup by accountId) e1 ON e1.accountId = Account.id\n\t\t\t\tWHERE (Account.code BETWEEN '101000' AND '102999')\n\t\t\t\tORDER BY Account.code";
     // OR (Account.companyId = ".Yii::app()->user->getState('selectedCompanyId')."))
     $accounts = Yii::app()->db->createCommand($sql)->queryAll();
     Yii::import('application.controllers.mailer.*');
     require_once "PHPMailerAutoload.php";
     foreach ($accounts as $account) {
         if (!empty($account['email'])) {
             // echo "Account Code: ".$account['accountcode']."<br>";
             // echo "Account Name: ".$account['accountname']."<br>";
             $threshold = empty($account['threshold']) ? 0 : intval($account['threshold']);
             $days = empty($account['days']) ? 90 : intval($account['days']);
             $balance = empty($account['balance']) ? 0 : intval($account['balance']);
             // echo "Threshold is: ".$threshold."<br>";
             // echo "Balance is: ".$balance."<br>";
             // Continue with checking balance
             if ($balance < $threshold) {
                 // echo "Notifying email...<br>";
                 $mail = new PHPMailer();
                 $mail->CharSet = 'UTF-8';
                 $mail->isSendmail();
                 $mail->isHTML(true);
                 $message = '<!DOCTYPE HTML>' . '<head>' . '<meta http-equiv="content-type" content="text/html; charset=utf-8">' . '<title>FCF Accounting Email notification</title>' . '</head>';
                 // // Notify all emails attatched to account
                 $email_arr = explode(",", $account['email']);
                 foreach ($email_arr as $email) {
                     $email = trim($email);
                     // echo 'Users email: '.$email.'<br>';
                     $mail->addAddress($email);
                 }
                 $mail->setFrom('*****@*****.**', 'FCF Accounting');
                 $message .= '<body>' . '<p>Hello,</p><br>' . '<p>This a automated notification from accounting at thaiconnections stating that the balance for Account: <strong>' . $account['accountname'] . ' </strong>has gone lower than the given threshold.<p>' . '<p>The current balance is:<strong> ' . $balance . ' Baht</strong><p><br>' . '<p>Kindest Regards,<br>' . 'FCF Accounting</p>' . '</body>';
                 $mail->Subject = 'Balance Threshold Breached';
                 $mail->Body = preg_replace('/\\[\\]/', '', $message);
                 $mail->AltBody = 'Hi, this a automated notification from accounting at thaiconnections stating that the balance for Account: ' . $account['accountname'] . ' has gone lower than the given threshold. The current balance is: ' . $balance . ' Kindest Regards, Thaiconnections Accounting';
                 if (!$mail->send()) {
                     // $this->log('Could not send mail. Please check servers email configurations', 'adminLog');
                     // echo 'Mailer Error: ' . $mail->ErrorInfo;
                 } else {
                     // echo 'Mail sent successfully';
                 }
             }
         }
     }
     echo "Script has finished....<br>";
     /*		echo "<pre>";
     		//var_dump($accounts);
     		echo "</pre>";*/
 }
Esempio n. 11
0
 public static function send($to, $subject, $params = array(), $vars = array())
 {
     global $LANG;
     if (empty($params['template'])) {
         if (empty($params['message'])) {
             return false;
         } else {
             $text = $params['message'];
         }
     } else {
         if (!file_exists((isset($params['path']) ? $params['path'] : '') . TMAIL_LOCATION . '/' . $params['template'] . '.html')) {
             return false;
         }
         $text = file_get_contents((isset($params['path']) ? $params['path'] : '') . TMAIL_LOCATION . '/' . $params['template'] . '.html');
         extract($vars);
         eval("\$text = \"{$text}\";");
     }
     include (isset($params['path']) ? $params['path'] : '') . LBDIR . '/PHPMailer/class.phpmailer.php';
     $mail = new \PHPMailer();
     $mail->CharSet = 'UTF-8';
     $mail->AddReplyTo(isset($params['reply_to']) ? $params['reply_to'] : \query\main::get_option('email_answer_to'), isset($params['reply_name']) ? $params['reply_name'] : '');
     $mail->From = isset($params['from_name']) ? $params['from_name'] : \query\main::get_option('email_answer_to');
     $mail->FromName = isset($params['from_email']) ? $params['from_email'] : \query\main::get_option('email_from_name');
     $mail->AddAddress($to);
     $mail->Subject = $subject;
     $mail->MsgHTML($text);
     $mail->IsHTML(true);
     switch (\query\main::get_option('mail_method')) {
         case 'SMTP':
             $mail->IsSMTP();
             // tell the class to use SMTP
             $mail->SMTPAuth = \query\main::get_option('smtp_auth');
             $mail->Port = \query\main::get_option('smtp_port');
             $mail->Host = \query\main::get_option('smtp_host');
             $mail->Username = \query\main::get_option('smtp_user');
             $mail->Password = \query\main::get_option('smtp_password');
             break;
         case 'sendmail':
             $mail->isSendmail();
             $mail->Sendmail = \query\main::get_option('sendmail_path');
             break;
         default:
             $mail->isMail();
             break;
     }
     if ($mail->Send()) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 12
0
 /**
  * ### Sets the protcol to be used by PHPMailer
  *
  * @param string $protocol
  */
 private function protocol($protocol)
 {
     switch ($protocol) {
         case 'smtp':
             if (Config::get('mail', 'username')) {
                 $this->mailer->SMTPAuth = true;
             } else {
                 $this->mailer->SMTPAuth = false;
             }
             $this->mailer->isSMTP();
             break;
         case 'php':
             $this->mailer->isSendmail();
             break;
         default:
             if (Config::get('mail', 'username')) {
                 $this->mailer->SMTPAuth = true;
             } else {
                 $this->mailer->SMTPAuth = false;
             }
             $this->mailer->isSMTP();
     }
 }
Esempio n. 13
0
function send_message_to_email($dataMail)
{
    $mail = new PHPMailer();
    $mail->isSendmail();
    $mailer->CharSet = 'UTF-8';
    // Указываем отправителя письма
    $mail->setFrom('*****@*****.**', 'Пушкарской Дарьи');
    // Указываем получателя письма
    $mail->addAddress('*****@*****.**', "Пушкарской Дарье");
    // Указываем тему письма
    $mail->Subject = "Отправка письма с вебинара";
    // Устанавливаем текст сообщения
    $mail->msgHTML("Тестовое письмо c моего сайта-портфолио: " . $dataMail['message'] . ' ' . $dataMail['name'] . ': ' . $dataMail['email']);
    return $mail->send();
}
Esempio n. 14
0
 public function excute()
 {
     $mail = new PHPMailer();
     $mail->isSendmail();
     $mail->setFrom("*****@*****.**", '邮件测试');
     $mail->addAddress("*****@*****.**");
     $mail->Subject = "发个测试邮件";
     $mail->msgHTML("Test");
     $mail->AltBody = 'This is a plain-text message body';
     if (!$mail->send()) {
         echo "Mailer Error: " . $mail->ErrorInfo;
     } else {
         echo "Message sent!";
     }
     exit;
 }
Esempio n. 15
0
 protected function chose_sender_strategy()
 {
     switch ($this->method) {
         case Mailer::MAIL:
             $this->php_mailer->isMail();
             break;
         case Mailer::QMAIL:
             $this->php_mailer->isQmail();
             break;
         case Mailer::SEND_MAIL:
             $this->php_mailer->isSendmail();
             break;
         default:
             $this->php_mailer->isSMTP();
             $this->method = Mailer::SMTP;
     }
 }
Esempio n. 16
0
/**
 * @param $data
 * @param null $file
 * @return bool
 * @throws Exception
 * @throws phpmailerException
 */
function send_message_to_email($data, $file = null)
{
    $mail = new PHPMailer();
    $mail->isSendmail();
    // Указываем отправителя письма
    $mail->setFrom('*****@*****.**', 'Вадим Клычев');
    // Указываем получателя письма
    $mail->addAddress('*****@*****.**', "Вадиму Клычеву");
    // Указываем тему письма
    $mail->Subject = "Отправка письма с сайта WWW-Ka.ru";
    // Устанавливаем текст сообщения
    $mail->msgHTML("Тестовое письмо с вебинара от " . $data['email'] . ' ' . $data['name']);
    if ($file) {
        $mail->addAttachment($file);
    }
    return $mail->send();
}
Esempio n. 17
0
 public static function mailWrapper($to, $subject = '(No subject)', $message = '', $aImagesToEmbed = [], $aFilesToAttach = [])
 {
     $mail = new \PHPMailer();
     $mail->CharSet = 'UTF-8';
     $mail->isMail();
     if (HelperConfig::$core['mail_method'] == 'sendmail') {
         $mail->isSendmail();
     } elseif (HelperConfig::$core['mail_method'] == 'smtp') {
         $mail->isSMTP();
         $mail->Host = HelperConfig::$secrets['mail_smtp_server'];
         $mail->Port = HelperConfig::$secrets['mail_smtp_port'];
         if (HelperConfig::$secrets['mail_smtp_auth'] == true) {
             $mail->SMTPAuth = true;
             $mail->Username = HelperConfig::$secrets['mail_smtp_auth_user'];
             $mail->Password = HelperConfig::$secrets['mail_smtp_auth_pwd'];
             if (HelperConfig::$secrets['mail_smtp_secure']) {
                 $mail->SMTPSecure = 'tls';
                 if (HelperConfig::$secrets['mail_smtp_secure_method'] == 'ssl') {
                     $mail->SMTPSecure = 'ssl';
                 }
             }
         }
     }
     $mail->From = HelperConfig::$core["email_sender"];
     $mail->FromName = HelperConfig::$core["email_sendername"];
     $mail->addAddress($to);
     $mail->isHTML(true);
     $mail->Subject = $subject;
     $mail->Body = $message;
     if (is_array($aImagesToEmbed) && count($aImagesToEmbed)) {
         foreach ($aImagesToEmbed as $sKey => $imgdata) {
             $imginfo = getimagesizefromstring($imgdata['binimg']);
             $mail->addStringEmbeddedImage($imgdata['binimg'], $sKey, $sKey, 'base64', $imginfo['mime']);
         }
     }
     if (is_array($aFilesToAttach) && count($aFilesToAttach)) {
         foreach ($aFilesToAttach as $sValue) {
             if (file_exists($sValue)) {
                 $mail->addAttachment($sValue);
             }
         }
     }
     //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
     return $mail->send();
 }
Esempio n. 18
0
 public function send()
 {
     //Create a new PHPMailer instance
     $mail = new \PHPMailer();
     // Set PHPMailer to use the sendmail transport
     $mail->isSendmail();
     //кодировка сайта
     $mail->CharSet = 'utf-8';
     //Set who the message is to be sent from
     $mail->setFrom('*****@*****.**', 'First Last');
     //Set who the message is to be sent to
     $mail->addAddress('*****@*****.**', 'Имя кому отправляется письмо');
     //Set the subject line
     $mail->Subject = 'Тема письма';
     //$mail->Body    = 'Текст письма';// - использовать, если нет $mail->msgHTML();
     $mail->msgHTML(file_get_contents('Views/mail/contents.html'), dirname(__FILE__));
     return $mail->send();
 }
Esempio n. 19
0
function send_mail($xss_record_json)
{
    $subject = "GET:" . count($xss_record_json['get_data']) . "个 POST:" . count($xss_record_json['post_data']) . "个 Cookie:" . count($xss_record_json['cookie_data']) . "个";
    $body = json_encode($xss_record_json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
    $body = str_replace("\n", "<br/>", $body);
    $body = str_replace(" ", "&nbsp;", $body);
    $mail = new PHPMailer();
    //实例化
    $mail->isSendmail();
    $mail->IsSMTP();
    // 启用SMTP
    $mail->Host = SMTP_SERVER;
    //SMTP服务器
    $mail->Port = SMTP_PORT;
    //邮件发送端口
    $mail->SMTPAuth = true;
    //启用SMTP认证
    $mail->SMTPSecure = SMTP_SECURE;
    $mail->CharSet = "UTF-8";
    //字符集
    $mail->Encoding = "base64";
    //编码方式
    $mail->Username = MAIL_USER;
    //你的邮箱
    $mail->Password = MAIL_PASS;
    //你的密码
    $mail->Subject = $subject;
    //邮件标题
    $mail->From = MAIL_FROM;
    //发件人地址(也就是你的邮箱)
    $mail->FromName = "通知";
    //发件人姓名
    $mail->AddAddress(MAIL_RECV);
    //添加收件人(地址,昵称)
    $mail->IsHTML(true);
    //支持html格式内容
    $mail->Body = $body;
    $mail->Send();
}
Esempio n. 20
0
if (isset($_POST["smtp"]) && $_POST["smtp"] == "on") {
    $mail->isSMTP();
    $mail->SMTPDebug = 0;
    //Set the hostname of the mail server
    $mail->Host = $_POST["smtp_server"];
    $mail->Port = $_POST["smtp_port"];
    if ($_POST["ssl"] != "on") {
        $mail->SMTPSecure = 'tls';
    } else {
        $mail->SMTPSecure = 'ssl';
    }
    $mail->SMTPAuth = true;
    $mail->Username = $_POST["smtp_user"];
    $mail->Password = $_POST["smtp_pass"];
} else {
    $mail->isSendmail();
}
?>
<html>
<head><title>PHP-SMTP Mailer</title>
<style>body,html{width:100%;padding:0;margin:0}html{overflow:scroll;min-height:100%;background:radial-gradient(#ccc,#54958A,#2C3A4E)}
.topBar{width:75%;color:#fafafa;background:rgba(0,0,0,.75);padding:15px;overflow:hidden;margin:0 auto;border-bottom-right-radius:150px;border-bottom-left-radius:150px;box-shadow:0 0 15px rgba(0,0,0,.75),0 0 15px rgba(0,0,0,.75);text-shadow:-1px 2px 3px rgba(255,255,255,.75);font-family:Audiowide,cursive;font-size:35px;text-align:center;font-weight:700}form{width:500px;margin:10% auto 0;background:rgba(0,0,0,.75);padding:15px;border-radius:15px;box-shadow:0 0 15px rgba(0,0,0,.75),0 0 15px rgba(0,0,0,.75);font-family:Play}form>fieldset>label,form>label{display:inline-block;width:40%;color:#fff;font-weight:700}form>input,fieldset>input{display:inline-block;width:40%;width:150px;margin-right:10px;background:rgba(0,0,0,.3);outline:0;padding:4px;font-size:13px;color:#fff;text-shadow:1px 1px 1px rgba(0,0,0,.3);border:1px solid rgba(0,0,0,.3);border-radius:4px;box-shadow:inset 0 -5px 45px rgba(100,100,100,.2),0 1px 1px rgba(255,255,255,.2);-webkit-transition:box-shadow .5s ease;-moz-transition:box-shadow .5s ease;-o-transition:box-shadow .5s ease;-ms-transition:box-shadow .5s ease;transition:box-shadow .5s ease}button{background-image:linear-gradient(to bottom,#f5f5f5,#aaa);padding:15px;border:0;border-radius:15px;color:rgba(78,154,0,.5);text-shadow:0 .02em .08em #ccc,0 0 0 #000,0 .02em .02em #fff;font-family:Audiowide;font-weight:700;font-size:22px;text-align:center;display:block;margin:10px auto 0}</style>
<link href="http://fonts.googleapis.com/css?family=Play|Audiowide" rel="stylesheet" type="text/css">
</head>
	<body><script>
	function senden(){if(text!=null){document.getElementById('text').value = ace.edit('mailtext').getSession().getValue();document.forms["myform"].submit();}}</script>
	<h2 class="topBar">Mail senden</h2>
		<form name="myform" action="" method="post" onsubmit="event.preventDefault();senden();">

			<label for="from">Absender Mail</label><input id="from" type="text" name="from"><br/>
			<label for="subject">Betreff</label><input id="subject" type="text" name="subject"><br>
Esempio n. 21
0
/** mailer - function to send mails to users 
 *  @arg $from - a string email address, or an array in array(email_address, name format)
 *  @arg $to - either a string of comma delimited email addresses, or an array of addresses in email_address => name format
 *  @arg $cc - either a string of comma delimited email addresses, or an array of addresses in email_address => name format
 *  @arg $bcc - either a string of comma delimited email addresses, or an array of addresses in email_address => name format
 *  @arg $replyto - a string email address, or an array in array(email_address, name format)
 *  @arg $subject - the email subject
 *  @arg $body - the email body, in HTML format.  If content_text is not set, the function will attempt to extract
 *       from the HTML format.
 *  @arg $body_text - the email body in TEXT format.  If set, it will override the stripping tags method
 *  @arg $attachments - the emails attachments as an array
 *  @arg $headers - an array of name value pairs representing custom headers.
 *  @arg $html - if set to true, html is the default, otherwise text format will be used
 */
function mailer($from, $to, $cc, $bcc, $replyto, $subject, $body, $body_text = '', $attachments, $headers, $html = true)
{
    global $config;
    include_once $config['base_path'] . '/lib/PHPMailer/PHPMailerAutoload.php';
    // Set the to informaiotn
    if ($to == '') {
        return 'Mailer Error: No <b>TO</b> address set!!<br>If using the <i>Test Mail</i> link, please set the <b>Alert e-mail</b> setting.';
    }
    if (is_array($to)) {
        $toText = $to[1] . ' <' . $to[0] . '>';
    } else {
        $toText = $to;
    }
    if (is_array($from)) {
        $fromText = $from[1] . ' <' . $from[0] . '>';
    } else {
        $fromText = $from;
    }
    $body = str_replace('<SUBJECT>', $subject, $body);
    $body = str_replace('<TO>', $toText, $body);
    $body = str_replace('<FROM>', $fromText, $body);
    // Create the PHPMailer instance
    $mail = new PHPMailer();
    // Set a reasonable timeout of 5 seconds
    $timeout = read_config_option('settings_smtp_timeout');
    if (empty($timeout) || $timeout < 0 || $timeout > 300) {
        $mail->Timeout = 5;
    } else {
        $mail->Timeout = $timeout;
    }
    // Set the subject
    $mail->Subject = $subject;
    $how = read_config_option('settings_how');
    if ($how < 0 || $how > 2) {
        $how = 0;
    }
    if ($how == 0) {
        $mail->isMail();
    } else {
        if ($how == 1) {
            $mail->Sendmail = read_config_option('settings_sendmail_path');
            $mail->isSendmail();
        } else {
            if ($how == 2) {
                $mail->isSMTP();
                $mail->Host = read_config_option('settings_smtp_host');
                $mail->Port = read_config_option('settings_smtp_port');
                $mail->Username = read_config_option('settings_smtp_username');
                $mail->Password = read_config_option('settings_smtp_password');
                if ($mail->Username != '') {
                    $mail->SMTPAuth = true;
                }
                // Set a reasonable timeout of 5 seconds
                $timeout = read_config_option('settings_smtp_timeout');
                if (empty($timeout) || $timeout < 0 || $timeout > 300) {
                    $mail->Timeout = 5;
                } else {
                    $mail->Timeout = $timeout;
                }
                $secure = read_config_option('settings_smtp_secure');
                if (!empty($secure) && $secure != 'none') {
                    $smtp->SMTPSecure = $secure;
                    if (substr_count($mail->Host, ':') == 0) {
                        $mail->Host = $secure . '://' . $mail->Host;
                    }
                }
            }
        }
    }
    // Set the from information
    if (!is_array($from)) {
        $fromname = '';
        if ($from == '') {
            $from = read_config_option('settings_from_email');
            $fromname = read_config_option('settings_from_name');
            if (isset($_SERVER['HOSTNAME'])) {
                $from = 'Cacti@' . $_SERVER['HOSTNAME'];
            } else {
                $from = '*****@*****.**';
            }
            if ($fromname == '') {
                $fromname = 'Cacti';
            }
        }
        $mail->setFrom($from, $fromname);
    } else {
        $mail->setFrom($from[0], $from[1]);
    }
    if (!is_array($to)) {
        $to = explode(',', $to);
        foreach ($to as $t) {
            $t = trim($t);
            if ($t != '') {
                $mail->addAddress($t);
            }
        }
    } else {
        foreach ($to as $email => $name) {
            $mail->addAddress($email, $name);
        }
    }
    if (!is_array($cc)) {
        if ($cc != '') {
            $cc = explode(',', $cc);
            foreach ($cc as $c) {
                $c = trim($c);
                $mail->addCC($c);
            }
        }
    } else {
        foreach ($cc as $email => $name) {
            $mail->addCC($email, $name);
        }
    }
    if (!is_array($bcc)) {
        if ($bcc != '') {
            $bcc = explode(',', $bcc);
            foreach ($bcc as $bc) {
                $bc = trim($bc);
                $mail->addBCC($bc);
            }
        }
    } else {
        foreach ($bcc as $email => $name) {
            $mail->addBCC($email, $name);
        }
    }
    if (!is_array($replyto)) {
        if ($replyto != '') {
            $mail->replyTo($replyto);
        }
    } else {
        $mail->replyTo($replyto[0], $replyto[1]);
    }
    // Set the wordwrap limits
    $wordwrap = read_config_option('settings_wordwrap');
    if ($wordwrap == '') {
        $wordwrap = 76;
    }
    if ($wordwrap > 9999) {
        $wordwrap = 9999;
    }
    if ($wordwrap < 0) {
        $wordwrap = 76;
    }
    $mail->WordWrap = $wordwrap;
    $mail->setWordWrap();
    $i = 0;
    // Handle Graph Attachments
    if (is_array($attachments) && sizeof($attachments) && substr_count($body, '<GRAPH>') > 0) {
        foreach ($attachments as $val) {
            $graph_data_array = array('output_flag' => RRDTOOL_OUTPUT_STDOUT);
            $data = rrdtool_function_graph($val['local_graph_id'], $val['rra_id'], $graph_data_array);
            if ($data != '') {
                /* get content id and create attachment */
                $cid = getmypid() . '_' . $i . '@' . 'localhost';
                /* attempt to attach */
                if ($mail->addStringEmbededImage($data, $cid, $val['filename'] . '.png', 'base64', 'image/png', 'inline') === false) {
                    cacti_log('ERROR: ' . $mail->ErrorInfo, false);
                    return $mail->ErrorInfo;
                }
                $body = str_replace('<GRAPH>', "<br><br><img src='cid:{$cid}'>", $body);
            } else {
                $body = str_replace('<GRAPH>', "<br><img src='" . $val['file'] . "'><br>Could not open!<br>" . $val['file'], $body);
            }
            $i++;
        }
    } elseif (is_array($attachments) && sizeof($attachments) && substr_count($body, '<GRAPH:') > 0) {
        foreach ($attachments as $attachment) {
            if ($attachment['attachment'] != '') {
                /* get content id and create attachment */
                $cid = getmypid() . '_' . $i . '@' . 'localhost';
                /* attempt to attach */
                if ($mail->addStringEmbeddedImage($attachment['attachment'], $cid, $attachment['filename'], 'base64', $attachment['mime_type'], $attachment['inline']) === false) {
                    cacti_log('ERROR: ' . $mail->ErrorInfo, false);
                    return $mail->ErrorInfo;
                }
                /* handle the body text */
                switch ($attachment['inline']) {
                    case 'inline':
                        $body = str_replace('<GRAPH:' . $attachment['graphid'] . ':' . $attachment['timespan'] . '>', "<img border='0' src='cid:{$cid}' >", $body);
                        break;
                    case 'attachment':
                        $body = str_replace('<GRAPH:' . $attachment['graphid'] . ':' . $attachment['timespan'] . '>', '', $body);
                        break;
                }
            } else {
                $body = str_replace('<GRAPH:' . $attachment['graphid'] . ':' . $attachment['timespan'] . '>', "<img border='0' src='" . $attachment['filename'] . "' ><br>Could not open!<br>" . $attachment['filename'], $body);
            }
            $i++;
        }
    }
    /* process custom headers */
    if (is_array($headers) && sizeof($headers)) {
        foreach ($headers as $name => $value) {
            $mail->addCustomHeader($name, $value);
        }
    }
    // Set both html and non-html bodies
    $text = array('text' => '', 'html' => '');
    if ($body_text != '' && $html == true) {
        $text['html'] = $body . '<br>';
        $text['text'] = $body_text;
        $mail->isHTML(true);
        $mail->Body = $text['html'];
        $mail->AltBody = $text['text'];
    } elseif ($attachments == '' && $html == false) {
        if ($body_text != '') {
            $body = $body_text;
        } else {
            $body = str_replace('<br>', "\n", $body);
            $body = str_replace('<BR>', "\n", $body);
            $body = str_replace('</BR>', "\n", $body);
        }
        $text['text'] = strip_tags($body);
        $mail->isHTML(false);
        $mail->Body = $text['text'];
        $mail->AltBody = $text['text'];
    } else {
        $text['html'] = $body . '<br>';
        $text['text'] = strip_tags(str_replace('<br>', "\n", $body));
        $mail->isHTML(true);
        $mail->Body = $text['html'];
        $mail->AltBody = $text['text'];
    }
    if ($mail->send()) {
        return '';
    } else {
        return $mail->ErrorInfo;
    }
}
Esempio n. 22
0
    /**
     * Send an email using a Transactional email service
     * or native PHP as a fallback.
     *
     * @param array  $attributes  A list of attributes for sending
     * @return bool on success
     */
    public static function send($attributes = array())
    {
        /*
        |--------------------------------------------------------------------------
        | Required attributes
        |--------------------------------------------------------------------------
        |
        | We first need to ensure we have the minimum fields necessary to send
        | an email.
        |
        */
        $required = array_intersect_key($attributes, array_flip(self::$required));

        if (count($required) >= 3) {

            /*
            |--------------------------------------------------------------------------
            | Load handler from config
            |--------------------------------------------------------------------------
            |
            | We check the passed data for a mailer + key first, and then fall back
            | to the global Statamic config.
            |
            */
            $email_handler     = array_get($attributes, 'email_handler', Config::get('email_handler', null));
            $email_handler_key = array_get($attributes, 'email_handler_key', Config::get('email_handler_key', null));

            if (in_array($email_handler, self::$email_handlers) && $email_handler_key) {

                /*
                |--------------------------------------------------------------------------
                | Initialize Stampie
                |--------------------------------------------------------------------------
                |
                | Stampie provides numerous adapters for popular email handlers, such as
                | Mandrill, Postmark, and SendGrid. Each is written as an abstract
                | interface in an Adapter Pattern.
                |
                */
                $mailer = self::initializeEmailHandler($email_handler, $email_handler_key);

                /*
                |--------------------------------------------------------------------------
                | Initialize Message class
                |--------------------------------------------------------------------------
                |
                | The message class is an implementation of the Stampie MessageInterface
                |
                */
                $email = new Message($attributes['to']);

                /*
                |--------------------------------------------------------------------------
                | Set email attributes
                |--------------------------------------------------------------------------
                |
                | I hardly think this requires much explanation.
                |
                */
                $email->setFrom($attributes['from']);

                $email->setSubject($attributes['subject']);

                if (isset($attributes['text'])) {
                    $email->setText($attributes['text']);
                }

                if (isset($attributes['html'])) {
                    $email->setHtml($attributes['html']);
                }

                if (isset($attributes['cc'])) {
                    $email->setCc($attributes['cc']);
                }

                if (isset($attributes['bcc'])) {
                    $email->setBcc($attributes['bcc']);
                }

                if (isset($attributes['headers'])) {
                    $email->setHeaders($attributes['headers']);
                }

                $mailer->send($email);

                return true;

            } else {

                /*
                |--------------------------------------------------------------------------
                | Native PHP Mail
                |--------------------------------------------------------------------------
                |
                | We're utilizing the popular PHPMailer class to handle the messy
                | email headers and do-dads. Emailing from PHP in general isn't the best
                | idea known to man, so this is really a lackluster fallback.
                |
                */
            try {
                $email = new PHPMailer(true);

                // SMTP
                if ($attributes['smtp'] = array_get($attributes, 'smtp', Config::get('smtp'))) {
                    
                    $email->isSMTP();

                    if ($smtp_host = array_get($attributes, 'smtp:host', false)) {
                        $email->Host = $smtp_host;
                    }

                    if ($smtp_secure = array_get($attributes, 'smtp:secure', false)) {
                        $email->SMTPSecure = $smtp_secure;
                    }

                    if ($smtp_port = array_get($attributes, 'smtp:port', false)) {
                        $email->Port = $smtp_port;
                    }

                    if (array_get($attributes, 'smtp:auth', false) === TRUE) {
                        $email->SMTPAuth = TRUE;
                    }

                    if ($smtp_username = array_get($attributes, 'smtp:username', false)) {
                        $email->Username = $smtp_username;
                    }

                    if ($smtp_password = array_get($attributes, 'smtp:password', false)) {
                        $email->Password = $smtp_password;
                    }

                // SENDMAIL
                } elseif (array_get($attributes, 'sendmail', false)) {
                    $email->isSendmail();

                // PHP MAIL
                } else {
                    $email->isMail();
                }

                $email->CharSet = 'UTF-8';

                $from_parts = self::explodeEmailString($attributes['from']);
                $email->setFrom($from_parts['email'], $from_parts['name']);

                $to = Helper::ensureArray($attributes['to']);
                foreach ($to as $to_addr) {
                    $to_parts = self::explodeEmailString($to_addr);
                    $email->addAddress($to_parts['email'], $to_parts['name']);
                }

                $email->Subject  = $attributes['subject'];

                if (isset($attributes['html'])) {
                    $email->msgHTML($attributes['html']);

                    if (isset($attributes['text'])) {
                        $email->AltBody = $attributes['text'];
                    }

                } elseif (isset($attributes['text'])) {
                    $email->msgHTML($attributes['text']);
                }

                if (isset($attributes['cc'])) {
                    $cc = Helper::ensureArray($attributes['cc']);
                    foreach ($cc as $cc_addr) {
                        $cc_parts = self::explodeEmailString($cc_addr);
                        $email->addCC($cc_parts['email'], $cc_parts['name']);
                    }                    
                }

                if (isset($attributes['bcc'])) {
                    $bcc = Helper::ensureArray($attributes['bcc']);
                    foreach ($bcc as $bcc_addr) {
                        $bcc_parts = self::explodeEmailString($bcc_addr);
                        $email->addBCC($bcc_parts['email'], $bcc_parts['name']);
                    }      
                }

                $email->send();

                } catch (phpmailerException $e) {
                    echo $e->errorMessage(); //error messages from PHPMailer
                    Log::error($e->errorMessage(), 'core', 'email');
                } catch (Exception $e) {
                    echo $e->getMessage();
                    Log::error($e->getMessage(), 'core', 'email');
                }

            }
        }

        return false;
    }
 /**
  * Send the notification.
  *
  * This method sends the notification to all recipients, rendering the template with the corresponding parameters for each recipient.
  * @throws phpmailerException The message could not be sent.
  */
 public function send()
 {
     $mail = new \PHPMailer(true);
     $mail->From = $this->from_email;
     $mail->FromName = $this->from_name;
     $mail->addReplyTo($this->reply_to_email, $this->reply_to_name);
     $twig = static::$app->view()->getEnvironment();
     // Loop through email recipients, sending customized content to each one
     foreach ($this->email_recipients as $recipient) {
         $mail->addAddress($recipient->getEmail(), $recipient->getName());
         // Add any CCs and BCCs
         if ($recipient->getCCs()) {
             foreach ($recipient->getCCs() as $cc) {
                 $mail->addCC($cc['email'], $cc['name']);
             }
         }
         if ($recipient->getBCCs()) {
             foreach ($recipient->getBCCs() as $bcc) {
                 $mail->addBCC($bcc['email'], $bcc['name']);
             }
         }
         $params = $recipient->getParams();
         // Must manually merge in global variables for block rendering
         $params = array_merge($twig->getGlobals(), $params);
         $mail->Subject = $this->template->renderBlock('subject', $params);
         $mail->Body = $this->template->renderBlock('body', $params);
         $mail->isHTML(true);
         // Set email format to HTML
         // Send mail as SMTP, if desired
         if (static::$app->config('mail') == 'smtp') {
             $config = static::$app->config('smtp');
             $mail->isSMTP(true);
             $mail->Host = $config['host'];
             $mail->Port = $config['port'];
             $mail->SMTPAuth = $config['auth'];
             $mail->SMTPSecure = $config['secure'];
             $mail->Username = $config['user'];
             $mail->Password = $config['pass'];
         }
         // Send mail as sendmail, if desired
         if (static::$app->config('mail') == 'sendmail') {
             $config = static::$app->config('sendmail');
             $mail->isSendmail(true);
         }
         // Try to send the mail.  Will throw an exception on failure.
         $mail->send();
         // Clear all PHPMailer recipients (from the message for this iteration)
         $mail->clearAllRecipients();
     }
 }
Esempio n. 24
0
function create_event()
{
    if ($_POST['submit']) {
        $user_name = $_POST['user_name'];
        $user_email = $_POST['user_email'];
        $event_title = str_replace('\\"', '"', $_POST['event_title']);
        if ($_POST['showcase_day'] != '') {
            $showcase_day = $_POST['showcase_day'];
        } else {
            $showcase_day = 'today';
        }
        //echo 'SHOWCASE DAY: '.$showcase_day;
        $showcase_day = strtotime($showcase_day);
        $showcase_day = date("Y-m-d", $showcase_day);
        $submission_date = $_POST['submission_date'];
        $description = $_POST['description'];
        $type = $_POST['type_of_event'];
        include '../../../inc/connection.php';
        // Insert into database
        $sql = "INSERT INTO schedule (user_name, event_title, showcase_day, type, description) VALUES ('{$user_name}','{$event_title}','{$showcase_day}', '{$type}', '{$description}')";
        if (mysqli_query($con, $sql)) {
            $email_subject = '[EVENT] ' . $user_name . ' - "' . $event_title . '" was Received!';
            $email_body = 'Thank you for submitting your music to FREELABEL Studios! We are a collective of producers, designers, and musicians dedicated to producing the highest quality exclusive platform to launch new brands to an audience averaging at <u>8.2+ Million Impressions each month.</u> You will be the branded product behind the impression we make to the world.<br><br>You will need to complete your registration by creating your account at http://freelabel.net/submit/ to get booked on any of the upcoming projects, publications, interviews, & radio showcases on the FREELABEL Radio, Magazine, & TV Network. Feel free to give us a call or email if you have any questions.';
            $email_body = 'Your Event has been submitted and will be reviewed for approval. If you have any questions regarding the status of your event, feel free to contact us at 347-994-0267<BR><BR> Thank you!';
            $body_template = '					<head>
											<style>
															html{
																width:100%;
															}
																body {
																	//background-image:url("' . $uploaded_file_path_http . '");
																	background-size:auto 100%;
																	background-position:center center;
																	background-color:#FE3F44;
																	color:#e3e3e3;
																	padding:0%;
																	margin:0%;
																	text-align:center;
																}
																#para_text {
																margin:1% auto;
																padding:1% 2%;
																font-size:100%;
															}
															#submission_info {
																background-color:#e3e3e3;
																color:#000000;
																width:90%;
																margin:auto;
																padding:2%;
																border-radius:10px;
															}
															#submission_info table, #submission_info tr,#submission_info td {
																margin:auto;
																color:#000;
															}
															a {
																//color:#FE3F44;
																color:#303030;
															}
															#email_photo {
															max-width:500px;
															margin:1% 0 3% 0;
															box-shadow:0px 0px 5px #303030;
														}
														#signature_block {
														margin: 4% auto;
														font-size:80%;

													}
												</style>
												</head>
												<body>
													<img style="width:250px" src="http://freelabel.net/images/FREELABELLOGO.gif"><br>
													<img style="width:250px" src="http://freelabel.net/images/flheadblack.png"><br>

													<div id="para_text">
														<h1>' . $email_subject . '</h1>

														' . $email_body . "\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<hr>\n\t\t\t\t\t\t\t\t\t\t\t\t" . '<h2>EVENT DETAILS:</h2>
														<div id="submission_info">
															<table>
																<tr>
																	<td>TITLE:</td>
																	<td>' . $event_title . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>DATE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $showcase_day . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>TYPE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $type . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>DESCRIPTION:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $description . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>EMAIL:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $user_email . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id='signature_block'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<u>FREELABEL ADMIN</u>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>c: (347) 994-0267<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\te: info@FREELABEL.net\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\nFREELABEL.net\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</body>";
            $stafflist = array($user_email);
            //foreach ($stafflist as $admin) {
            include '../../../mailer/PHPMailerAutoload.php';
            //Create a new PHPMailer instance
            $mail = new PHPMailer();
            // Set PHPMailer to use the sendmail transport
            $mail->isSendmail();
            //Set who the message is to be sent from
            $mail->setFrom('*****@*****.**', 'FREELABEL Studios');
            //Set an alternative reply-to address
            $mail->addReplyTo('*****@*****.**', 'FREELABEL Studios');
            //Set the subject line
            $mail->Subject = $email_subject;
            //Read an HTML message body from an external file, convert referenced images to embedded,
            //convert HTML into a basic plain-text alternative body
            $mail->msgHTML($body_template);
            //Replace the plain text body with one created manually
            $mail->AltBody = $body_template;
            //Attach an image file
            //$mail->addAttachment('images/phpmailer_mini.png');
            //send the message, check for errors
            //foreach ($stafflist as $admin) { //This iterator syntax only works in PHP 5.4+
            $admin = "*****@*****.**";
            $mail->addAddress($admin, 'FREELABEL BOOKING');
            if (!empty($row['photo'])) {
                $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
                //Assumes the image data is stored in the DB
            }
            if (!$mail->send()) {
                echo "Mailer Error (" . str_replace("@", "&#64;", $admin) . ') ' . $mail->ErrorInfo . '<br />';
                break;
                //Abandon sending
            } else {
                echo "Message sent to: " . $admin . "!<br>";
                //echo "<br><br><br><br>".$body_template.'<br><br>';
                //echo "Message sent to :" . $admin . ' (' . str_replace("@", "&#64;", $admin) . ')<br />';
            }
            // Clear all addresses and attachments for next loop
            $mail->clearAddresses();
            $mail->clearAttachments();
            //} // foreach END
            // end of sending email
            /*echo '<style>
            		html {
            		color:#fff;
            		background-color:#303030;
            		margin:10%;
            		font-size:300%;
            		font-family:sans-serif;
            		}
            		</style>';*/
            echo "Your Event has been submitted and will be reviewed for confirmation. Please stay updated!<br><br>Your Requested Event: <p id='sub_label' >" . $event_title . '<br>On a ';
            //echo $showcase_day."</p><a href='http://freelabel.net/submit/'>Return to Dashboard</a><br><br><br><br><br><br>";
            //echo '<script>
            //		window.location.assign("http://freelabel.net/?ctrl=booking");
            //	</script>';
            exit;
        } else {
            echo "Error creating database entry: " . mysqli_error($con);
        }
    }
}
 protected function do_entry_email_tech_support()
 {
     //get params
     //from
     $employeeId = trim($_REQUEST['employeeid']);
     $employeeEmail = trim($_REQUEST['employeeemail']);
     $employeeName = trim($_REQUEST['name']);
     //to
     $schedulerEmail = trim($_REQUEST['scheduleremail']);
     //msg
     $subject = trim($_REQUEST['subject']);
     $message = trim($_REQUEST['message']);
     //sanity check -> LISTS
     if (!strlen($employeeId) or !strlen($employeeEmail) or !strlen($employeeName) or !strlen($schedulerEmail) or !strlen($subject) or !strlen($message)) {
         //fmt reply 400
         $reply['statuscode'] = HTTP_BAD_REQUEST;
         $reply['message'] = "Invalid parameters!";
         //give it back
         $this->send_reply($reply);
         return;
     }
     //chk-params
     if (!$this->is_valid_email($employeeEmail) or !$this->is_valid_email($schedulerEmail)) {
         //fmt reply 417
         $reply['statuscode'] = HTTP_EXPECTATION_FAILED;
         $reply['message'] = "Invalid parameters [Email format]!";
         //give it back
         $this->send_reply($reply);
         return;
     }
     //get params
     $fromName = sprintf("%s / %s", $employeeName, $employeeId);
     $employeeId = trim($_REQUEST['employeeid']);
     $employeeEmail = trim($_REQUEST['employeeemail']);
     $employeeName = trim($_REQUEST['name']);
     //to
     $schedulerEmail = trim($_REQUEST['scheduleremail']);
     //msg
     $subject = trim($_REQUEST['subject']);
     $message = trim($_REQUEST['message']);
     //email-obj
     $mail = new PHPMailer();
     $mail->isSendmail();
     //FROM
     $mail->setFrom($employeeEmail, $fromName);
     //REPLY-TO
     $mail->addReplyTo($employeeEmail, $fromName);
     //TO
     $mail->addAddress($schedulerEmail, $schedulerEmail);
     //SUBJECT
     $mail->Subject = sprintf("%s", $subject);
     //MESSAGE
     $mail->msgHTML($message);
     //MESSAGE-alt
     $mail->AltBody = "{$message}";
     //failed
     if (!$mail->send()) {
         //chk
         $dmp = @var_export($mail->ErrorInfo, 1);
         debug("EMAIl-SEND-FAILED> {$dmp}");
         //fmt reply 409
         $reply['statuscode'] = HTTP_CONFLICT;
         $reply['message'] = "Email Tech Support sent failed! [{$dmp}]";
         //give it back
         $this->send_reply($reply);
         return;
     }
     //fmt reply 200
     $reply['status'] = true;
     $reply['statuscode'] = HTTP_SUCCESS;
     $reply['message'] = "Email Tech Support sent successful!";
     $reply['uuid'] = md5($this->str_enc(sprintf("%s-%s", mt_rand(), uniqid(true))));
     $this->send_reply($reply);
 }
Esempio n. 26
0
         fputcsv($csvFileData, $csvData);
     } else {
         $csvFileData = fopen($csvFile, 'a');
         $headerRowFields = array("Guest Name", "Email Address", "Subject");
         fputcsv($csvFileData, $headerRowFields);
         fputcsv($csvFileData, $csvData);
     }
     fclose($csvFileData);
 }
 /*	---------------------------------------------------------------------
 			: Send the auto responder message if its true
 			--------------------------------------------------------------------- */
 if ($autoResponder == true) {
     include dirname(__FILE__) . '/templates/autoresponder.php';
     $automail = new PHPMailer();
     $automail->isSendmail();
     $automail->From = '*****@*****.**';
     $automail->FromName = 'The Gear Safe';
     $automail->isHTML(true);
     $automail->CharSet = "UTF-8";
     $automail->Encoding = "base64";
     $automail->Timeout = 200;
     $automail->ContentType = "text/html";
     $automail->AddAddress($emailaddress, $sendername);
     $automail->Subject = "Thank you for contacting us";
     $automail->Body = $automessage;
     $automail->AltBody = "Use an HTML compatible email client";
     $automail->Send();
 }
 if ($redirectForm == true) {
     echo '<script>setTimeout(function () { window.location.replace("' . $redirectForm_url . '") }, 8000); </script>';
Esempio n. 27
0
 function sendmail()
 {
     global $CHARSET, $system;
     $this->errors = array();
     // from has not been set send email via admin
     if (!isset($this->from) || empty($this->from)) {
         $this->from = $system->SETTINGS['adminmail'];
     }
     // if sending to admin, send to all linked admin emails
     if ($system->SETTINGS['adminmail'] == $this->to) {
         $emails = array_filter(explode(',', $system->SETTINGS['alert_emails']));
         if (!empty($emails)) {
             if (!is_array($this->to)) {
                 $to_start = $this->to;
                 $this->to = array();
                 $this->to[] = $to_start;
             }
             foreach ($emails as $email) {
                 if (strlen($email) > 0 && preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $email)) {
                     $this->to[] = $email;
                 }
             }
         }
     }
     // deal with sending the emails
     switch ($system->SETTINGS['mail_protocol']) {
         case '5':
             $mail = new PHPMailer(true);
             $mail->isQmail();
             break;
         case '4':
             $mail = new PHPMailer(true);
             $mail->isSendmail();
             break;
         case '3':
             // do not send email
             return 'No email sent. You have selected to disable all emails';
             break;
         case '2':
             $mail = new PHPMailer(true);
             $mail->isSMTP();
             $mail->SMTPDebug = 0;
             $mail->Debugoutput = 'html';
             $mail->Host = $system->SETTINGS['smtp_host'];
             $mail->Port = (int) $system->SETTINGS['smtp_port'];
             if ($system->SETTINGS['smtp_security'] != 'none') {
                 $mail->SMTPSecure = strtolower($system->SETTINGS['smtp_security']);
             }
             if ($system->SETTINGS['smtp_authentication'] == 'y') {
                 $mail->SMTPAuth = true;
                 $mail->Username = $system->SETTINGS['smtp_username'];
                 $mail->Password = $system->SETTINGS['smtp_password'];
             } else {
                 $mail->SMTPAuth = false;
             }
             break;
         case '1':
             $mail = new PHPMailer(true);
             $mail->isMail();
             break;
         default:
             // just use php mail function
             if (is_array($this->to)) {
                 for ($i = 0; $i < count($this->to); $i++) {
                     if (!empty($system->SETTINGS['mail_parameter'])) {
                         $sent = mail($this->to[$i], $this->subject, $this->message, $this->headers, $system->SETTINGS['mail_parameter']);
                     } else {
                         $sent = mail($this->to[$i], $this->subject, $this->message, $this->headers);
                     }
                 }
             } else {
                 if (!empty($system->SETTINGS['mail_parameter'])) {
                     $sent = mail($this->to, $this->subject, $this->message, $this->headers, $system->SETTINGS['mail_parameter']);
                 } else {
                     $sent = mail($this->to, $this->subject, $this->message, $this->headers);
                 }
             }
             if ($sent) {
                 return false;
             } else {
                 return true;
             }
             break;
     }
     if (is_array($this->to)) {
         for ($i = 0; $i < count($this->to); $i++) {
             try {
                 $mail->setFrom($this->from, $system->SETTINGS['adminmail']);
                 $mail->addAddress($this->to[$i]);
                 $mail->addReplyTo($this->from, $system->SETTINGS['adminmail']);
                 $mail->Subject = $this->subject;
                 $mail->msgHTML($this->message);
                 //$mail->addAttachment('images/phpmailer_mini.png');
                 $mail->CharSet = $CHARSET;
                 $mail->Send();
             } catch (phpmailerException $e) {
                 trigger_error('---->PHPMailer error: ' . $e->errorMessage());
                 $this->add_error($e->errorMessage());
             } catch (Exception $e) {
                 trigger_error('---->PHPMailer error2: ' . $e->getMessage());
                 $this->add_error($e->getMessage());
             }
             $mail->clearAddresses();
         }
     } else {
         try {
             $mail->setFrom($this->from, $system->SETTINGS['adminmail']);
             if (is_array($this->to)) {
                 for ($i = 0; $i < count($this->to); $i++) {
                     $mail->addAddress($this->to[$i]);
                 }
             } else {
                 $mail->addAddress($this->to);
             }
             $mail->addReplyTo($this->from, $system->SETTINGS['adminmail']);
             $mail->Subject = $this->subject;
             $mail->msgHTML($this->message);
             $mail->CharSet = $CHARSET;
             $mail->Send();
         } catch (phpmailerException $e) {
             trigger_error('---->PHPMailer error: ' . $e->errorMessage());
             $this->add_error($e->errorMessage());
         } catch (Exception $e) {
             trigger_error('---->PHPMailer error: ' . $e->getMessage());
             $this->add_error($e->getMessage());
         }
     }
     return implode('<br/>', $this->errors);
 }
Esempio n. 28
0
 public static function sendmail($content, $subject, $to, $from, $to_name, $attachment = '', $from_name = 'Test', $type = 'cc', $bc_arr = array())
 {
     Yii::import("application.extensions.mailer.*", true);
     $mail = new PHPMailer();
     $mail->isSendmail();
     //Config mandrillapp SMTP Port
     $mail->IsSMTP();
     $mail->SMTPDebug = 0;
     // debugging: 1 = errors and messages, 2 = messages only
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = "ssl";
     if (App::isDevDomain()) {
         $mail->Host = "vps1.credencys.com";
         $mail->Port = 465;
         $mail->Username = "******";
         $mail->Password = "******";
     } else {
         $mail->Host = "smtp.gmail.com";
         $mail->Port = 465;
         $mail->Username = "******";
         $mail->Password = "******";
     }
     $mail->setFrom($from, $from_name);
     $mail->addReplyTo($from, $from_name);
     $mail->addAddress($to);
     // Add in to the cc
     if (count($bc_arr) > 0) {
         if ($type == 'cc') {
             foreach ($bc_arr as $k => $v) {
                 $mail->AddCC($v);
             }
         } else {
             foreach ($bc_arr as $k => $v) {
                 $mail->AddBCC($v);
             }
         }
     }
     $mail->Subject = $subject;
     $mail->msgHTML($content, dirname(__FILE__));
     $mail->AltBody = 'This is a plain-text message body';
     if (!empty($attachment)) {
         $mail->addAttachment($attachment);
     }
     if (!$mail->send()) {
         return false;
     } else {
         return true;
     }
 }
Esempio n. 29
0
 /**
  * Saves new data to $this->json_data_file and send email if necessary
  * @access public
  */
 public function saveData()
 {
     $this->saveSettings();
     $mailBody = '';
     if (file_exists($this->jsonData) || !file_exists($this->jsonData) && touch($this->jsonData)) {
         $existingData = file_get_contents($this->jsonData);
         try {
             $existing_data_array = json_decode($existingData, TRUE);
         } catch (Exception $e) {
             $existing_data_array = array();
         }
         foreach ($this->businessInfo as $businessId => $business_data) {
             if (!array_key_exists($businessId, $existing_data_array)) {
                 $existing_data_array[$businessId] = md5(json_encode(end($business_data)));
             } else {
                 if (md5(json_encode(end($business_data))) != $existing_data_array[$businessId]) {
                     $bd_end = end($business_data);
                     $mailBody .= $bd_end['yrityksen_nimi'] . ' (' . $bd_end['y_tunnus'] . ') ' . $bd_end['rekisterointilaji'] . ' ' . $bd_end['rekisterointiajankohta'] . ' ' . $bd_end['rekisteroity_asia'] . PHP_EOL . PHP_EOL;
                     $existing_data_array[$businessId] = md5(json_encode(end($business_data)));
                 }
             }
         }
         $this->companiesNamesToYAML();
         file_put_contents($this->jsonData, json_encode($existing_data_array));
         if (!empty($mailBody) && !empty($this->settings['send_email_to'])) {
             /** @var PHPMailer $mail */
             $mail = new PHPMailer();
             $mail->isSendmail();
             foreach ($this->settings['send_email_to'] as $mail_to) {
                 $mail->addAddress($mail_to);
             }
             $mail->SetFrom($this->settings['mail_from_addr'], $this->settings['mail_from_name']);
             $mail->Subject = utf8_decode('Yhden tai useamman yrityksen tietoja päivitetty virreen');
             $mail->Body = utf8_decode($mailBody);
             if (!$mail->send()) {
                 echo 'Mailer Error: ' . $mail->ErrorInfo;
             } else {
                 echo 'Message sent!';
             }
         }
     }
 }
 /**
  * Miscellaneous calls to improve test coverage and some small tests.
  */
 public function testMiscellaneous()
 {
     $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
     $this->Mail->addCustomHeader('SomeHeader: Some Value');
     $this->Mail->clearCustomHeaders();
     $this->Mail->clearAttachments();
     $this->Mail->isHTML(false);
     $this->Mail->isSMTP();
     $this->Mail->isMail();
     $this->Mail->isSendmail();
     $this->Mail->isQmail();
     $this->Mail->setLanguage('fr');
     $this->Mail->Sender = '';
     $this->Mail->createHeader();
     $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
     $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
     //Test pathinfo
     $a = '/mnt/files/飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
     $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
 }