set() public method

You should avoid this function - it's more verbose, less efficient, more error-prone and harder to debug than setting properties directly. Usage Example: $mail->set('SMTPSecure', 'tls'); is the same as: $mail->SMTPSecure = 'tls';
public set ( string $name, mixed $value = '' ) : boolean
$name string The property name to set
$value mixed The value to set the property to
return boolean
コード例 #1
0
ファイル: Mail.php プロジェクト: friend8/DSA-Blacksmith
 /**
  * Send an email
  *
  * @param array  $recipient The recipient to send the mail to
  *                          Format:
  *                          array(
  *                              '*****@*****.**',
  *                              'test',
  *                          )
  * @param string $subject   The mail subjet
  * @param string $message   The mail message, may be html
  *
  * @return boolean
  */
 public static function send($recipient, $subject, $message)
 {
     $translator = \SmartWork\Translator::getInstance();
     $mailer = new \PHPMailer(true);
     $mailer->set('CharSet', $this->globalConfig->getConfig('charset'));
     $mailer->setFrom($this->globalConfig->getGlobal(array('mail' => 'sender')), $translator->gt('title'));
     $mailer->addAddress($recipient[0], $recipient[1]);
     $mailer->set('Subject', $subject);
     $mailer->set('AltBody', strip_tags($message));
     $mailer->msgHTML($message);
     $mailer->isHTML(true);
     return $mailer->send();
 }
コード例 #2
0
ファイル: Mailer.php プロジェクト: Kit-kat1/custom-bluz-app
 /**
  * Creates new instance of PHPMailer and set default options from config
  * @api
  * @throws ComponentException
  * @throws \phpmailerException
  * @return \PHPMailer
  */
 public function create()
 {
     // can initial, can't use
     if (!class_exists('\\PHPMailer')) {
         throw new ComponentException("PHPMailer library is required for `Bluz\\Mailer` package. <br/>\n" . "Read more: <a href='https://github.com/bluzphp/framework/wiki/Mailer'>" . "https://github.com/bluzphp/framework/wiki/Mailer</a>");
     }
     $mail = new \PHPMailer();
     $mail->WordWrap = 920;
     // RFC 2822 Compliant for Max 998 characters per line
     $fromEmail = $this->getOption('from', 'email');
     $fromName = $this->getOption('from', 'name') ?: '';
     // setup options from config
     $mail->SetFrom($fromEmail, $fromName, false);
     // setup options
     if ($settings = $this->getOption('settings')) {
         foreach ($settings as $name => $value) {
             $mail->set($name, $value);
         }
     }
     // setup custom headers
     if ($headers = $this->getOption('headers')) {
         foreach ($headers as $header => $value) {
             $mail->AddCustomHeader($header, $value);
         }
     }
     return $mail;
 }
コード例 #3
0
 /**
  * Miscellaneous calls to improve test coverage and some small tests
  */
 function test_Miscellaneous()
 {
     $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');
     //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');
 }
コード例 #4
0
ファイル: phpmailerTest.php プロジェクト: jbs321/portfolio
 /**
  * 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;
 }
コード例 #5
0
ファイル: phpmailerTest.php プロジェクト: NurulRizal/BB
 /**
  * Miscellaneous calls to improve test coverage and some small tests
  */
 function test_Miscellaneous()
 {
     $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');
 }
コード例 #6
0
ファイル: lmbMailer.class.php プロジェクト: r-kitaev/limb
 protected function _createMailer()
 {
     $mailer = new PHPMailer(true);
     $mailer->set('LE', "\r\n");
     if ($this->use_phpmail) {
         return $mailer;
     }
     $mailer->IsSMTP();
     $mailer->Host = $this->smtp_host;
     $mailer->Port = $this->smtp_port;
     if ($this->smtp_auth == true) {
         $mailer->SMTPAuth = true;
         $mailer->Username = $this->smtp_user;
         $mailer->Password = $this->smtp_password;
     }
     return $mailer;
 }
