Authorise() public method

Combination of public events - connect, login, disconnect
public Authorise ( string $host, integer $port = false, integer $tval = false, string $username, string $password, $debug_level )
$host string
$port integer
$tval integer
$username string
$password string
Esempio n. 1
0
function zenphoto_PHPMailer($msg, $email_list, $subject, $message, $from_mail, $from_name, $cc_addresses, $replyTo, $html = false)
{
    require_once dirname(__FILE__) . '/PHPMailer/class.phpmailer.php';
    switch (getOption('PHPMailer_mail_protocol')) {
        case 'pop3':
            require_once dirname(__FILE__) . '/PHPMailer/class.pop3.php';
            $pop = new POP3();
            $authorized = $pop->Authorise(getOption('PHPMailer_server'), getOption('PHPMailer_pop_port'), 30, getOption('PHPMailer_user'), getOption('PHPMailer_password'), 0);
            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->Port = getOption('PHPMailer_smtp_port');
            $mail->Host = getOption('PHPMailer_server');
            break;
        case 'smtp':
            $mail = new PHPMailer();
            $mail->SMTPAuth = true;
            // enable SMTP authentication
            $mail->IsSMTP();
            $mail->Username = getOption('PHPMailer_user');
            $mail->Password = getOption('PHPMailer_password');
            $mail->Host = getOption('PHPMailer_server');
            $mail->Port = getOption('PHPMailer_smtp_port');
            break;
        case 'sendmail':
            $mail = new PHPMailer();
            $mail->IsSendmail();
            break;
    }
    $mail->SMTPSecure = getOption('PHPMailer_secure');
    $mail->CharSet = 'UTF-8';
    $mail->From = $from_mail;
    $mail->FromName = $from_name;
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->AltBody = '';
    $mail->IsHTML($html);
    foreach ($email_list as $to_name => $to_mail) {
        if (is_numeric($to_name)) {
            $mail->AddAddress($to_mail);
        } else {
            $mail->AddAddress($to_mail, $to_name);
        }
    }
    if (count($cc_addresses) > 0) {
        foreach ($cc_addresses as $cc_name => $cc_mail) {
            $mail->AddCC($cc_mail);
        }
    }
    if ($replyTo) {
        $names = array_keys($replyTo);
        $mail->AddReplyTo(array_shift($replyTo), array_shift($names));
    }
    if (!$mail->Send()) {
        if (!empty($msg)) {
            $msg .= '<br />';
        }
        $msg .= sprintf(gettext('<code>PHPMailer</code> failed to send <em>%1$s</em>. ErrorInfo:%2$s'), $subject, $mail->ErrorInfo);
    }
    return $msg;
}
Esempio n. 2
0
 function SendMail($toAddress, $toName, $subject, $messageBody, $bcc = NULL, $mailList = FALSE)
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/Main.php";
     if ($mailList) {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService2.php";
     } else {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService.php";
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.phpmailer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.pop3.php";
     if ($MailServiceAuthPOP3) {
         $pop = new POP3();
         $pop->Authorise($MailServicePOP3Addr, $MailServicePOP3Port, 30, $MailServiceSMTPUser, $MailServiceSMTPPass, $MailServicePOPDebug);
     }
     $mail = new PHPMailer();
     if ($MailServiceMailerLang != "en") {
         $mail->SetLanguage($MailServiceMailerLang, $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/language/");
     }
     $mail->IsSMTP();
     $mail->SMTPDebug = $MailServiceSMTPDebug;
     $mail->Port = $MailServiceSMTPPort;
     $mail->SMTPSecure = $MailServiceEncrypt;
     $mail->Host = $MailServiceSMTPAddr;
     $mail->SMTPAuth = $MailServiceAuthSMTP;
     $mail->Username = $MailServiceSMTPUser;
     $mail->Password = $MailServiceSMTPPass;
     $mail->From = $MailServiceFromMail;
     $mail->FromName = $MailServiceFromName;
     $mail->AddAddress($toAddress, $toName);
     if ($bcc != NULL) {
         if (is_array($bcc)) {
             foreach ($bcc as $key => $value) {
                 $mail->AddBCC($value);
             }
         }
     }
     $mail->WordWrap = 50;
     $mail->CharSet = $MailServiceMsgCharset;
     $mail->IsHTML(true);
     $mail->Subject = $subject;
     $mail->Body = $messageBody;
     if ($mail->Send()) {
         return true;
     } else {
         return $mail->ErrorInfo;
     }
 }
Esempio n. 3
0
function sendMail($_msubject, $_mbody, $_mto, $_mname)
{
    global $SMTP_FROMNAME;
    $pop = new POP3();
    $pop->Authorise('envasadoras.com.mx', 110, 30, 't&e-hod', 'tyeh2014', 1);
    $mail = new PHPMailer();
    //Luego tenemos que iniciar la validación por SMTP:
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Host = "envasadoras.com.mx";
    // SMTP a utilizar. Por ej. smtp.elserver.com
    //$mail->Username = "******"; // Correo completo a utilizar
    //$mail->Password = "******"; // Contraseña
    $mail->Port = 25;
    // Puerto a utilizar
    $mail->From = "t&e-hod@envasadoras.com.mx";
    // Desde donde enviamos (Para mostrar)
    $mail->FromName = "Sistema de Gastos de Viaje";
    $cnt = 0;
    if (stristr($_mto, ",") === FALSE) {
        //EVALUAMOS SI TIENE , PARA SACAR A LOS USUARIOS QUE SE MANDARA EL MAIL :)
        $mail->AddAddress($_mto, $_mname);
    } else {
        $aux = explode(",", $_mto);
        foreach ($aux as $direccion) {
            $mail->AddAddress(trim($direccion), $_mname);
            $cnt++;
        }
    }
    $mail->WordWrap = 50;
    // set word wrap
    $mail->IsHTML(TRUE);
    // send as HTML
    $mail->Subject = $_msubject;
    $mail->Body = $_mbody;
    if (!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
        return -1;
    }
    return 0;
    //echo "    Mensaje Enviado.\n";
}
Esempio n. 4
0
 public function action_index()
 {
     if (!empty($_REQUEST["f_rename"])) {
         if ($this->model->valid($_POST["f_mail"], $_POST["f_login"]) > 0) {
             $maincfg = Configs::readCfg("main", tbuild);
             if ($maincfg["usemd5"] == 0) {
                 $pwd = $this->model->viewPwd($_POST["f_login"]);
             } else {
                 $pwd = $this->model->getNewPwd($_POST["f_login"], 1);
             }
             if ($this->configs["useMail"] != 1) {
                 echo "<script>alert('password is: {$pwd}');</script>";
             } else {
                 $c_mail = Configs::readCfg("mail", tbuild);
                 require "libraries/PHPMailer/PHPMailerAutoload.php";
                 $pop = new POP3();
                 $pop->Authorise($c_mail["mailhost"], $c_mail["mailport"], $c_mail["mailtmout"], $c_mail["mailboxf"], $c_mail["mailpbf"], $c_mail["maildlvl"]);
                 $mail = new PHPMailer();
                 $mail->CharSet = "UTF-8";
                 $mail->Host = $c_mail["mailhost"];
                 $mail->SMTPAuth = true;
                 $mail->Username = $c_mail["mailboxf"];
                 $mail->Password = $c_mail["mailpbf"];
                 $mail->SetFrom($c_mail["mailboxf"], $c_mail["mailnamefrom"]);
                 $mail->AddReplyTo($c_mail["mailboxf"], $c_mail["mailnib"]);
                 $mail->Subject = "Register";
                 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
                 // optional, comment out and test
                 $this->view->set("fl_login", $_POST["f_login"])->set("fl_pwd", $pwd);
                 $mail->MsgHTML($this->view->out("register", "mail", 2));
                 $mail->AddAddress($_POST['f_mail']);
                 if (!$mail->Send()) {
                     $this->model->toLog("Mail error:" . $mail->ErrorInfo, "register", 13);
                 }
                 echo "<script>alert('Password was send to your e-mail');</script>";
             }
         }
     }
     $this->view->out("forgotpwd");
 }
<html>
<head>
<title>POP before SMTP Test</title>
</head>
<body>

<?php 
require_once '../class.phpmailer.php';
require_once '../class.pop3.php';
// required for POP before SMTP
$pop = new POP3();
$pop->Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1);
$mail = new PHPMailer(true);
// the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP();
try {
    $mail->SMTPDebug = 2;
    $mail->Host = 'pop3.yourdomain.com';
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->AddAddress('*****@*****.**', 'John Doe');
    $mail->SetFrom('*****@*****.**', 'First Last');
    $mail->AddReplyTo('*****@*****.**', 'First Last');
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    // optional - MsgHTML will create an alternate automatically
    $mail->MsgHTML(file_GET_contents('contents.html'));
    $mail->AddAttachment('images/phpmailer.gif');
    // attachment
    $mail->AddAttachment('images/phpmailer_mini.gif');
    // attachment
    $mail->Send();
Esempio n. 6
0
function cforms_phpmailer($no, $frommail, $field_email, $to, $vsubject, $message, $formdata, $htmlmessage, $htmlformdata, $file = 'ac')
{
    global $smtpsettings, $phpmailer, $cformsSettings;
    $eol = $cformsSettings['global']['cforms_crlf'][b] != 1 ? "\r\n" : "\n";
    if (file_exists(dirname(__FILE__) . '/class.phpmailer.php') && !class_exists('PHPMailer')) {
        require_once dirname(__FILE__) . '/class.phpmailer.php';
        require_once dirname(__FILE__) . '/class.smtp.php';
        if ($smtpsettings[6] == '1') {
            require_once dirname(__FILE__) . '/class.pop3.php';
        }
    }
    ### pop before smtp?
    if ($smtpsettings[6] == '1' && class_exists('POP3')) {
        $debuglevel = 0;
        $pop = new POP3();
        $pop->Authorise($smtpsettings[7], $smtpsettings[8], 30, $smtpsettings[9], $smtpsettings[10], $debuglevel);
    }
    $mail = new PHPMailer();
    $mail->ClearAllRecipients();
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    $mail->CharSet = 'utf-8';
    $mail->SetLanguage('en', dirname(__FILE__) . '/');
    $mail->PluginDir = dirname(__FILE__) . '/';
    $mail->IsSMTP();
    $mail->Host = $smtpsettings[1];
    if ((int) $cformsSettings['form' . $no]['cforms' . $no . '_emailpriority'] > 0) {
        $mail->Priority = (int) $cformsSettings['form' . $no]['cforms' . $no . '_emailpriority'];
    }
    ### $mail->SMTPDebug = true;
    if ($smtpsettings[4] != '') {
        $mail->SMTPSecure = $smtpsettings[4];
        ### sets the prefix to the servier
        $mail->Port = $smtpsettings[5];
        ### set the SMTP port
    }
    if ($smtpsettings[2] != '') {
        $mail->SMTPAuth = true;
        ### turn on SMTP authentication
        $mail->Username = $smtpsettings[2];
        ### SMTP username
        $mail->Password = $smtpsettings[3];
        ### SMTP password
    }
    $temp2 = array();
    ###from
    if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $frommail, $temp)) {
        $mail->From = $temp[0];
    }
    if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $frommail, $temp2)) {
        $mail->FromName = str_replace('"', '', $temp2[1]);
    } else {
        $mail->FromName = $temp[0];
    }
    $temp2 = array();
    ### reply-to
    if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $field_email, $temp)) {
        if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $field_email, $temp2)) {
            $mail->AddReplyTo($temp[0], str_replace('"', '', $temp2[1]));
        } else {
            $mail->AddReplyTo($temp[0]);
        }
    }
    ### TAF: add CC
    if (substr($cformsSettings['form' . $no]['cforms' . $no . '_tellafriend'], 0, 1) == '1' && $file == 'ac') {
        $mail->AddCC($temp[0], str_replace('"', '', $temp2[1]));
    }
    ### bcc
    $te = array();
    $t = array();
    $addresses = explode(',', stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_bcc']));
    foreach ($addresses as $a) {
        if (preg_match('/([\\w-+\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $a, $te)) {
            $mail->AddBCC($te[0]);
        }
    }
    ###to
    ###if( preg_match('/[\w-\.]+@([\w-]+\.)+[\w-]{2,4}/',$to,$temp) )
    ###	$mail->AddAddress($temp[0]);
    $addresses = explode(',', $to);
    foreach ($addresses as $address) {
        if (preg_match('/([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})/', $address, $temp)) {
            if (preg_match('/(.*)\\s+(([\\w-\\.]+@|<)).*/', $address, $temp2)) {
                $mail->AddAddress($temp[0], str_replace('"', '', $temp2[1]));
            } else {
                $mail->AddAddress($temp[0]);
            }
        }
    }
    ###
    ### HTML email ?
    ###
    if ($htmlmessage != '') {
        $htmlmessage = str_replace('=3D', '=', $htmlmessage);
        ###remove 3D's
        $htmlformdata = str_replace('=3D', '=', $htmlformdata);
        ###remove 3D's,
        $mail->IsHTML(true);
        $mail->Body = "<html>" . $eol . "<body>" . stripslashes($htmlmessage) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 1, 1) == '1' && $htmlformdata != '' ? $eol . $htmlformdata : '') . $eol . "</body></html>" . $eol;
        $mail->AltBody = stripslashes($message) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 0, 1) == '1' && $formdata != '' ? $eol . $formdata : '');
    } else {
        $mail->Body = stripslashes($message) . (substr($cformsSettings['form' . $no]['cforms' . $no . '_formdata'], 0, 1) == '1' && $formdata != '' ? $eol . $formdata : '');
    }
    ###
    ### adding attachments
    ###
    global $fdata;
    if ($file == '1' && !$cformsSettings['form' . $no]['cforms' . $no . '_noattachments']) {
        foreach ($fdata as $file) {
            if ($file[name] != '') {
                $n = substr($file[name], strrpos($file[name], $cformsSettings['global']['cforms_IIS']) + 1, strlen($file[name]));
                $m = getMIME(strtolower(substr($n, strrpos($n, '.') + 1, strlen($n))));
                $mail->AddAttachment($file[name], $n, 'base64', $m);
                ### optional name
            }
        }
        ### for
    }
    ### end adding attachments
    $mail->Subject = $vsubject;
    $sentadmin = $mail->Send();
    if ($sentadmin) {
        return 1;
    } else {
        return $mail->ErrorInfo;
    }
}
Esempio n. 7
0
function osc_sendMail($params)
{
    if (key_exists('add_bcc', $params)) {
        if (!is_array($params['add_bcc']) && $params['add_bcc'] != '') {
            $params['add_bcc'] = array($params['add_bcc']);
        }
    }
    require_once osc_lib_path() . 'phpmailer/class.phpmailer.php';
    if (osc_mailserver_pop()) {
        require_once osc_lib_path() . 'phpmailer/class.pop3.php';
        $pop = new POP3();
        $pop->Authorise(isset($params['host']) ? $params['host'] : osc_mailserver_host(), isset($params['port']) ? $params['port'] : osc_mailserver_port(), 30, isset($params['username']) ? $params['username'] : osc_mailserver_username(), isset($params['username']) ? $params['username'] : osc_mailserver_username(), 0);
    }
    $mail = new PHPMailer(true);
    try {
        $mail->CharSet = 'utf-8';
        if (osc_mailserver_auth()) {
            $mail->IsSMTP();
            $mail->SMTPAuth = true;
        } else {
            if (osc_mailserver_pop()) {
                $mail->IsSMTP();
            }
        }
        $mail->SMTPSecure = isset($params['ssl']) ? $params['ssl'] : osc_mailserver_ssl();
        $mail->Username = isset($params['username']) ? $params['username'] : osc_mailserver_username();
        $mail->Password = isset($params['password']) ? $params['password'] : osc_mailserver_password();
        $mail->Host = isset($params['host']) ? $params['host'] : osc_mailserver_host();
        $mail->Port = isset($params['port']) ? $params['port'] : osc_mailserver_port();
        $mail->From = isset($params['from']) ? $params['from'] : osc_contact_email();
        $mail->FromName = isset($params['from_name']) ? $params['from_name'] : osc_page_title();
        $mail->Subject = isset($params['subject']) ? $params['subject'] : '';
        $mail->Body = isset($params['body']) ? $params['body'] : '';
        $mail->AltBody = isset($params['alt_body']) ? $params['alt_body'] : '';
        $to = isset($params['to']) ? $params['to'] : '';
        $to_name = isset($params['to_name']) ? $params['to_name'] : '';
        if (key_exists('add_bcc', $params)) {
            foreach ($params['add_bcc'] as $bcc) {
                $mail->AddBCC($bcc);
            }
        }
        if (isset($params['reply_to'])) {
            $mail->AddReplyTo($params['reply_to']);
        }
        if (isset($params['attachment'])) {
            $mail->AddAttachment($params['attachment']);
        }
        $mail->IsHTML(true);
        $mail->AddAddress($to, $to_name);
        $mail->Send();
        return true;
    } catch (phpmailerException $e) {
        error_log("phpmailerException in osc_sendMail() Error: " . $mail->ErrorInfo, 0);
        return false;
    } catch (Exception $e) {
        error_log("Exception in osc_sendMail() Error" . $mail->ErrorInfo, 0);
        return false;
    }
    return false;
}
<html>
<head>
<title>POP before SMTP Test</title>
</head>

