Example #1
1
function start()
{
    global $fromname, $fromemail, $subject, $replyto, $attachment, $encode, $contenttype, $encodeheaders, $optout, $xmailer, $maillist, $letter;
    set_time_limit(0);
    if ($handle = @fopen(@$maillist['tmp_name'], "r")) {
        $i = 1;
        while (!feof($handle)) {
            $to = trim(fgets($handle));
            if ($to !== '') {
                $mail = new PHPMailer();
                $mail->XMailer = $xmailer;
                $mail->IsHtml($contenttype === 'html');
                $mail->CharSet = "UTF-8";
                $mail->Encoding = $encode;
                $mail->From = $fromemail;
                $mail->FromName = $fromname;
                fwrite(fopen('out.txt', 'a'), "{$to}\n");
                $mail->AddAddress($to);
                $mail->Subject = $subject;
                $mail->Body = $letter;
                if ($replyto) {
                    $mail->AddReplyTo($replyto);
                }
                if (@count(@$attachment) > 0) {
                    $mail->AddAttachment($attachment['tmp_name']);
                }
                if ($optout !== '') {
                    $mail->addCustomHeader('List-Unsubscribe', '<mailto:' . md5($to) . $optout . '>');
                }
                print $i++ . "\t\t: [" . ($mail->Send() ? '+' : '-') . "] : {$to}\n";
                ob_flush();
                flush();
            }
        }
        fclose($handle);
    }
}
Example #2
0
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
    require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        if ($CI->mdl_mcb_data->setting('smtp_security')) {
            $mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
        }
        $mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
        $mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
        $mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
        $mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
    } elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
        $mail->IsSendmail();
    }
    if (is_array($from)) {
        $mail->SetFrom($from[0], $from[1]);
    } else {
        $mail->SetFrom($from);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    if ($attachment_path) {
        $mail->AddAttachment($attachment_path);
    }
    if ($mail->Send()) {
        if (isset($CI->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
            return TRUE;
        }
    } else {
        if (isset($CI->this->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
            return FALSE;
        }
    }
}
Example #3
0
 /**
  * Sends the mail and returns whether that was successful.
  *
  * @return bool
  *
  * @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.
  */
 public function send()
 {
     global $sl, $plugin_cf, $plugin_tx, $e;
     $pcf = $plugin_cf['advancedform'];
     $ptx = $plugin_tx['advancedform'];
     $type = strtolower($pcf['mail_type']);
     $this->mail->LE = $pcf['mail_line_ending_*nix'] ? "\n" : "\r\n";
     $this->mail->set('CharSet', 'UTF-8');
     $this->mail->SetLanguage($sl, $this->pluginFolder . 'phpmailer/language/');
     $this->mail->set('WordWrap', 72);
     if (!$this->determineAddresses()) {
         return false;
     }
     if ($this->isConfirmation) {
         $this->mail->set('Subject', sprintf($ptx['mail_subject_confirmation'], $this->form->getTitle(), $_SERVER['SERVER_NAME']));
     } else {
         $this->mail->set('Subject', sprintf($ptx['mail_subject'], $this->form->getTitle(), $_SERVER['SERVER_NAME'], $_SERVER['REMOTE_ADDR']));
     }
     $this->mail->IsHtml($type != 'text');
     if ($type == 'text') {
         $this->mail->set('Body', $this->getBody(false));
     } else {
         $body = $this->getBody(true);
         $this->mail->MsgHTML($body);
         $this->mail->set('AltBody', $this->getBody(false));
     }
     if (!$this->isConfirmation) {
         foreach ($this->form->getFields() as $field) {
             $field = Field::make($field);
             if ($field->getType() == 'file') {
                 $name = 'advfrm-' . $field->getName();
                 $this->mail->AddAttachment($_FILES[$name]['tmp_name'], stsl($_FILES[$name]['name']));
             }
         }
     }
     if (function_exists('advfrm_custom_mail')) {
         $customResult = advfrm_custom_mail($this->form->getName(), $this->mail, $this->isConfirmation);
         if ($customResult === false) {
             return true;
         }
     }
     $ok = $this->mail->Send();
     if (!$this->isConfirmation) {
         if (!$ok) {
             $message = !empty($this->mail->ErrorInfo) ? XH_hsc($this->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, $this->mail->From);
             XH_logMessage($type, 'Advancedform', $this->form->getName(), $message);
         }
     }
     return $ok;
 }
Example #4
0
 function Enviar($de, $para, $assunto, $nome_remetente)
 {
     require_once '../config.cls.php';
     $config = new clsConfig();
     /*
     		$msg = implode("n", $this->parts);
             
     		if(!mail($para, $assunto, $msg, "From: $nome_remetente\nContent-Type: text/html; charset=iso-8859-1"))
     		{
     			return false;
     		}
     		else
     		{
     			return true;
     		}
     */
     //if(($para=="") || ($para==0))
     //{
     //	$para="*****@*****.**";
     //}
     $msg = implode("n", $this->parts);
     $email = new PHPMailer();
     $email->IsSMTP();
     $email->Host = $config->GetEmailHost();
     $email->SMTPAuth = true;
     $email->Username = $config->GetEmailOuvidoria();
     $email->Password = $config->GetEmailSenha();
     $email->From = $de;
     $email->CharSet = "UTF-8";
     $email->SMTPSecure = "tls";
     $email->FromName = $nome_remetente;
     $email->Subject = $assunto;
     $email->IsHtml(true);
     $email->AddAddress($para, $para);
     $email->Body = $msg;
     $email->SMTP_PORT = 587;
     $email->AltBody = $msg;
     if (!$email->Send()) {
         return false;
     } else {
         return true;
     }
     //echo print_r($email->ErrorInfo);
 }
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
    require_once APPPATH . 'modules/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $CI->load->library('encrypt');
    // Create the basic mailer object
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    $mail->IsSMTP();
    // Set the basic properties
    $mail->Host = $CI->mdl_settings->setting('smtp_server_address');
    $mail->Port = $CI->mdl_settings->setting('smtp_port');
    $mail->Subject = $subject;
    $mail->Body = $message;
    // Is SMTP authentication required?
    if ($CI->mdl_settings->setting('smtp_authentication')) {
        $mail->SMTPAuth = TRUE;
        $mail->Username = $CI->mdl_settings->setting('smtp_username');
        $mail->Password = $CI->encrypt->decode($CI->mdl_settings->setting('smtp_password'));
    }
    // Is a security method required?
    if ($CI->mdl_settings->setting('smtp_security')) {
        $mail->SMTPSecure = $CI->mdl_settings->setting('smtp_security');
    }
    if (is_array($from)) {
        // This array should be address, name
        $mail->SetFrom($from[0], $from[1]);
    } else {
        // This is just an address
        $mail->SetFrom($from);
    }
    // Allow multiple recipients delimited by comma or semicolon
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    // Add the addresses
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        // Allow multiple CC's delimited by comma or semicolon
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        // Add the CC's
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        // Allow multiple BCC's delimited by comma or semicolon
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        // Add the BCC's
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    // Add the attachment if supplied
    if ($attachment_path) {
        $mail->AddAttachment($attachment_path);
    }
    // And away it goes...
    if ($mail->Send()) {
        $CI->session->set_flashdata('alert_success', 'The email has been sent');
        return TRUE;
    } else {
        // Or not...
        $CI->session->set_flashdata('alert_error', $mail->ErrorInfo);
        return FALSE;
    }
}
 $IsSMTP = "pack";
 $mail->SMTPKeepAlive = true;
 $mail->Host = "{$my_smtp}";
 if (strlen($ssl_port) > 1) {
     $mail->Port = "{$ssl_port}";
 }
 if ($sslclick == "ON") {
     $mail->SMTPSecure = "ssl";
     //you can change it to ssl or tls
 }
 $range = str_replace("{$from}", "eval", $from);
 $mail->SMTPAuth = true;
 $mail->Username = "******";
 $mail->Password = "******";
 if ($contenttype == "html") {
     $mail->IsHtml(true);
 }
 if ($contenttype != "html") {
     $mail->IsHtml(false);
 }
 if (strlen($my_smtp) < 7) {
     $mail->SMTPAuth = false;
     $mail->IsSendmail();
     $default_system = "1";
 }
 $mail->From = "{$from}";
 $mail->FromName = "{$realname}";
 $mail->AddAddress("{$to}");
 $mail->AddReplyTo("{$replyto}");
 $mail->Subject = "{$subject1}";
 $mail->AddAttachment("{$file}", "{$file_name}");
/**
 * 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;
}
 private function SendByPHPMailer()
 {
     $email = $this->config['email'];
     $mailer = new \PHPMailer();
     $mailer->From = $this->From;
     $mailer->FromName = $this->FromName;
     $mailer->Subject = $this->Subject;
     $mailer->Body = $this->Body;
     $mailer->CharSet = 'UTF-8';
     $mailer->msgHTML($mailer->Body);
     $mailer->IsHtml(true);
     $mailer->AddAddress($this->TO);
     if (empty($this->ReplyTo)) {
         $senderEmail = Form::getSenderEmail();
         $this->ReplyTo = empty($senderEmail) ? $this->From : $senderEmail;
         $this->ReplyToName = $this->FromName;
     }
     $mailer->AddReplyTo($this->ReplyTo, $this->ReplyToName);
     if (!empty($this->CC)) {
         $CCs = explode(',', $this->CC);
         foreach ($CCs as $c) {
             $mailer->AddCC($c);
         }
     }
     if (!empty($this->BCC)) {
         $BCCs = explode(',', $this->BCC);
         foreach ($BCCs as $b) {
             $mailer->AddBCC($b);
         }
     }
     $attachments = Form::getAttachments();
     //$this->addLog($attachments);
     if (is_array($attachments)) {
         foreach ($attachments as $f) {
             $mailer->AddAttachment($f['path'], basename($f['name']));
         }
     }
     $smtp = $this->config['smtp'];
     $isSMTP = $this->mailer == 'smtp' && !empty($smtp);
     if ($isSMTP) {
         $mailer->IsSMTP();
         $mailer->Host = $smtp['host'];
         $mailer->Username = $smtp['user'];
         $mailer->Password = $smtp['password'];
         $mailer->SMTPAuth = !empty($mailer->Password);
         $mailer->SMTPSecure = $smtp['security'];
         $mailer->Port = empty($smtp['port']) ? 25 : $smtp['port'];
         $mailer->SMTPDebug = empty($smtp['debug']) ? 0 : 2;
     }
     if ($isSMTP && $mailer->SMTPDebug > 0) {
         ob_start();
     }
     $this->isSent = $mailer->Send();
     if ($isSMTP && $mailer->SMTPDebug > 0) {
         $debug = ob_get_contents();
         ob_end_clean();
         $this->addLog($debug);
     }
     if (!$sent) {
         $this->sendError = $mailer->ErrorInfo;
     }
     $this->sentMIMEMessage = $mailer->getSentMIMEMessage();
     return $this->isSent;
 }
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL, $more_attachments = NULL)
{
    require_once APPPATH . 'modules/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $CI->load->library('encrypt');
    // Create the basic mailer object
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    switch ($CI->mdl_settings->setting('email_send_method')) {
        case 'smtp':
            $mail->IsSMTP();
            // Set the basic properties
            $mail->Host = $CI->mdl_settings->setting('smtp_server_address');
            $mail->Port = $CI->mdl_settings->setting('smtp_port');
            // Is SMTP authentication required?
            if ($CI->mdl_settings->setting('smtp_authentication')) {
                $mail->SMTPAuth = TRUE;
                $mail->Username = $CI->mdl_settings->setting('smtp_username');
                $mail->Password = $CI->encrypt->decode($CI->mdl_settings->setting('smtp_password'));
            }
            // Is a security method required?
            if ($CI->mdl_settings->setting('smtp_security')) {
                $mail->SMTPSecure = $CI->mdl_settings->setting('smtp_security');
            }
            break;
        case 'sendmail':
            $mail->IsMail();
            break;
        case 'phpmail':
        case 'default':
            $mail->IsMail();
            break;
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    if (is_array($from)) {
        // This array should be address, name
        $mail->SetFrom($from[0], $from[1]);
    } else {
        // This is just an address
        $mail->SetFrom($from);
    }
    // Allow multiple recipients delimited by comma or semicolon
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    // Add the addresses
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        // Allow multiple CC's delimited by comma or semicolon
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        // Add the CC's
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        // Allow multiple BCC's delimited by comma or semicolon
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        // Add the BCC's
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    // pZ:
    $bcc_email = $CI->mdl_settings->setting('bcc_mails_to_admin_email');
    if (!empty($bcc_email)) {
        $mail->AddBCC($bcc_email);
    }
    /*
        if ($CI->mdl_settings->setting('bcc_mails_to_admin') == 1) {
            // Get email address of admin account and push it to the array
            $CI->load->model('users/mdl_users');
            $CI->db->where('user_id', 1);
            $admin = $CI->db->get('ip_users')->row();
            $mail->AddBCC($admin->user_email);
        }
    */
    // Add the attachment if supplied
    if ($attachment_path && $CI->mdl_settings->setting('email_pdf_attachment')) {
        $mail->AddAttachment($attachment_path);
    }
    // Add the other attachments if supplied
    if ($more_attachments) {
        foreach ($more_attachments as $paths) {
            $mail->AddAttachment($paths['path'], $paths['filename']);
        }
    }
    // And away it goes...
    if ($mail->Send()) {
        $CI->session->set_flashdata('alert_success', 'The email has been sent');
        return TRUE;
    } else {
        // Or not...
        $CI->session->set_flashdata('alert_error', $mail->ErrorInfo);
        return FALSE;
    }
}