コード例 #7
0
ファイル: Mailer.php プロジェクト: bbfriend/advancedform_xh
 /**
  * Determines the addresses of sender and recipients, and returns whether
  * that succeeded.
  *
  * @return bool
  *
  * @global array  The localization of the plugins.
  * @global string The (X)HTML fragment with error messages.
  */
 protected function determineAddresses()
 {
     global $plugin_tx, $e;
     $from = '';
     $from_name = '';
     foreach ($this->form->getFields() as $field) {
         $field = Field::make($field);
         if ($field->getType() == 'from_name') {
             $from_name = stsl($_POST['advfrm-' . $field->getName()]);
         } elseif ($field->getType() == 'from') {
             $from = stsl($_POST['advfrm-' . $field->getName()]);
         }
     }
     if ($this->isConfirmation && empty($from)) {
         $e .= '<li>' . $plugin_tx['advancedform']['error_missing_sender'] . '</li>' . PHP_EOL;
         return false;
     }
     if ($this->isConfirmation) {
         $this->mail->set('From', $this->form->getReceiver());
         $this->mail->set('FromName', $this->form->getReceiverName());
         $this->mail->AddAddress($from, $from_name);
     } else {
         $this->mail->set('From', $from);
         $this->mail->set('FromName', $from_name);
         $this->mail->AddAddress($this->form->getReceiver(), $this->form->getReceiverName());
         foreach (explode(';', $this->form->getCC()) as $cc) {
             if (trim($cc) != '') {
                 $this->mail->AddCC($cc);
             }
         }
         foreach (explode(';', $this->form->getBCC()) as $bcc) {
             if (trim($bcc) != '') {
                 $this->mail->AddBCC($bcc);
             }
         }
     }
     return true;
 }
コード例 #8
0
ファイル: Mailer.php プロジェクト: acp3/core
 /**
  * Initializes PHPMailer and sets the basic configuration parameters
  *
  * @return $this
  */
 private function configure()
 {
     if ($this->phpMailer === null) {
         $this->phpMailer = new \PHPMailer(true);
         $settings = $this->config->getSettings(Schema::MODULE_NAME);
         if (strtolower($settings['mailer_type']) === 'smtp') {
             $this->phpMailer->set('Mailer', 'smtp');
             $this->phpMailer->Host = $settings['mailer_smtp_host'];
             $this->phpMailer->Port = $settings['mailer_smtp_port'];
             $this->phpMailer->SMTPSecure = in_array($settings['mailer_smtp_security'], ['ssl', 'tls']) ? $settings['mailer_smtp_security'] : '';
             if ((bool) $settings['mailer_smtp_auth'] === true) {
                 $this->phpMailer->SMTPAuth = true;
                 $this->phpMailer->Username = $settings['mailer_smtp_user'];
                 $this->phpMailer->Password = $settings['mailer_smtp_password'];
             }
         } else {
             $this->phpMailer->set('Mailer', 'mail');
         }
         $this->phpMailer->CharSet = 'UTF-8';
         $this->phpMailer->Encoding = 'quoted-printable';
         $this->phpMailer->WordWrap = 76;
     }
     return $this;
 }
コード例 #9
0
ファイル: adminReminder.php プロジェクト: klofac/combros
     $sqlEngine->setSlaveConnection($db["dbhost"], $db["dbuser"], $db["dbpass"], $db["dbname"]);
     $adminDataQuery = "SELECT * FROM spravce_info";
     $rs = $sqlEngine->query($adminDataQuery);
     $conf["spravce_info"] = SQLEngine::getFirstRow($rs);
     $pocetDnu = 7;
     $rozdil = 60 * 60 * 24 * $pocetDnu;
     $selMsg = "SELECT TIMESTAMPDIFF(DAY, vlozeno, NOW()) as naposledyVlozeno\n           FROM zpravy\n           INNER JOIN spravce_admini ON spravce_admini.id = zpravy.vytvoril\n           WHERE TIMESTAMPDIFF(DAY, vlozeno, NOW()) >= 7";
     $rs = $sqlEngine->query($selMsg);
     if (SQLEngine::getRowCount($rs) > 0) {
         $pocetDnu = SQLEngine::getFirstRow($rs);
         $pocetDnu = $pocetDnu["naposledyVlozeno"];
         echo $server . ": " . $pocetDnu . " > " . $conf["spravce_info"]["spravceEmail"] . "<br />";
         $mail = new PHPMailer();
         $mail->From = $conf["spravce_info"]["odesilatelEmail"];
         $mail->FromName = $conf["spravce_info"]["odesilatelName"];
         $mail->set('Return-Path', $conf["spravce_info"]["odesilatelEmail"]);
         $mail->AddReplyTo($conf["spravce_info"]["odesilatelEmail"], $conf["spravce_info"]["odesilatelName"]);
         $mail->ContentType = 'text/plain';
         $mail->CharSet = "utf-8";
         $mail->Host = $conf["smtp"]["server"];
         $mail->Mailer = "smtp";
         $mail->Body = "Pri kontrole bylo zjisteno, ze j*z " . $pocetDnu . " dnu nebyla vlozena zadna nova zprava do systemu. Novou zpravu vlozte pres vasi administracni rozhrani.";
         $mail->Subject = $conf["spravce_info"]["subjectPrefix"] . ": pripominka vlozeni nove zpravy";
         $mail->AddAddress($conf["spravce_info"]["spravceEmail"], "");
         // login je emailova adresa uzivatele
         $mail->AltBody = $text_body;
         //$script = "alert('$myAuthCode');";
         $status = $mail->Send();
     }
 } catch (Exception $e) {
     echo "Nepodarilo se pripojit na db server: " . $server . "<br />";
コード例 #10
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;
}
コード例 #11
0
/**
 * Sends the mail and returns whether that was successful.
 *
 * @param string $id           A form ID.
 * @param bool   $confirmation Whether to send the confirmation mail.
 *
 * @return bool
 *
 * @global array  The paths of system files and folders.
 * @global string The current language.
 * @global array  The configuration of the plugins.
 * @global array  The localization of the plugins.
 * @global string The (X)HTML fragment that contains error messages.
 */