<body>

<pre>
<?php 
require 'class.phpmailer.php';
require 'class.pop3.php';
$pop = new POP3();
$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->IsHTML(false);
$mail->Host = 'relay.example.com';
$mail->From = '*****@*****.**';
$mail->FromName = 'Example Mailer';
$mail->Subject = 'My subject';
$mail->Body = 'Hello world';
$mail->AddAddress('*****@*****.**', 'First Last');
if (!$mail->Send()) {
    echo $mail->ErrorInfo;
}
?>
</pre>

</body>
</html>
Esempio n. 9
0
File: mail.php Progetto: notzen/e107
 /**
  * Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
  * 
  * @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref.
  * @return none
  */
 public function __construct($overrides = FALSE)
 {
     parent::__construct(FALSE);
     // Parent constructor - no exceptions for now
     $e107 = e107::getInstance();
     global $pref;
     //Load up Email Templates
     include e107::coreTemplatePath('email', 'front');
     $this->templateOption['email'] = array('header' => $EMAIL_HEADER, 'footer' => $EMAIL_FOOTER);
     $this->templateOption['notify'] = array('header' => $NOTIFY_HEADER, 'footer' => $NOTIFY_FOOTER);
     $this->templateOption['mailout'] = array('header' => $MAILOUT_HEADER, 'footer' => $MAILOUT_FOOTER);
     $this->CharSet = 'utf-8';
     $this->SetLanguage(CORE_LC);
     if ($overrides === FALSE || !is_array($overrides)) {
         $overrides = array();
     }
     foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin', 'smtp_pop3auth') as $k) {
         if (!isset($overrides[$k])) {
             $overrides[$k] = $pref[$k];
         }
     }
     $this->pause_amount = varset($pref['mail_pause'], 10);
     $this->pause_time = varset($pref['mail_pausetime'], 1);
     if (varsettrue($pref['mail_options'])) {
         $this->general_opts = explode(',', $pref['mail_options'], '');
     }
     if (defined('MAIL_DEBUG')) {
         echo 'Mail_options: ' . $pref['mail_options'] . ' Count: ' . count($this->general_opts) . '<br />';
     }
     foreach ($this->general_opts as $k => $v) {
         $v = trim($v);
         $this->general_opts[$k] = $v;
         if (strpos($v, 'hostname') === 0) {
             list(, $this->HostName) = explode('=', $v);
             if (defined('MAIL_DEBUG')) {
                 echo "Host name set to: {$this->HostName}<br />";
             }
         }
     }
     list($this->logEnable, $this->add_email) = explode(',', varset($pref['mail_log_options'], '0,0'));
     switch ($overrides['mailer']) {
         case 'smtp':
             $smtp_options = array();
             $temp_opts = explode(',', varset($pref['smtp_options'], ''));
             if (varsettrue($overrides['smtp_pop3auth'])) {
                 $temp_opts[] = 'pop3auth';
             }
             // Legacy option - remove later
             if (varsettrue($pref['smtp_keepalive'])) {
                 $temp_opts[] = 'keepalive';
             }
             // Legacy option - remove later
             foreach ($temp_opts as $k => $v) {
                 if (strpos($v, '=') !== FALSE) {
                     list($v, $k) = explode('=', $v, 2);
                     $smtp_options[trim($v)] = trim($k);
                 } else {
                     $smtp_options[trim($v)] = TRUE;
                     // Simple on/off option
                 }
             }
             unset($temp_opts);
             $this->IsSMTP();
             // Enable SMTP functions
             if (varsettrue($smtp_options['helo'])) {
                 $this->Helo = $smtp_options['helo'];
             }
             if (isset($smtp_options['pop3auth'])) {
                 // Need POP-before-SMTP authorisation
                 require_once e_HANDLER . 'phpmailer/class.pop3.php';
                 $pop = new POP3();
                 $pop->Authorise($overrides['smtp_server'], 110, 30, $overrides['smtp_username'], $overrides['smtp_password'], 1);
             }
             $this->Mailer = 'smtp';
             $this->localUseVerp = isset($smtp_options['useVERP']);
             if (isset($smtp_options['secure'])) {
                 switch ($smtp_options['secure']) {
                     case 'TLS':
                         $this->SMTPSecure = 'tls';
                         $this->Port = 465;
                         // Can also use port 587, and maybe even 25
                         break;
                     case 'SSL':
                         $this->SMTPSecure = 'ssl';
                         $this->Port = 465;
                         break;
                     default:
                         if (defined('MAIL_DEBUG')) {
                             echo "Invalid option: {$smtp_options['secure']}<br />";
                         }
                 }
             }
             $this->SMTPKeepAlive = varset($smtp_options['keepalive'], FALSE);
             // ***** Control this
             $this->Host = $overrides['smtp_server'];
             if ($overrides['smtp_username'] && $overrides['smtp_password']) {
                 $this->SMTPAuth = !isset($smtp_options['pop3auth']);
                 $this->Username = $overrides['smtp_username'];
                 $this->Password = $overrides['smtp_password'];
             }
             break;
         case 'sendmail':
             $this->Mailer = 'sendmail';
             $this->Sendmail = $overrides['sendmail'] ? $overrides['sendmail'] : '/usr/sbin/sendmail -t -i -r ' . varsettrue($pref['replyto_email'], $overrides['siteadminemail']);
             break;
         case 'php':
             $this->Mailer = 'mail';
             break;
     }
     if (varsettrue($pref['mail_bounce_email'])) {
         $this->Sender = $pref['mail_bounce_email'];
     }
     $this->FromName = $e107->tp->toHTML(varsettrue($pref['replyto_name'], $overrides['siteadmin']), '', 'RAWTEXT');
     $this->From = $e107->tp->toHTML(varsettrue($pref['replyto_email'], $overrides['siteadminemail']), '', 'RAWTEXT');
     $this->WordWrap = 76;
     // Set a sensible default
     // Now look for any overrides - slightly cumbersome way of doing it, but does give control over what can be set from here
     // Options are those accepted by the arraySet() method.
     foreach (array('SMTPDebug', 'subject', 'from', 'fromname', 'replyto', 'send_html', 'add_html_header', 'attachments', 'cc', 'bcc', 'bouncepath', 'returnreceipt', 'priority', 'extra_header', 'wordwrap', 'split') as $opt) {
         if (isset($overrides[$opt])) {
             $this->arraySet(array($opt => $overrides[$opt]));
         }
     }
 }