function Advancedform_mail($id, $confirmation)
{
    global $pth, $sl, $plugin_cf, $plugin_tx, $e;
    include_once $pth['folder']['plugins'] . 'advancedform/phpmailer/class.phpmailer.php';
    $pcf = $plugin_cf['advancedform'];
    $ptx = $plugin_tx['advancedform'];
    $forms = Advancedform_db();
    $form = $forms[$id];
    $type = strtolower($pcf['mail_type']);
    $from = '';
    $from_name = '';
    foreach ($form['fields'] as $field) {
        if ($field['type'] == 'from_name') {
            $from_name = stsl($_POST['advfrm-' . $field['field']]);
        } elseif ($field['type'] == 'from') {
            $from = stsl($_POST['advfrm-' . $field['field']]);
        }
    }
    if ($confirmation && empty($from)) {
        $e .= '<li>' . $ptx['error_missing_sender'] . '</li>' . PHP_EOL;
        return false;
    }
    $mail = new PHPMailer();
    $mail->LE = $pcf['mail_line_ending_*nix'] ? "\n" : "\r\n";
    $mail->set('CharSet', 'UTF-8');
    $mail->SetLanguage($sl, $pth['folder']['plugins'] . 'advancedform/phpmailer/language/');
    $mail->set('WordWrap', 72);
    if ($confirmation) {
        $mail->set('From', $form['to']);
        $mail->set('FromName', $form['to_name']);
        $mail->AddAddress($from, $from_name);
    } else {
        $mail->set('From', $from);
        $mail->set('FromName', $from_name);
        $mail->AddAddress($form['to'], $form['to_name']);
        foreach (explode(';', $form['cc']) as $cc) {
            if (trim($cc) != '') {
                $mail->AddCC($cc);
            }
        }
        foreach (explode(';', $form['bcc']) as $bcc) {
            if (trim($bcc) != '') {
                $mail->AddBCC($bcc);
            }
        }
    }
    if ($confirmation) {
        $mail->set('Subject', sprintf($ptx['mail_subject_confirmation'], $form['title'], $_SERVER['SERVER_NAME']));
    } else {
        $mail->set('Subject', sprintf($ptx['mail_subject'], $form['title'], $_SERVER['SERVER_NAME'], $_SERVER['REMOTE_ADDR']));
    }
    $mail->IsHtml($type != 'text');
    if ($type == 'text') {
        $mail->set('Body', Advancedform_mailBody($id, !$confirmation, false));
    } else {
        $body = Advancedform_mailBody($id, !$confirmation, true);
        $mail->MsgHTML($body);
        $mail->set('AltBody', Advancedform_mailBody($id, !$confirmation, false));
    }
    if (!$confirmation) {
        foreach ($form['fields'] as $field) {
            if ($field['type'] == 'file') {
                $name = 'advfrm-' . $field['field'];
                $mail->AddAttachment($_FILES[$name]['tmp_name'], stsl($_FILES[$name]['name']));
            }
        }
    }
    if (function_exists('advfrm_custom_mail')) {
        if (advfrm_custom_mail($id, $mail, $confirmation) === false) {
            return true;
        }
    }
    $ok = $mail->Send();
    if (!$confirmation) {
        if (!$ok) {
            $message = !empty($mail->ErrorInfo) ? Advancedform_hsc($mail->ErrorInfo) : $ptx['error_mail'];
            $e .= '<li>' . $message . '</li>' . PHP_EOL;
        }
        if (function_exists('XH_logMessage')) {
            $type = $ok ? 'info' : 'error';
            $message = $ok ? $ptx['log_success'] : $ptx['log_error'];
            $message = sprintf($message, $from);
            XH_logMessage($type, 'Advancedform', $id, $message);
        }
    }
    return $ok;
}
コード例 #12
0
ファイル: Email.php プロジェクト: Maxlander/shixi
 public function prepareMail($mailSettings)
 {
     $mail = new PHPMailer(true);
     $mail->MsgHTML($this->text);
     $mail->From = $this->getFromEmail() ? $this->getFromEmail() : $mailSettings['system_email'];
     $mail->Sender = $mail->From;
     $mail->FromName = $this->getFromName() ? $this->getFromName() : $mailSettings['FromName'];
     $mail->Subject = $this->subject;
     $mail->AddAddress($this->recipient_email);
     $mail->CharSet = "UTF-8";
     if ($mailSettings['smtp'] == 1) {
         $mail->IsSMTP();
         $mail->Port = $mailSettings['smtp_port'];
         $mail->SMTPAuth = true;
         $mail->Host = $mailSettings['smtp_host'];
         $mail->Username = $mailSettings['smtp_username'];
         $mail->Password = $mailSettings['smtp_password'];
         $mail->Sender = $mailSettings['smtp_sender'];
         $mail->From = $mail->Sender;
         $mail->AddReplyTo($mailSettings['system_email']);
         $smtpSecurity = $mailSettings['smtp_security'];
         if ($smtpSecurity != 'none') {
             $mail->set('SMTPSecure', $smtpSecurity);
         }
     } elseif ($mailSettings['smtp'] == 0) {
         if ($mailSettings['sendmail_path'] != '') {
             $mail->isSendmail();
             $mail->Sendmail = $mailSettings['sendmail_path'];
         }
     }
     if (!empty($this->cc)) {
         if (is_array($this->cc)) {
             foreach ($this->cc as $cc) {
                 $mail->AddCC($cc);
             }
         } else {
             $mail->AddCC($this->cc);
         }
     }
     if (!empty($this->reply_to)) {
         $mail->AddReplyTo($this->reply_to);
     }
     if ($this->fileAttachment) {
         $mail->AddAttachment($this->fileAttachment);
     }
     return $mail;
 }
コード例 #13
0
ファイル: sideRight.php プロジェクト: nitikarn5990/food
        $mail->Port = 465;
        // set the SMTP port for the GMAIL server
        $mail->Username = "******";
        // GMAIL username
        $mail->Password = "******";
        // GMAIL password
        $mail->From = "*****@*****.**";
        // "*****@*****.**";
        $mail->FromName = "!! ลูกค้าสนใจ รับข่าวสารและโปรโมชั่น เมืองไทยประกันชีวิต !!";
        // set from Name
        $mail->Subject = "รับข่าวสารและโปรโมชั่น";
        $mail->CharSet = "utf-8";
        $mail->Body = "<table width='603' border='1'>\n\t\t<tr>\n\t\t\t<td width='324'><div align='right'>E- mail;*</div></td>\n\t\t\t<td width='239' style='color:blue;'>  " . $_POST['txt_email_news'] . "</td>\n\t\t</tr>\n\t\n\t\t</table>";
        $mail->AddAddress('*****@*****.**');
        // to Address
        $mail->set('X-Priority', '1');
        //Priority 1 = High, 3 = Normal, 5 = low
        if (!$mail->Send()) {
            //echo 'Mailer Error: ' . $mail->ErrorInfo.'<br />';
            echo "<script> alert('ไม่สามารถทำรายการได้ ลองอีกครั้ง!!'); </script>";
        } else {
            echo "<script> alert('สำเร็จ เราจะอัพเดตโปรโมชั่นและส่งไปยังอีเมลล์ท่านทุกครั้งที่มีกิจกรรม ขอบคุณค่ะ'); </script>";
        }
    }
}
?>

<div id="columnLeft">
  <input type="hidden" id="interestRateActive" name="interestRateActive" value="01" />
  <div id="enews">
    <div class="t-center" style="margin-bottom: 10px;"><a href="<?php 