Esempio n. 10
0
File: mail.php Progetto: armpit/e107
 /**
  * Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
  * 
  * @var array $overrides - array of values which override mail-related prefs. Key is the same as the corresponding pref.
  *						- second batch of keys can preset values configurable through the arraySet() method
  * @return none
  */
 public function __construct($overrides = FALSE)
 {
     parent::__construct(FALSE);
     // Parent constructor - no exceptions for now
     $e107 = e107::getInstance();
     $pref = e107::pref('core');
     $tp = e107::getParser();
     if (defined('MAIL_DEBUG')) {
         $this->debug = true;
     } else {
         $this->Debugoutput = 'handlePHPMailerDebug';
     }
     $this->pref = $pref;
     $this->CharSet = 'utf-8';
     $this->SetLanguage(CORE_LC);
     if ($overrides === FALSE || !is_array($overrides)) {
         $overrides = array();
     }
     foreach (array('mailer', 'smtp_server', 'smtp_username', 'smtp_password', 'sendmail', 'siteadminemail', 'siteadmin') as $k) {
         if (!isset($overrides[$k])) {
             $overrides[$k] = $pref[$k];
         }
     }
     $this->pause_amount = varset($pref['mail_pause'], 10);
     $this->pause_time = varset($pref['mail_pausetime'], 1);
     $this->allow_html = varset($pref['mail_sendstyle'], 'textonly') == 'texthtml' ? true : 1;
     if (vartrue($pref['mail_options'])) {
         $this->general_opts = explode(',', $pref['mail_options'], '');
     }
     if ($this->debug) {
         echo 'Mail_options: ' . $pref['mail_options'] . ' Count: ' . count($this->general_opts) . '<br />';
     }
     foreach ($this->general_opts as $k => $v) {
         $v = trim($v);
         $this->general_opts[$k] = $v;
         if (strpos($v, 'hostname') === 0) {
             list(, $this->HostName) = explode('=', $v);
             if ($this->debug) {
                 echo "Host name set to: {$this->HostName}<br />";
             }
         }
     }
     list($this->logEnable, $this->add_email) = explode(',', varset($pref['mail_log_options'], '0,0'));
     switch ($overrides['mailer']) {
         case 'smtp':
             $smtp_options = array();
             $temp_opts = explode(',', varset($pref['smtp_options'], ''));
             if (vartrue($overrides['smtp_pop3auth'])) {
                 $temp_opts[] = 'pop3auth';
             }
             // Legacy option - remove later
             if (vartrue($pref['smtp_keepalive'])) {
                 $temp_opts[] = 'keepalive';
             }
             // Legacy option - remove later
             foreach ($temp_opts as $k => $v) {
                 if (strpos($v, '=') !== FALSE) {
                     list($v, $k) = explode('=', $v, 2);
                     $smtp_options[trim($v)] = trim($k);
                 } else {
                     $smtp_options[trim($v)] = TRUE;
                     // Simple on/off option
                 }
             }
             unset($temp_opts);
             $this->IsSMTP();
             // Enable SMTP functions
             if (vartrue($smtp_options['helo'])) {
                 $this->Helo = $smtp_options['helo'];
             }
             if (isset($smtp_options['pop3auth'])) {
                 // Need POP-before-SMTP authorisation
                 require_once e_HANDLER . 'phpmailer/class.pop3.php';
                 $pop = new POP3();
                 $pop->Authorise($overrides['smtp_server'], 110, 30, $overrides['smtp_username'], $overrides['smtp_password'], 1);
             }
             $this->Mailer = 'smtp';
             $this->localUseVerp = isset($smtp_options['useVERP']);
             if (isset($smtp_options['secure'])) {
                 switch ($smtp_options['secure']) {
                     case 'TLS':
                         $this->SMTPSecure = 'tls';
                         $this->Port = 465;
                         // Can also use port 587, and maybe even 25
                         break;
                     case 'SSL':
                         $this->SMTPSecure = 'ssl';
                         $this->Port = 465;
                         break;
                     default:
                         if ($this->debug) {
                             echo "Invalid option: {$smtp_options['secure']}<br />";
                         }
                 }
             }
             $this->SMTPKeepAlive = varset($smtp_options['keepalive'], FALSE);
             // ***** Control this
             $this->Host = $overrides['smtp_server'];
             if ($overrides['smtp_username'] && $overrides['smtp_password']) {
                 $this->SMTPAuth = !isset($smtp_options['pop3auth']);
                 $this->Username = $overrides['smtp_username'];
                 $this->Password = $overrides['smtp_password'];
             }
             break;
         case 'sendmail':
             $this->Mailer = 'sendmail';
             $this->Sendmail = $overrides['sendmail'] ? $overrides['sendmail'] : '/usr/sbin/sendmail -t -i -r ' . vartrue($pref['replyto_email'], $overrides['siteadminemail']);
             break;
         case 'php':
             $this->Mailer = 'mail';
             break;
     }
     if (vartrue($pref['mail_bounce_email'])) {
         $this->Sender = $pref['mail_bounce_email'];
     }
     $this->FromName = $tp->toHTML(vartrue($pref['replyto_name'], $overrides['siteadmin']), '', 'RAWTEXT');
     $this->From = $tp->toHTML(vartrue($pref['replyto_email'], $overrides['siteadminemail']), '', 'RAWTEXT');
     $this->WordWrap = 76;
     // Set a sensible default
     $pref['mail_dkim'] = 1;
     $privatekeyfile = e_SYSTEM . 'dkim_private.key';
     if ($pref['mail_dkim'] && is_readable($privatekeyfile)) {
         $this->DKIM_domain = e_DOMAIN;
         // 'example.com';
         $this->DKIM_private = $privatekeyfile;
         $this->DKIM_selector = 'phpmailer';
         $this->DKIM_passphrase = '';
         //key is not encrypted
         $this->DKIM_identifier = $this->From;
     }
     // Now look for any overrides - slightly cumbersome way of doing it, but does give control over what can be set from here
     // Options are those accepted by the arraySet() method.
     if (!empty($overrides)) {
         foreach ($this->overrides as $key => $opt) {
             if (isset($overrides[$key])) {
                 $this->arraySet(array($opt => $overrides[$key]));
             } elseif (!empty($overrides[$opt])) {
                 $this->arraySet(array($opt => $overrides[$opt]));
             }
         }
     }
 }