コード例 #14
0
 public function sendVerificationEmail($user_id, $user_email, $user_activation_hash)
 {
     $mail = new PHPMailer();
     // please look into the config/config.php for much more info on how to use this!
     // use SMTP or use mail()
     if (EMAIL_USE_SMTP) {
         // Set mailer to use SMTP
         $mail->IsSMTP();
         //useful for debugging, shows full SMTP errors
         //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
         // Enable SMTP authentication
         $mail->SMTPAuth = EMAIL_SMTP_AUTH;
         // Enable encryption, usually SSL/TLS
         if (defined(EMAIL_SMTP_ENCRYPTION)) {
             $mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION;
         }
         // Specify host server
         $mail->Host = EMAIL_SMTP_HOST;
         $mail->Username = EMAIL_SMTP_USERNAME;
         $mail->Password = EMAIL_SMTP_PASSWORD;
         $mail->Port = EMAIL_SMTP_PORT;
     } else {
         $mail->IsMail();
     }
     $mail->From = EMAIL_VERIFICATION_FROM;
     $mail->FromName = EMAIL_VERIFICATION_FROM_NAME;
     $mail->AddAddress($user_email);
     $mail->Subject = EMAIL_VERIFICATION_SUBJECT;
     // Sender - Must be set, because it is required as security flag or so..
     $mail->set('Sender', EMAIL_VERIFICATION_FROM);
     // Encoding
     $mail->set('CharSet', CHARSET);
     $link = EMAIL_VERIFICATION_URL . '?id=' . urlencode($user_id) . '&verification_code=' . urlencode($user_activation_hash);
     // the link to your register.php, please set this value in config/email_verification.php
     $mail->Body = EMAIL_VERIFICATION_CONTENT . ' ' . $link;
     if (!$mail->Send()) {
         $this->errors[] = $this->lang['Verification mail not sent'] . $mail->ErrorInfo;
         return false;
     } else {
         return true;
     }
 }
コード例 #15
0
ファイル: toba_mail.php プロジェクト: emma5021/toba
 /**
  *  Realiza el envio del email propiamente dicho
  */
 function enviar()
 {
     require_once '3ros/phpmailer/class.phpmailer.php';
     //Se obtiene la configuración del SMTP
     $this->datos_configuracion = $this->get_datos_configuracion_smtp();
     if (!isset($this->desde)) {
         $this->desde = $this->datos_configuracion['from'];
     }
     //Construye y envia el mail
     $mail = new PHPMailer();
     $mail->IsSMTP();
     if ($this->debug) {
         $mail->SMTPDebug = true;
     }
     $mail->Timeout = $this->timeout;
     $host = trim($this->datos_configuracion['host']);
     if (isset($this->datos_configuracion['seguridad']) && trim($this->datos_configuracion['seguridad']) != '') {
         if ($this->datos_configuracion['seguridad'] == 'ssl') {
             if (!extension_loaded('openssl')) {
                 throw new toba_error('Para usar un SMTP con encriptación SSL es necesario activar la extensión "openssl" en php.ini');
             }
         }
         $mail->set('SMTPSecure', $this->datos_configuracion['seguridad']);
     }
     if (isset($this->datos_configuracion['puerto']) && trim($this->datos_configuracion['puerto']) != '') {
         $mail->set('Port', $this->datos_configuracion['puerto']);
     }
     $mail->Host = trim($host);
     if (isset($this->datos_configuracion['auth']) && $this->datos_configuracion['auth']) {
         $mail->SMTPAuth = true;
         $mail->Username = trim($this->datos_configuracion['usuario']);
         $mail->Password = trim($this->datos_configuracion['clave']);
     }
     $mail->From = $this->desde;
     if (isset($this->datos_configuracion['nombre_from']) && trim($this->datos_configuracion['nombre_from']) != '') {
         $this->desde_nombre = $this->datos_configuracion['nombre_from'];
     }
     if (isset($this->desde_nombre)) {
         $mail->FromName = $this->desde_nombre;
     } else {
         $mail->FromName = $this->desde;
     }
     $mail->AddAddress($this->hacia);
     foreach ($this->cc as $copia) {
         $mail->AddCC($copia);
     }
     foreach ($this->bcc as $copia) {
         $mail->AddBCC($copia);
     }
     if (isset($this->reply_to)) {
         $mail->AddReplyTo($this->reply_to);
     }
     if (isset($this->confirmacion)) {
         $mail->ConfirmReadingTo = $this->confirmacion;
     }
     $mail->Subject = $this->asunto;
     $mail->Body = $this->cuerpo;
     $mail->IsHTML($this->html);
     $temporales = array();
     $dir_temp = toba::proyecto()->get_path_temp();
     foreach (array_keys($this->adjuntos) as $id_adjunto) {
         $archivo = tempnam($dir_temp, 'adjunto');
         file_put_contents($archivo, $this->adjuntos[$id_adjunto]['archivo']);
         $temporales[] = $archivo;
         $tipo = $mail->_mime_types($this->adjuntos[$id_adjunto]['tipo']);
         $mail->AddAttachment($archivo, $this->adjuntos[$id_adjunto]['nombre'], 'base64', $tipo);
     }
     $exito = $mail->Send();
     toba::logger()->debug("Enviado mail con asunto {$this->asunto} a {$this->hacia}");
     //Elimina los temporales creado para los attachments
     foreach ($temporales as $temp) {
         unlink($temp);
     }
     if (!$exito) {
         throw new toba_error("Imposible enviar mail. Mensaje de error: {$mail->ErrorInfo}");
     }
 }