Esempio n. 11
0
 public function action_setregister()
 {
     if ($this->configs["useCaptcha"] == 1 && empty($_POST["rcaptch"])) {
         echo "0::" . $this->view->getVal("l_err4");
         return;
     }
     if (!empty($_POST["rlogin"]) && !empty($_POST["rpwd"]) && !empty($_POST["rrpwd"]) && !empty($_POST["rmail"])) {
         $login = $_POST["rlogin"];
         if (!preg_match("#^[aA-zZ0-9\\-_]+\$#", $login)) {
             echo "0::" . $this->view->getVal("l_err1");
             return;
         }
         $pwd = $_POST["rpwd"];
         if (!preg_match("#^[aA-zZ0-9\\-_]+\$#", $pwd)) {
             echo "0::" . $this->view->getVal("l_err2");
             return;
         }
         $rpwd = $_POST["rrpwd"];
         if ($pwd != $rpwd) {
             echo "0::" . $this->view->getVal("l_err3");
             return;
         }
         $email = $_POST["rmail"];
         if ($this->configs["useCaptcha"] != 0) {
             $cp = $_POST["rcaptch"];
             if ($cp != $_SESSION["captcha_keystring"]) {
                 echo "0::" . $this->view->getVal("l_err4");
                 return;
             }
             unset($_SESSION["captcha_keystring"]);
         }
         if (!$this->model->checkLogin($login)) {
             echo "0::" . $this->view->getVal("l_err5");
             return;
         }
         //l_err7
         if ($this->configs["useMail"] == 0) {
             $this->model->reg($login, $pwd, $email);
             echo "1::" . $this->view->getVal("l_err6");
         } else {
             $id = $this->model->regM($login, $pwd, $email, $this->configs["defGrp"]);
             if ($id > 0) {
                 //region отсылаем почту
                 $hash = md5($id . "-=-" . $email);
                 $c_mail = Configs::readCfg("mail", tbuild);
                 require "libraries/PHPMailer/PHPMailerAutoload.php";
                 $pop = new POP3();
                 $pop->Authorise($c_mail["mailhost"], $c_mail["mailport"], $c_mail["mailtmout"], $c_mail["mailboxf"], $c_mail["mailpbf"], $c_mail["maildlvl"]);
                 $mail = new PHPMailer();
                 $mail->CharSet = "UTF-8";
                 //  $mail->IsSMTP();
                 //$mail->SMTPDebug  = $c_mail["maildlvl"];
                 $mail->Host = $c_mail["mailhost"];
                 $mail->SMTPAuth = true;
                 $mail->Username = $c_mail["mailboxf"];
                 $mail->Password = $c_mail["mailpbf"];
                 $mail->SetFrom($c_mail["mailboxf"], $c_mail["mailnamefrom"]);
                 $mail->AddReplyTo($c_mail["mailboxf"], $c_mail["mailnib"]);
                 $mail->Subject = "Register";
                 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
                 // optional, comment out and test
                 $this->view->set("hash", $hash . "_" . $id);
                 $mail->MsgHTML($this->view->out("register", "mail", 2));
                 $mail->AddAddress($email);
                 if (!$mail->Send()) {
                     $this->model->toLog("Mail error:" . $mail->ErrorInfo, "register", 13);
                 }
                 //endregion
                 echo "1::" . $this->view->getVal("l_err7");
             } else {
                 echo "0::" . $this->view->getVal("l_err5");
             }
         }
     }
 }
Esempio n. 12
0
function icmail($mail, $bet, $txt, $from = '', $html = false)
{
    global $allgAr;
    include_once 'include/includes/libs/phpmailer/class.phpmailer.php';
    $mailer = new PHPMailer();
    if (empty($from)) {
        $mailer->From = $allgAr['adminMail'];
        $mailer->FromName = $allgAr['allg_default_subject'];
    } elseif (preg_match('%(.*) <([\\w\\.-]*@[\\w\\.-]*)>%i', $from, $tmp)) {
        $mailer->From = trim($tmp[2]);
        $mailer->FromName = trim($tmp[1]);
    } elseif (preg_match('%([\\w\\.-]*@[\\w\\.-]*)%i', $from, $tmp)) {
        $mailer->From = trim($tmp[1]);
        $mailer->FromName = '';
    }
    if ($allgAr['mail_smtp']) {
        // SMTP Versand
        $smtpser = @db_result(db_query('SELECT `t1` FROM `prefix_allg` WHERE `k` = "smtpconf"'));
        if (empty($smtpser)) {
            echo '<span style="font-size: 2em; color: red;">Mailversand muss konfiguriert werden!</span><br />';
        } else {
            $smtp = unserialize($smtpser);
            $mailer->IsSMTP();
            $mailer->Host = $smtp['smtp_host'];
            $mailer->SMTPAuth = $smtp['smtp_auth'] == 'no' ? false : true;
            if ($smtp['smtp_auth'] == 'ssl' or $smtp['smtp_auth'] == 'tls') {
                $mailer->SMTPSecure = $smtp['smtp_auth'];
            }
            if (!empty($smtp['smtp_port'])) {
                $mailer->Port = $smtp['smtp_port'];
            }
            $mailer->AddReplyTo($mailer->From, $mailer->FromName);
            if ($smtp['smtp_changesubject'] and $mailer->From != $smtp['smtp_email']) {
                $bet = '(For ' . $mailer->FromName . ' - ' . $mailer->From . ') ' . $bet;
                $mailer->From = $smtp['smtp_email'];
            }
            $mailer->Username = $smtp['smtp_login'];
            require_once 'include/includes/libs/AzDGCrypt.class.inc.php';
            $cr64 = new AzDGCrypt(DBDATE . DBUSER . DBPREF);
            $mailer->Password = $cr64->decrypt($smtp['smtp_pass']);
            if ($smtp['smtp_pop3beforesmtp'] == 1) {
                include_once 'include/includes/libs/phpmailer/class.pop3.php';
                $pop = new POP3();
                $pop3port = !empty($smpt['smtp_pop3port']) ? $smpt['smtp_pop3port'] : 110;
                $pop->Authorise($smpt['smtp_pop3host'], $pop3port, 5, $mailer->Username, $mailer->Password, 1);
            }
        }
        // $mailer->SMTPDebug = true;
    }
    if (is_array($mail)) {
        if ($mail[0] == 'bcc') {
            array_shift($mail);
            foreach ($mail as $m) {
                $mailer->AddBCC(escape_for_email($m));
            }
            $mailer->AddAddress($mailer->From);
        } else {
            foreach ($mail as $m) {
                $mailer->AddAddress(escape_for_email($mail));
            }
        }
    } else {
        $mailer->AddAddress(escape_for_email($mail));
    }
    $mailer->Subject = escape_for_email($bet, true);
    $txt = str_replace("\r", "\n", str_replace("\r\n", "\n", $txt));
    if ($html) {
        $mailer->IsHTML(true);
        $mailer->AltBody = strip_tags($txt);
    }
    $mailer->Body = $txt;
    if ($mailer->Send()) {
        return true;
    } else {
        if (is_coadmin()) {
            echo "<h2 style=\"color:red;\">Mailer Error: " . $mailer->ErrorInfo . '</h2>';
        }
        return false;
    }
}
Esempio n. 13
0
function osc_sendMail($params)
{
    // DO NOT send mail if it's a demo
    if (defined('DEMO')) {
        return false;
    }
    $mail = new PHPMailer(true);
    $mail->ClearAddresses();
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();
    $mail->ClearBCCs();
    $mail->ClearCCs();
    $mail->ClearCustomHeaders();
    $mail->ClearReplyTos();
    $mail = osc_apply_filter('init_send_mail', $mail, $params);
    if (osc_mailserver_pop()) {
        require_once osc_lib_path() . 'phpmailer/class.pop3.php';
        $pop = new POP3();
        $pop3_host = osc_mailserver_host();
        if (array_key_exists('host', $params)) {
            $pop3_host = $params['host'];
        }
        $pop3_port = osc_mailserver_port();
        if (array_key_exists('port', $params)) {
            $pop3_port = $params['port'];
        }
        $pop3_username = osc_mailserver_username();
        if (array_key_exists('username', $params)) {
            $pop3_username = $params['username'];
        }
        $pop3_password = osc_mailserver_password();
        if (array_key_exists('password', $params)) {
            $pop3_password = $params['password'];
        }
        $pop->Authorise($pop3_host, $pop3_port, 30, $pop3_username, $pop3_password, 0);
    }
    if (osc_mailserver_auth()) {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
    } else {
        if (osc_mailserver_pop()) {
            $mail->IsSMTP();
        }
    }
    $smtpSecure = osc_mailserver_ssl();
    if (array_key_exists('password', $params)) {
        $smtpSecure = $params['ssl'];
    }
    if ($smtpSecure != '') {
        $mail->SMTPSecure = $smtpSecure;
    }
    $stmpUsername = osc_mailserver_username();
    if (array_key_exists('username', $params)) {
        $stmpUsername = $params['username'];
    }
    if ($stmpUsername != '') {
        $mail->Username = $stmpUsername;
    }
    $smtpPassword = osc_mailserver_password();
    if (array_key_exists('password', $params)) {
        $smtpPassword = $params['password'];
    }
    if ($smtpPassword != '') {
        $mail->Password = $smtpPassword;
    }
    $smtpHost = osc_mailserver_host();
    if (array_key_exists('host', $params)) {
        $smtpHost = $params['host'];
    }
    if ($smtpHost != '') {
        $mail->Host = $smtpHost;
    }
    $smtpPort = osc_mailserver_port();
    if (array_key_exists('port', $params)) {
        $smtpPort = $params['port'];
    }
    if ($smtpPort != '') {
        $mail->Port = $smtpPort;
    }
    $from = osc_mailserver_mail_from();
    if (empty($from)) {
        $from = 'osclass@' . osc_get_domain();
        if (array_key_exists('from', $params)) {
            $from = $params['from'];
        }
    }
    $from_name = osc_mailserver_name_from();
    if (empty($from_name)) {
        $from_name = osc_page_title();
        if (array_key_exists('from_name', $params)) {
            $from_name = $params['from_name'];
        }
    }
    $mail->From = osc_apply_filter('mail_from', $from, $params);
    $mail->FromName = osc_apply_filter('mail_from_name', $from_name, $params);
    $to = $params['to'];
    $to_name = '';
    if (array_key_exists('to_name', $params)) {
        $to_name = $params['to_name'];
    }
    if (!is_array($to)) {
        $to = array($to => $to_name);
    }
    foreach ($to as $to_email => $to_name) {
        try {
            $mail->addAddress($to_email, $to_name);
        } catch (phpmailerException $e) {
            continue;
        }
    }
    if (array_key_exists('add_bcc', $params)) {
        if (!is_array($params['add_bcc']) && $params['add_bcc'] != '') {
            $params['add_bcc'] = array($params['add_bcc']);
        }
        foreach ($params['add_bcc'] as $bcc) {
            try {
                $mail->AddBCC($bcc);
            } catch (phpmailerException $e) {
                continue;
            }
        }
    }
    if (array_key_exists('reply_to', $params)) {
        try {
            $mail->AddReplyTo($params['reply_to']);
        } catch (phpmailerException $e) {
            //continue;
        }
    }
    $mail->Subject = $params['subject'];
    $mail->Body = $params['body'];
    if (array_key_exists('attachment', $params)) {
        if (!is_array($params['attachment']) || isset($params['attachment']['path'])) {
            $params['attachment'] = array($params['attachment']);
        }
        foreach ($params['attachment'] as $attachment) {
            try {
                if (is_array($attachment)) {
                    if (isset($attachment['path']) && isset($attachment['name'])) {
                        $mail->AddAttachment($attachment['path'], $attachment['name']);
                    }
                } else {
                    $mail->AddAttachment($attachment);
                }
            } catch (phpmailerException $e) {
                continue;
            }
        }
    }
    $mail->CharSet = 'utf-8';
    $mail->IsHTML(true);
    $mail = osc_apply_filter('pre_send_mail', $mail, $params);
    // send email!
    try {
        $mail->Send();
    } catch (phpmailerException $e) {
        return false;
    }
    return true;
}
Esempio n. 14
0
 function popbeforesmtp($rcpt, $header, $body, $option = "")
 {
     $debug_level = 0;
     $pop = new POP3();
     $pop->Authorise($this->config->get('pop_address'), $this->config->get('pop_port'), $this->config->get('pop_timeout'), $this->config->get('pop_username'), $this->config->get('pop_password'), $debug_level);
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPDebug = $debug_level;
     $mail->IsHTML(false);
     $mail->Host = $this->config->get('smtp_address');
     $mail->From = $this->config->get('smtp_from');
     $mail->FromName = 'Anubis';
     $mail->Subject = $header['subject'][1];
     $mail->Body = $body;
     $mail->AddAddress($rcpt, 'Anubis User');
     if (!$mail->Send()) {
         return $mail->ErrorInfo;
     }
 }