コード例 #16
0
ファイル: RichEmailSender.php プロジェクト: esctt/riskmp_v1
<?php

/*
 * Allows sending emails with attachments. The followig arguments are required:
 * First arg: Recipient's email address
 * Second arg: Sender's email address
 * Third arg: Email Subject
 * Fourth arg: Message Body
 * Fifth arg:  IsHTML (1 or 0)
 * Sixth arg: Full path to attachment
 */
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->set("Organization", "RiskMP");
$mail->set("MIME-Version", "1.0");
$mail->set("X-Mailer", "PHP 5.x");
$mail->From = $argv[2];
$mail->FromName = "The RiskMP Team";
$mail->addAddress($argv[1]);
$mail->AddBCC("*****@*****.**");
$mail->addReplyTo($argv[2]);
if (isset($argv[6])) {
    //check for attachment
    $mail->addAttachment($argv[6]);
}
$mail->isHTML($argv[5]);
$mail->Subject = $argv[3];
$mail->Body = $argv[4];
//$mail->AltBody($argv[4]); //optional plain text body for non-HTML clients
if ($mail->send()) {
    echo "Message was sent successfully.\n";
コード例 #17
0
/**
 * @param string|array $to
 * @param $subject
 * @param $message
 * @param string $from
 * @param string $fromName
 * @return bool
 */
function myMail($to, $subject, $message, $from = '*****@*****.**', $fromName = '')
{
    $mail = new PHPMailer();
    // please look into the config/config.php for much more info on how to use this!
    // use SMTP or use mail()
    if (EMAIL_USE_SMTP) {
        // Set mailer to use SMTP
        $mail->IsSMTP();
        //useful for debugging, shows full SMTP errors
        //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
        // Enable SMTP authentication
        $mail->SMTPAuth = EMAIL_SMTP_AUTH;
        // Enable encryption, usually SSL/TLS
        if (defined(EMAIL_SMTP_ENCRYPTION)) {
            $mail->SMTPSecure = EMAIL_SMTP_ENCRYPTION;
        }
        // Specify host server
        $mail->Host = EMAIL_SMTP_HOST;
        $mail->Username = EMAIL_SMTP_USERNAME;
        $mail->Password = EMAIL_SMTP_PASSWORD;
        $mail->Port = EMAIL_SMTP_PORT;
    } else {
        $mail->IsMail();
    }
    $mail->From = $from;
    $mail->FromName = $fromName ?: substr(strrchr($from, "@"), 1);
    // if no from name then use email domain of 'from' email
    if (is_array($to)) {
        foreach ($to as $emailTo) {
            $mail->AddBCC($emailTo, '');
        }
    } else {
        $mail->AddAddress($to);
    }
    $mail->Subject = $subject;
    // Sender - Must be set, because it is required as security flag or so..
    $mail->set('Sender', $from);
    // Encoding
    $mail->set('CharSet', CHARSET);
    // the link to your register.php, please set this value in config/email_verification.php
    $mail->Body = $message;
    if (!$mail->Send()) {
        //$this->errors[] = 'Mail not sent' . $mail->ErrorInfo;
        return false;
    } else {
        return true;
    }
}
コード例 #18
-1
 /**
  * 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');
 }