<html>
<head>
<title>POP before SMTP Test</title>
</head>
<body>

<?php 
require_once '../class.phpmailer.php';
require_once '../class.pop3.php';
// required for POP before SMTP
$pop = new POP3();
$pop->Authorise('192.168.0.1', 110, 30, 'jason', 'ujntfv', 1);
$mail = new PHPMailer();
$body = file_get_contents('contents.html');
$body = eregi_replace("[\\]", '', $body);
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Host = '192.168.0.1';
$mail->SetFrom('*****@*****.**', 'First Last');
$mail->AddReplyTo("*****@*****.**", "First Last");
$mail->Subject = "PHPMailer Test Subject via POP before SMTP, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
// optional, comment out and test
$mail->MsgHTML($body);
$address = "*****@*****.**";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("images/phpmailer.gif");
// attachment
$mail->AddAttachment("images/phpmailer_mini.gif");
// attachment
if (!$mail->Send()) {
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     if ($event == 'backend_sendmail') {
         # Load phpmailer
         substr(PHP_VERSION, 0, 1) > 4 ? include_once 'php5/class.phpmailer.php' : (include_once 'php4/class.phpmailer.php');
         # Login to POP3 Server if Auth is "POP3 before SMTP"
         if ($this->get_config('smtpmail_auth') == 1) {
             substr(PHP_VERSION, 0, 1) > 4 ? include_once 'php5/class.pop3.php' : (include_once 'php4/class.pop3.php');
             $pop = new POP3();
             $pop->Authorise($this->get_config('smtpmail_pop3_server'), $this->get_config('smtpmail_pop3_port'), false, $this->get_config('smtpmail_user'), $this->get_config('smtpmail_passwd'), 0);
         }
         $mail = new PHPMailer();
         $mail->IsSMTP();
         # Activate Auth if Auth is "SMTP AUTH"
         if ($this->get_config('smtpmail_auth') == 2) {
             $mail->SMTPAuth = true;
             if ($this->get_config('smtpmail_auth') != 0) {
                 $mail->SMTPSecure = $this->get_config('smtpmail_secure');
             }
             $mail->Username = $this->get_config('smtpmail_user');
             $mail->Password = $this->get_config('smtpmail_passwd');
         }
         $mail->IsHTML(false);
         $mail->Host = $this->get_config('smtpmail_smtp_server');
         $mail->Port = $this->get_config('smtpmail_smtp_port');
         $mail->From = $eventData['fromMail'];
         $mail->FromName = $eventData['fromName'];
         $mail->Subject = $eventData['subject'];
         $mail->Body = $eventData['message'];
         $mail->CharSet = LANG_CHARSET;
         if (strpos($eventData['to'], '<') === false || strpos($eventData['to'], '>') === false) {
             $mail->AddAddress($eventData['to']);
         } else {
             preg_match('/^(.)+ <(.)+>$/', $eventData['to'], $splited_mail);
             $mail->AddAddress($splited_mail[2], $splited_mail[1]);
         }
         $eventData['skip_native'] = true;
         return $mail->send();
     } else {
         return false;
     }
 }