function send($address_to, $subject, $htmlcontent, $plaincontent, $attachment)
 {
     global $admin_name, $admin_email;
     $PHPMailer = new PHPMailer();
     $PHPMailer->From = $admin_email;
     $PHPMailer->FromName = $admin_name;
     $PHPMailer->ClearAllRecipients();
     $PHPMailer->AddAddress($address_to);
     $PHPMailer->Subject = $subject;
     $PHPMailer->Body = $htmlcontent;
     $PHPMailer->AltBody = $plaincontent;
     $PHPMailer->IsHTML(true);
     while (list($k, $v) = each($attachment)) {
         $PHPMailer->AddAttachment($v['file'], $v['nickname']);
     }
     $status = @$PHPMailer->Send();
     $PHPMailer->ClearAddresses();
     $PHPMailer->ClearAttachments();
     return $status;
 }
Example #2
0
 /**
  * Clears out all previously specified values for this object and restores
  * it to the state it was in when it was instantiated.
  *
  * @return Email
  */
 public function Clear()
 {
     $this->PhpMailer->ClearAllRecipients();
     $this->PhpMailer->Body = '';
     $this->From();
     $this->_IsToSet = FALSE;
     $this->MimeType(Gdn::Config('Garden.Email.MimeType', 'text/plain'));
     $this->_MasterView = 'email.master';
     return $this;
 }
Example #3
0
function sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message, $type = "plain", $cc = "", $bcc = "")
{
    global $settings, $locale;
    require_once INCLUDES . "class.phpmailer.php";
    $mail = new PHPMailer();
    if (file_exists(INCLUDES . "language/phpmailer.lang-" . $locale['phpmailer'] . ".php")) {
        $mail->SetLanguage($locale['phpmailer'], INCLUDES . "language/");
    } else {
        $mail->SetLanguage("en", INCLUDES . "language/");
    }
    if (!$settings['smtp_host']) {
        $mail->IsMAIL();
    } else {
        $mail->IsSMTP();
        $mail->Host = $settings['smtp_host'];
        $mail->Port = $settings['smtp_port'];
        $mail->SMTPAuth = $settings['smtp_auth'] ? true : false;
        $mail->Username = $settings['smtp_username'];
        $mail->Password = $settings['smtp_password'];
    }
    $mail->CharSet = $locale['charset'];
    $mail->From = $fromemail;
    $mail->FromName = $fromname;
    $mail->AddAddress($toemail, $toname);
    $mail->AddReplyTo($fromemail, $fromname);
    if ($cc) {
        $cc = explode(", ", $cc);
        foreach ($cc as $ccaddress) {
            $mail->AddCC($ccaddress);
        }
    }
    if ($bcc) {
        $bcc = explode(", ", $bcc);
        foreach ($bcc as $bccaddress) {
            $mail->AddBCC($bccaddress);
        }
    }
    if ($type == "plain") {
        $mail->IsHTML(false);
    } else {
        $mail->IsHTML(true);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    if (!$mail->Send()) {
        $mail->ErrorInfo;
        $mail->ClearAllRecipients();
        $mail->ClearReplyTos();
        return false;
    } else {
        $mail->ClearAllRecipients();
        $mail->ClearReplyTos();
        return true;
    }
}
 /**
  * Short description of method send
  *
  * @access public
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return int
  */
 public function send()
 {
     $returnValue = (int) 0;
     foreach ($this->messages as $message) {
         if ($message instanceof tao_helpers_transfert_Message) {
             $this->mailer->SetFrom($message->getFrom());
             $this->mailer->AddReplyTo($message->getFrom());
             $this->mailer->Subject = $message->getTitle();
             $this->mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody()));
             $this->mailer->MsgHTML($message->getBody());
             $this->mailer->AddAddress($message->getTo());
             try {
                 if ($this->mailer->Send()) {
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_SENT);
                     $returnValue++;
                 }
                 if ($this->mailer->IsError()) {
                     if (DEBUG_MODE) {
                         echo $this->mailer->ErrorInfo . "<br>";
                     }
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_ERROR);
                 }
             } catch (phpmailerException $pe) {
                 if (DEBUG_MODE) {
                     print $pe;
                 }
             }
         }
         $this->mailer->ClearReplyTos();
         $this->mailer->ClearAllRecipients();
     }
     $this->mailer->SmtpClose();
     return (int) $returnValue;
 }
Example #5
0
 public function enviar($para = array())
 {
     if (count($para) == 0) {
         $para = $this->para;
     }
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = "a2plcpnl0171.prod.iad2.secureserver.net";
     $mail->SMTPSecure = 'ssl';
     $mail->SMTPAuth = true;
     $mail->Port = 465;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->From = $this->de;
     $mail->Sender = $this->de;
     $mail->FromName = $this->nome;
     foreach ($para as $p) {
         $mail->AddAddress($p);
     }
     $mail->IsHTML(true);
     $mail->Subject = $this->assunto;
     $mail->Body = $this->conteudo;
     @$mail->Send();
     $mail->ClearAllRecipients();
     $mail->ClearAttachments();
 }
Example #6
0
 /**
  * Inner mailer initialization from set variables
  *
  * @return void
  */
 protected function initMailFromSet()
 {
     $this->mail->SetLanguage($this->get('langLocale'), $this->get('langPath'));
     $this->mail->CharSet = $this->get('charset');
     $this->mail->From = $this->get('from');
     $this->mail->FromName = $this->get('from');
     $this->mail->Sender = $this->get('from');
     $this->mail->ClearAllRecipients();
     $this->mail->ClearAttachments();
     $this->mail->ClearCustomHeaders();
     $emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
     foreach ($emails as $email) {
         $this->mail->AddAddress($email);
     }
     $this->mail->Subject = $this->get('subject');
     $this->mail->AltBody = $this->createAltBody($this->get('body'));
     $this->mail->Body = $this->get('body');
     // add custom headers
     foreach ($this->get('customHeaders') as $header) {
         $this->mail->AddCustomHeader($header);
     }
     if (is_array($this->get('images'))) {
         foreach ($this->get('images') as $image) {
             // Append to $attachment array
             $this->mail->AddEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
         }
     }
 }
Example #7
0
 /**
  * Test BCC-only addressing
  */
 function test_BCCAddressing()
 {
     $this->Mail->Subject .= ': BCC-only addressing';
     $this->BuildBody();
     $this->Mail->ClearAllRecipients();
     $this->assertTrue($this->Mail->AddBCC('*****@*****.**'), 'BCC addressing failed');
     $this->assertTrue($this->Mail->Send(), 'Send failed');
 }
Example #8
0
 public function Send(IEmailMessage $emailMessage)
 {
     $this->phpMailer->ClearAllRecipients();
     $this->phpMailer->ClearReplyTos();
     $this->phpMailer->CharSet = $emailMessage->Charset();
     $this->phpMailer->Subject = $emailMessage->Subject();
     $this->phpMailer->Body = $emailMessage->Body();
     $from = $emailMessage->From();
     $defaultFrom = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_ADDRESS);
     $defaultName = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_NAME);
     $address = empty($defaultFrom) ? $from->Address() : $defaultFrom;
     $name = empty($defaultName) ? $from->Name() : $defaultName;
     $this->phpMailer->SetFrom($address, $name);
     $replyTo = $emailMessage->ReplyTo();
     $this->phpMailer->AddReplyTo($replyTo->Address(), $replyTo->Name());
     $to = $this->ensureArray($emailMessage->To());
     $toAddresses = new StringBuilder();
     foreach ($to as $address) {
         $toAddresses->Append($address->Address());
         $this->phpMailer->AddAddress($address->Address(), $address->Name());
     }
     $cc = $this->ensureArray($emailMessage->CC());
     foreach ($cc as $address) {
         $this->phpMailer->AddCC($address->Address(), $address->Name());
     }
     $bcc = $this->ensureArray($emailMessage->BCC());
     foreach ($bcc as $address) {
         $this->phpMailer->AddBCC($address->Address(), $address->Name());
     }
     if ($emailMessage->HasStringAttachment()) {
         Log::Debug('Adding email attachment %s', $emailMessage->AttachmentFileName());
         $this->phpMailer->AddStringAttachment($emailMessage->AttachmentContents(), $emailMessage->AttachmentFileName());
     }
     Log::Debug('Sending %s email to: %s from: %s', get_class($emailMessage), $toAddresses->ToString(), $from->Address());
     $success = false;
     try {
         $success = $this->phpMailer->Send();
     } catch (Exception $ex) {
         Log::Error('Failed sending email. Exception: %s', $ex);
     }
     Log::Debug('Email send success: %d. %s', $success, $this->phpMailer->ErrorInfo);
 }
Example #9
0
    public function index()
    {
        $this->toView['title'] = 'Email teste';
        $this->loadLib('phpmailer');
        $mail = new PHPMailer();
        //Define os dados do servidor e tipo de conexão
        $mail->IsSMTP();
        // Define que a mensagem será SMTP
        $mail->Host = "webmail.grupomaggi.com.br";
        // Endereço do servidor SMTP
        $mail->Port = 25;
        $mail->SMTPAuth = true;
        // Autenticação
        $mail->Username = '******';
        // Usuário do servidor SMTP
        $mail->Password = '******';
        // Senha da caixa postal utilizada
        //Define o remetente
        $mail->From = "*****@*****.**";
        $mail->FromName = "Alteração no estado de um link";
        //Define os destinatário(s)
        $mail->AddAddress('*****@*****.**', 'Nome do Destinatário');
        //$mail->AddAddress('*****@*****.**');
        //$mail->AddCC('*****@*****.**', 'Copia');
        //$mail->AddBCC('*****@*****.**', 'Copia Oculta');
        //Define os dados técnicos da Mensagem
        $mail->IsHTML(true);
        // Define que o e-mail será enviado como HTML
        $mail->CharSet = 'UTF-8';
        // Charset da mensagem (opcional)
        //Texto e Assunto
        $mail->Subject = "Mensagem Teste";
        // Assunto da mensagem
        $mail->Body = 'Este é o corpo da mensagem de teste, em HTML! 
		<IMG src="http://seudominio.com.br/imagem.jpg" alt=5":)"   class="wp-smiley"> ';
        $mail->AltBody = 'Este é o corpo da mensagem de teste, em Texto Plano! \\r\\n 
		<IMG src="http://seudominio.com.br/imagem.jpg" alt=5":)"  class="wp-smiley"> ';
        //Anexos (opcional)
        //$mail->AddAttachment("e:\home\login\web\documento.pdf", "novo_nome.pdf");
        //Envio da Mensagem
        $enviado = $mail->Send();
        //Limpa os destinatários e os anexos
        $mail->ClearAllRecipients();
        $mail->ClearAttachments();
        //Exibe uma mensagem de resultado
        if ($enviado) {
            echo "E-mail enviado com sucesso!";
        } else {
            echo "Não foi possível enviar o e-mail.\n\t\t \n\t\t";
            echo "Informações do erro: \n\t\t" . $mail->ErrorInfo;
        }
        //$this->loadView('viewDashboard');
    }
Example #10
0
 /**
  * Test error handling
  */
 function test_Error()
 {
     $this->Mail->Subject .= ": This should be sent";
     $this->BuildBody();
     $this->Mail->ClearAllRecipients();
     // no addresses should cause an error
     $this->assertTrue($this->Mail->IsError() == false, "Error found");
     $this->assertTrue($this->Mail->Send() == false, "Send succeeded");
     $this->assertTrue($this->Mail->IsError(), "No error found");
     $this->assertEquals('You must provide at least one recipient email address.', $this->Mail->ErrorInfo);
     $this->Mail->AddAddress($_REQUEST['mail_to']);
     $this->assertTrue($this->Mail->Send(), "Send failed");
 }
Example #11
0
 public function enviar($para, $assunto, $html, $variaveis = "")
 {
     if ($_SERVER['SERVER_NAME'] == 'localhost') {
         return true;
     } else {
         require_once "PHPMailer/class.phpmailer.php";
         $mail = new PHPMailer();
         //$mail->IsSMTP(); // Define que a mensagem será SMTP
         //$mail->Host = "smtp.dominio.net"; // Endereço do servidor SMTP
         //$mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional)
         //$mail->Username = '******'; // Usuário do servidor SMTP
         //$mail->Password = '******'; // Senha do servidor SMTP
         // Define o remetente
         $mail->From = "*****@*****.**";
         // Seu e-mail
         $mail->FromName = "Ipanema Eventos";
         // Seu nome
         // Define os destinatário(s)
         $mail->AddAddress($para);
         //$mail->AddAddress('*****@*****.**');
         //$mail->AddCC('*****@*****.**', 'Ciclano'); // Copia
         //$mail->AddBCC('*****@*****.**', 'Fulano da Silva'); // Cópia Oculta
         $mail->IsHTML(true);
         $mail->Subject = $assunto;
         $mail->CharSet = 'UTF-8';
         if (file_exists(PATHEMAIL . $html)) {
             $corpo = file_get_contents(PATHEMAIL . $html);
             // substitui variaveis
             if (is_array($variaveis)) {
                 foreach ($variaveis as $nomeVar => $valorVar) {
                     $corpo = str_replace("\${$nomeVar}", $valorVar, $corpo);
                 }
             }
         } else {
             return false;
         }
         $mail->Body = $corpo;
         // Envia o e-mail
         $enviado = $mail->Send();
         // Limpa os destinatários e os anexos
         $mail->ClearAllRecipients();
         $mail->ClearAttachments();
         // Exibe uma mensagem de resultado
         if ($enviado) {
             return true;
         } else {
             //$mail->ErrorInfo;
             return false;
         }
     }
 }
Example #12
0
 public function send($report)
 {
     //если отправлять некуда или незачем, то делаем вид, что отправили
     if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
         return true;
     } elseif (empty($report)) {
         return false;
     }
     $this->mail->IsHTML($this->getCFGDef('isHtml', 1));
     $this->mail->From = $this->getCFGDef('from', $this->modx->config['site_name']);
     $this->mail->FromName = $this->getCFGDef('fromName', $this->modx->config['emailsender']);
     $this->mail->Subject = $this->getCFGDef('subject');
     $this->mail->Body = $report;
     $this->addAddressToMailer("replyTo", $this->getCFGDef('replyTo'));
     $this->addAddressToMailer("to", $this->getCFGDef('to'));
     $this->addAddressToMailer("cc", $this->getCFGDef('cc'));
     $this->addAddressToMailer("bcc", $this->getCFGDef('bcc'));
     $result = $this->mail->send();
     if ($result) {
         $this->mail->ClearAllRecipients();
         $this->mail->ClearAttachments();
     }
     return $result;
 }
function sendMail($toMail, $toName, $subject, $textContent, $fromMail, $fromName, $html = 1, $mailcc = '')
{
    //require_once "class.phpmailer.php";
    //require_once "class.smtp.php";
    require_once "class.phpmailer.php";
    require_once "class.smtp.php";
    $sendMail = $toMail;
    $sendName = $toName;
    $mailSubject = $subject;
    $mail = new PHPMailer();
    $mail->Subject = $mailSubject;
    $mail->From = $fromMail;
    $mail->FromName = $fromName;
    $mail->Body = $textContent;
    if ($mailcc != '') {
        $mail->AddCC($mailcc);
    }
    if ($html == 1) {
        $mail->isHTML(true);
    }
    if (preg_match("/,/i", $sendMail)) {
        $arr = explode(",", $sendMail);
    } else {
        $arr[0] = $sendMail;
    }
    foreach ($arr as $val) {
        if (preg_match("/@/i", $val)) {
            $name = $val;
            $mail->AddAddress($val, $sendName);
            //$mail->AddBCC("*****@*****.**", "Debopam");
            $mail->AddReplyTo($fromMail, $fromName);
            if (!$mail->Send()) {
                $flag = 0;
                echo "Message was not sent <p>";
                echo "Mailer Error: " . $mail->ErrorInfo;
                exit;
            } else {
                $flag = 1;
            }
            $mail->ClearAllRecipients();
        }
    }
    if ($flag == 1) {
        return true;
    } else {
        return false;
    }
}
Example #14
0
    /**
     * Test error handling
     */
    function test_Error()
    {
        $this->Mail->Subject .= ": This should be sent";
        $this->BuildBody();
        $this->Mail->ClearAllRecipients(); // no addresses should cause an error
        $this->assertTrue($this->Mail->IsError() == false, "Error found");
        $this->assertTrue($this->Mail->Send() == false, "Send succeeded");
        $this->assertTrue($this->Mail->IsError(), "No error found");
        $this->assertEquals('You must provide at least one recipient email address.', $this->Mail->ErrorInfo);

	    if(!isset($_REQUEST['mail_to'])){
		    $this->markTestSkipped('Skipping re-send after removing addresses, no address requested.');
		    return;
	    }
        $this->Mail->AddAddress($_REQUEST['mail_to']);
        $this->assertTrue($this->Mail->Send(), "Send failed");
    }
Example #15
0
function envia($from, $fromName, $to, $sub, $message, $anexo = false, $anexos = '')
{
    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPDebug = 0;
    $mail->Debugoutput = 'html';
    /** Acessos para envio do email **/
    $mail->Host = SMTP;
    $mail->Port = PORTA;
    $mail->SMTPAuth = true;
    $mail->Username = USER_EMAIL;
    //'*****@*****.**';
    $mail->Password = PASS_EMAIL;
    //barbarulo.vini
    /** Detalhes do email **/
    $mail->CharSet = 'UTF-8';
    $mail->setFrom($from, $fromName);
    $mail->addReplyTo($from, $fromName);
    $mail->addAddress($to);
    $mail->Subject = $sub;
    $mail->msgHTML($message);
    $mail->AltBody = $message;
    #$mail->addBcc = $message;
    /** Verifica a existencia de anexos **/
    if ($anexo === true) {
        //$caminho_anexo = '';
        //copy($anexos['tmp_name'], $caminho_anexo.$anexos['name']);
        //$mail->AddAttachment($caminho_anexo.$anexos['name']) or die('Erro ao anexar '.$anexos['name']);
        $mail->AddAttachment($anexos);
    }
    /** Envia a mensagem **/
    if (!$mail->send()) {
        return $mail->ErrorInfo;
    } else {
        $mail->ClearAllRecipients();
        $mail->ClearAttachments();
        /** Limpa os anexos caso exista **/
        //	if($anexo === true){
        //		unlink($caminho_anexo.$anexos['name']);
        //	}
        return true;
    }
}
Example #16
0
 public static function send($title, $message, $to, $name = false, $extramails = false)
 {
     $mail = new PHPMailer();
     if (MAIL_USE_SMTP) {
         $mail->IsSMTP();
         $mail->SMTPAuth = MAIL_SMTP_AUTH;
         $mail->SMTPSecure = MAIL_SMTP_SECURE;
         $mail->Host = MAIL_SMTP_HOST;
         $mail->Port = MAIL_SMTP_PORT;
         $mail->Username = MAIL_SMTP_USER;
         $mail->Password = MAIL_SMTP_PASS;
     }
     $mail->AddReplyTo(MAIL_REPLYTO_EMAIL, MAIL_REPLYTO_NAME);
     if (is_array($to)) {
         if (!@is_array($to[0])) {
             $mail->AddAddress($to[0], $to[1]);
         }
     } else {
         if (!$name) {
             $name = $to;
         }
         $mail->AddAddress($to, $name);
     }
     $mail->SetFrom(MAIL_FROM_EMAIL, MAIL_FROM_NAME);
     if (MAIL_IS_HTML) {
         $mail->IsHTML(true);
     }
     $mail->Subject = utf8_decode($title);
     $mail->AltBody = MAIL_ALT_BODY;
     $mail->Body = $message;
     $result = $mail->Send();
     $mail->ClearAllRecipients();
     $mail->ClearAttachments();
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
function sendMailReportError($assunto, $corpo, $destinatarios = array(0 => array("nome" => "", "email" => "")), $form_data = array())
{
    if (is_array($form_data)) {
        extract($form_data);
        foreach ($form_data as $var => $value) {
            ${"{$var}"} = @utf8_decode(${"{$var}"});
        }
    }
    unset($form_data);
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "mail.hageerp.com.br";
    $mail->SMTPAuth = true;
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->Port = 587;
    $mail->From = '*****@*****.**';
    $mail->Sender = "*****@*****.**";
    $mail->FromName = 'HageERP';
    foreach ($destinatarios as $var => $value) {
        $mail->AddAddress($value['email'], $value['nome']);
    }
    $mail->IsHTML(true);
    ob_start();
    include "email_templates/" . $corpo;
    $body = ob_get_contents();
    ob_end_clean();
    $mail->Subject = utf8_decode($assunto);
    $mail->Body = utf8_decode($body);
    $enviado = $mail->Send();
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();
    if ($enviado) {
        return true;
    } else {
        return false;
    }
}
function dbem_send_mail($subject = "no title", $body = "No message specified", $receiver = '')
{
    global $smtpsettings, $phpmailer, $cformsSettings;
    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';
    }
    $mail = new PHPMailer();
    $mail->ClearAllRecipients();
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    $mail->CharSet = 'utf-8';
    $mail->SetLanguage('en', dirname(__FILE__) . '/');
    $mail->PluginDir = dirname(__FILE__) . '/';
    get_option('dbem_rsvp_mail_send_method') == 'qmail' ? $mail->IsQmail() : ($mail->Mailer = get_option('dbem_rsvp_mail_send_method'));
    $mail->Host = get_option('dbem_smtp_host');
    $mail->port = get_option('dbem_rsvp_mail_port');
    if (get_option('dbem_rsvp_mail_SMTPAuth') == '1') {
        $mail->SMTPAuth = TRUE;
    }
    $mail->Username = get_option('dbem_smtp_username');
    $mail->Password = get_option('dbem_smtp_password');
    $mail->From = get_option('dbem_mail_sender_address');
    //$mail->SMTPDebug = true;
    $mail->FromName = get_option('dbem_mail_sender_name');
    // This is the from name in the email, you can put anything you like here
    $mail->Body = $body;
    $mail->Subject = $subject;
    $mail->AddAddress($receiver);
    if (!$mail->Send()) {
        echo "Message was not sent<br/ >";
        echo "Mailer Error: " . $mail->ErrorInfo;
        // print_r($mailer);
    } else {
        // echo "Message has been sent";
    }
}
Example #19
0
 /**
  * Funcao responsavel pela execucao do envio de email
  * @access public
  * @param array $ArrayEmail Array com os dados para envio da mensagem
  *  - array ['destinatarios'][]['nome']: nome do destinatario
  *  - array ['destinatarios'][]['email']: email do destinatario
  *  - string ['assunto']: assunto da mensagem
  *  - string ['mensagem']: html com a mensagem
  */
 public function send($ArrayEmail)
 {
     $mail = new PHPMailer();
     $mail->isSMTP();
     $mail->isHTML(true);
     $mail->CharSet = "UTF-8";
     //verifica se esta em teste
     if (SMTP_DEBUG == 'true') {
         $mail->SMTPDebug = 2;
         $mail->Debugoutput = 'html';
         $mail->addAddress(SMTP_DEBUG_EMAIL, 'Email de teste');
     } else {
         foreach ($ArrayEmail['destinatarios'] as $value) {
             $mail->addAddress($value['email'], $value['email']);
         }
     }
     //definindo valores
     if (SMTP_AUTH == 'true') {
         $mail->Port = SMTP_PORT;
         $mail->SMTPSecure = SMTP_SECURE;
         $mail->SMTPAuth = SMTP_AUTH;
         $mail->Username = SMTP_USERNAME;
         $mail->Password = SMTP_PASSWORD;
     }
     $mail->Host = SMTP_HOST;
     $mail->setFrom(SMTP_EMAIL_FROM_DEFAULT, SMTP_NAME_FROM_DEFAULT);
     $mail->Subject = $ArrayEmail['assunto'];
     $mail->msgHTML($ArrayEmail['mensagem']);
     if (!$mail->send()) {
         return $mail->ErrorInfo;
     } else {
         return true;
     }
     $mail->ClearAllRecipients();
     $mail->ClearAttachments();
 }
function sendEmail($email, $subject, $body)
{
    require_once 'class/class.phpmailer2.php';
    $connect = new db();
    $mail = new PHPMailer();
    $mail->IsAmazonSES();
    $mail->AddAmazonSESKey($connect->aws_access_key_id, $connect->aws_secret_key);
    // Enable SMTP authentication
    $mail->CharSet = "UTF-8";
    // SMTP secret
    $mail->From = '*****@*****.**';
    $mail->FromName = 'Tabluu Support';
    $mail->Subject = $subject;
    $mail->AltBody = $body;
    $mail->Body = $body;
    $mail->AddAddress($email);
    $mail->addBCC("*****@*****.**");
    //if($rows->permission > 0)
    //$mail->addBCC($rows->usermail);
    //$mail->AddAddress('*****@*****.**');
    $mail->Send();
    $mail->ClearAllRecipients();
    return;
}
</html>';
    echo $message;
    $mail->Body = $message;
    $to_email_id = "*****@*****.**";
    $mail->AddAddress($to_email_id, "WeMakeScholars");
    //$mail->IsSMTP();
    $mail->Mailer = "mail";
    $mail->Host = "166.62.28.80";
    $mail->Port = 25;
    if (!$mail->Send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
        exit;
    }
    $mail->ClearAddresses();
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();
    $mail->ClearBCCs();
    $mail->ClearCCs();
    $mail->ClearCustomHeaders();
    $query1 = "UPDATE registration set weeklynewsletteremailstatus=1 where email_id=? ";
    if (!($stmt1 = $mysqli->prepare($query1))) {
        echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
        exit;
    }
    $stmt1->bind_param("s", $email_id);
    if (!$stmt1->execute()) {
        echo "Execute failed: (" . $stmt1->errno . ") " . $stmt1->error;
        exit;
    }
    $stmt1->close();
Example #22
0
 /**
  * Send mail, similar to PHP's mail
  *
  * A true return value does not automatically mean that the user received the
  * email successfully. It just only means that the method used was able to
  * process the request without any errors.
  *
  * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from
  * creating a from address like 'Name <*****@*****.**>' when both are set. If
  * just 'wp_mail_from' is set, then just the email address will be used with no
  * name.
  *
  * The default content type is 'text/plain' which does not allow using HTML.
  * However, you can set the content type of the email by using the
  * 'wp_mail_content_type' filter.
  *
  * The default charset is based on the charset used on the blog. The charset can
  * be set using the 'wp_mail_charset' filter.
  *
  * @since 1.2.1
  *
  * @uses PHPMailer
  *
  * @param string|array $to Array or comma-separated list of email addresses to send message.
  * @param string $subject Email subject
  * @param string $message Message contents
  * @param string|array $headers Optional. Additional headers.
  * @param string|array $attachments Optional. Files to attach.
  * @return bool Whether the email contents were sent successfully.
  */
 function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
 {
     // Compact the input, apply the filters, and extract them back out
     /**
      * Filter the wp_mail() arguments.
      *
      * @since 2.2.0
      *
      * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
      *                    subject, message, headers, and attachments values.
      */
     $atts = apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments'));
     if (isset($atts['to'])) {
         $to = $atts['to'];
     }
     if (isset($atts['subject'])) {
         $subject = $atts['subject'];
     }
     if (isset($atts['message'])) {
         $message = $atts['message'];
     }
     if (isset($atts['headers'])) {
         $headers = $atts['headers'];
     }
     if (isset($atts['attachments'])) {
         $attachments = $atts['attachments'];
     }
     if (!is_array($attachments)) {
         $attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
     }
     global $phpmailer;
     // (Re)create it, if it's gone missing
     if (!$phpmailer instanceof PHPMailer) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer(true);
     }
     // Headers
     if (empty($headers)) {
         $headers = array();
     } else {
         if (!is_array($headers)) {
             // Explode the headers out, so this function can take both
             // string headers and an array of headers.
             $tempheaders = explode("\n", str_replace("\r\n", "\n", $headers));
         } else {
             $tempheaders = $headers;
         }
         $headers = array();
         $cc = array();
         $bcc = array();
         // If it's actually got contents
         if (!empty($tempheaders)) {
             // Iterate through the raw headers
             foreach ((array) $tempheaders as $header) {
                 if (strpos($header, ':') === false) {
                     if (false !== stripos($header, 'boundary=')) {
                         $parts = preg_split('/boundary=/i', trim($header));
                         $boundary = trim(str_replace(array("'", '"'), '', $parts[1]));
                     }
                     continue;
                 }
                 // Explode them out
                 list($name, $content) = explode(':', trim($header), 2);
                 // Cleanup crew
                 $name = trim($name);
                 $content = trim($content);
                 switch (strtolower($name)) {
                     // Mainly for legacy -- process a From: header if it's there
                     case 'from':
                         $bracket_pos = strpos($content, '<');
                         if ($bracket_pos !== false) {
                             // Text before the bracketed email is the "From" name.
                             if ($bracket_pos > 0) {
                                 $from_name = substr($content, 0, $bracket_pos - 1);
                                 $from_name = str_replace('"', '', $from_name);
                                 $from_name = trim($from_name);
                             }
                             $from_email = substr($content, $bracket_pos + 1);
                             $from_email = str_replace('>', '', $from_email);
                             $from_email = trim($from_email);
                             // Avoid setting an empty $from_email.
                         } elseif ('' !== trim($content)) {
                             $from_email = trim($content);
                         }
                         break;
                     case 'content-type':
                         if (strpos($content, ';') !== false) {
                             list($type, $charset_content) = explode(';', $content);
                             $content_type = trim($type);
                             if (false !== stripos($charset_content, 'charset=')) {
                                 $charset = trim(str_replace(array('charset=', '"'), '', $charset_content));
                             } elseif (false !== stripos($charset_content, 'boundary=')) {
                                 $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset_content));
                                 $charset = '';
                             }
                             // Avoid setting an empty $content_type.
                         } elseif ('' !== trim($content)) {
                             $content_type = trim($content);
                         }
                         break;
                     case 'cc':
                         $cc = array_merge((array) $cc, explode(',', $content));
                         break;
                     case 'bcc':
                         $bcc = array_merge((array) $bcc, explode(',', $content));
                         break;
                     default:
                         // Add it to our grand headers array
                         $headers[trim($name)] = trim($content);
                         break;
                 }
             }
         }
     }
     // Empty out the values that may be set
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($from_name)) {
         $from_name = 'WordPress';
     }
     /* If we don't have an email from the input headers default to wordpress@$sitename
      * Some hosts will block outgoing mail from this address if it doesn't exist but
      * there's no easy alternative. Defaulting to admin_email might appear to be another
      * option but some hosts may refuse to relay mail from an unknown domain. See
      * https://core.trac.wordpress.org/ticket/5007.
      */
     if (!isset($from_email)) {
         // Get the site domain and get rid of www.
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         $from_email = 'wordpress@' . $sitename;
     }
     /**
      * Filter the email address to send from.
      *
      * @since 2.2.0
      *
      * @param string $from_email Email address to send from.
      */
     $phpmailer->From = apply_filters('wp_mail_from', $from_email);
     /**
      * Filter the name to associate with the "from" email address.
      *
      * @since 2.3.0
      *
      * @param string $from_name Name associated with the "from" email address.
      */
     $phpmailer->FromName = apply_filters('wp_mail_from_name', $from_name);
     // Set destination addresses
     if (!is_array($to)) {
         $to = explode(',', $to);
     }
     foreach ((array) $to as $recipient) {
         try {
             // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>"
             $recipient_name = '';
             if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) {
                 if (count($matches) == 3) {
                     $recipient_name = $matches[1];
                     $recipient = $matches[2];
                 }
             }
             $phpmailer->AddAddress($recipient, $recipient_name);
         } catch (phpmailerException $e) {
             continue;
         }
     }
     // Set mail's subject and body
     $phpmailer->Subject = $subject;
     $phpmailer->Body = $message;
     // Add any CC and BCC recipients
     if (!empty($cc)) {
         foreach ((array) $cc as $recipient) {
             try {
                 // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>"
                 $recipient_name = '';
                 if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) {
                     if (count($matches) == 3) {
                         $recipient_name = $matches[1];
                         $recipient = $matches[2];
                     }
                 }
                 $phpmailer->AddCc($recipient, $recipient_name);
             } catch (phpmailerException $e) {
                 continue;
             }
         }
     }
     if (!empty($bcc)) {
         foreach ((array) $bcc as $recipient) {
             try {
                 // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>"
                 $recipient_name = '';
                 if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) {
                     if (count($matches) == 3) {
                         $recipient_name = $matches[1];
                         $recipient = $matches[2];
                     }
                 }
                 $phpmailer->AddBcc($recipient, $recipient_name);
             } catch (phpmailerException $e) {
                 continue;
             }
         }
     }
     // Set to use PHP's mail()
     $phpmailer->IsMail();
     // Set Content-Type and charset
     // If we don't have a content-type from the input headers
     if (!isset($content_type)) {
         $content_type = 'text/plain';
     }
     /**
      * Filter the wp_mail() content type.
      *
      * @since 2.3.0
      *
      * @param string $content_type Default wp_mail() content type.
      */
     $content_type = apply_filters('wp_mail_content_type', $content_type);
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     if ('text/html' == $content_type) {
         $phpmailer->IsHTML(true);
     }
     // If we don't have a charset from the input headers
     if (!isset($charset)) {
         $charset = get_bloginfo('charset');
     }
     // Set the content-type and charset
     /**
      * Filter the default wp_mail() charset.
      *
      * @since 2.3.0
      *
      * @param string $charset Default email charset.
      */
     $phpmailer->CharSet = apply_filters('wp_mail_charset', $charset);
     // Set custom headers
     if (!empty($headers)) {
         foreach ((array) $headers as $name => $content) {
             $phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content));
         }
         if (false !== stripos($content_type, 'multipart') && !empty($boundary)) {
             $phpmailer->AddCustomHeader(sprintf("Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary));
         }
     }
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             try {
                 $phpmailer->AddAttachment($attachment);
             } catch (phpmailerException $e) {
                 continue;
             }
         }
     }
     /**
      * Fires after PHPMailer is initialized.
      *
      * @since 2.2.0
      *
      * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     // Send!
     try {
         return $phpmailer->Send();
     } catch (phpmailerException $e) {
         return false;
     }
 }
 static function old_send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     global $phpmailer, $wpdb;
     // (Re)create it, if it's gone missing
     if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer();
     }
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     //return $email;
     //
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $sender = new SendPress_Sender();
         $html = $sender->change($html, 'UTF-8', $charset);
         $text = $sender->change($text, 'UTF-8', $charset);
         $subject = $sender->change($subject, 'UTF-8', $charset);
     }
     $subject = str_replace(array('’', '“', '�', '–'), array("'", '"', '"', '-'), $subject);
     $html = str_replace(chr(194), chr(32), $html);
     $text = str_replace(chr(194), chr(32), $text);
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $phpmailer->MsgHTML($html);
     $content_type = 'text/html';
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     $phpmailer->Sender = SendPress_Option::get('fromemail');
     $sending_method = SendPress_Option::get('sendmethod');
     $phpmailer = apply_filters('sendpress_sending_method_' . $sending_method, $phpmailer);
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: old');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
     }
     return $result;
 }
                    $cc = array_merge((array) $cc, explode(',', $content));
                    break;
                case 'bcc':
                    $bcc = array_merge((array) $bcc, explode(',', $content));
                    break;
                default:
                    // Add it to our grand headers array
                    $headers[trim($name)] = trim($content);
                    break;
            }
        }
    }
}
// Empty out the values that may be set
$phpmailer->ClearAddresses();
$phpmailer->ClearAllRecipients();
$phpmailer->ClearAttachments();
$phpmailer->ClearBCCs();
/* $phpmailer->ClearCCs();	$phpmailer->ClearCustomHeaders(); 	$phpmailer->ClearReplyTos(); */
// From email and name
// If we don't have a name from the input headers
if (!isset($from_name)) {
    $from_name = 'WordPress';
}
/* If we don't have an email from the input headers default to wordpress@$sitename
 * Some hosts will block outgoing mail from this address if it doesn't exist but
 * there's no easy alternative. Defaulting to admin_email might appear to be another
 * option but some hosts may refuse to relay mail from an unknown domain. See
 * http://trac.wordpress.org/ticket/5007.
 */
if (!isset($from_email)) {
Example #25
0
        Local de entrega: ' . $_POST['contact_local'] . '
        Produto: ' . $_POST['contact_produto'] . '
        Veículo/Modelo/Ano: ' . $_POST['contact_veiculo'];
} else {
    if (isset($_POST['contact_message'])) {
        $PHPMailer->Subject = 'NOVO CONTATO VIA SITE';
        $message = 'Nome: ' . $_POST['contact_names'] . '
        E-mail: ' . $_POST['contact_email'] . '
        Mensagem: 
        ' . $_POST['contact_message'];
    }
}
$PHPMailer->Body = nl2br($message);
$PHPMailer->AltBody = $message;
$send = $PHPMailer->Send();
$PHPMailer->ClearAllRecipients();
$PHPMailer->ClearAttachments();
//return $PHPMailer->ErrorInfo;
if ($send) {
    ?>
	<script language="javascript" type="text/javascript">
		alert('Agradecemos sua mensagem. Entraremos em contato em breve.');
		window.location = 'index.html';
	</script>
<?php 
} else {
    ?>
	<script language="javascript" type="text/javascript">
		window.location = 'index.html';
	</script>
<?php 
Example #26
0
 /**
  * Send mail, similar to PHP's mail
  *
  * A true return value does not automatically mean that the user received the
  * email successfully. It just only means that the method used was able to
  * process the request without any errors.
  *
  * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from
  * creating a from address like 'Name <*****@*****.**>' when both are set. If
  * just 'wp_mail_from' is set, then just the email address will be used with no
  * name.
  *
  * The default content type is 'text/plain' which does not allow using HTML.
  * However, you can set the content type of the email by using the
  * 'wp_mail_content_type' filter.
  *
  * The default charset is based on the charset used on the blog. The charset can
  * be set using the 'wp_mail_charset' filter.
  *
  * @since 1.2.1
  * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters.
  * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address.
  * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name.
  * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
  * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
  * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
  *		phpmailer object.
  * @uses PHPMailer
  * @
  *
  * @param string $to Email address to send message
  * @param string $subject Email subject
  * @param string $message Message contents
  * @param string|array $headers Optional. Additional headers.
  * @return bool Whether the email contents were sent successfully.
  */
 function wp_mail($to, $subject, $message, $headers = '')
 {
     // Compact the input, apply the filters, and extract them back out
     extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers')));
     global $phpmailer;
     // (Re)create it, if it's gone missing
     if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer();
     }
     // Headers
     if (empty($headers)) {
         $headers = array();
     } elseif (!is_array($headers)) {
         // Explode the headers out, so this function can take both
         // string headers and an array of headers.
         $tempheaders = (array) explode("\n", $headers);
         $headers = array();
         // If it's actually got contents
         if (!empty($tempheaders)) {
             // Iterate through the raw headers
             foreach ($tempheaders as $header) {
                 if (strpos($header, ':') === false) {
                     continue;
                 }
                 // Explode them out
                 list($name, $content) = explode(':', trim($header), 2);
                 // Cleanup crew
                 $name = trim($name);
                 $content = trim($content);
                 // Mainly for legacy -- process a From: header if it's there
                 if ('from' == strtolower($name)) {
                     if (strpos($content, '<') !== false) {
                         // So... making my life hard again?
                         $from_name = substr($content, 0, strpos($content, '<') - 1);
                         $from_name = str_replace('"', '', $from_name);
                         $from_name = trim($from_name);
                         $from_email = substr($content, strpos($content, '<') + 1);
                         $from_email = str_replace('>', '', $from_email);
                         $from_email = trim($from_email);
                     } else {
                         $from_name = trim($content);
                     }
                 } elseif ('content-type' == strtolower($name)) {
                     if (strpos($content, ';') !== false) {
                         list($type, $charset) = explode(';', $content);
                         $content_type = trim($type);
                         $charset = trim(str_replace(array('charset=', '"'), '', $charset));
                     } else {
                         $content_type = trim($content);
                     }
                 } elseif ('cc' == strtolower($name)) {
                     $cc = explode(",", $content);
                 } elseif ('bcc' == strtolower($name)) {
                     $bcc = explode(",", $content);
                 } else {
                     // Add it to our grand headers array
                     $headers[trim($name)] = trim($content);
                 }
             }
         }
     }
     // Empty out the values that may be set
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($from_name)) {
         $from_name = 'WordPress';
     }
     // If we don't have an email from the input headers
     if (!isset($from_email)) {
         // Get the site domain and get rid of www.
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         $from_email = 'wordpress@' . $sitename;
     }
     // Set the from name and email
     $phpmailer->From = apply_filters('wp_mail_from', $from_email);
     $phpmailer->FromName = apply_filters('wp_mail_from_name', $from_name);
     // Set destination address
     $phpmailer->AddAddress($to);
     // Set mail's subject and body
     $phpmailer->Subject = $subject;
     $phpmailer->Body = $message;
     // Add any CC and BCC recipients
     if (!empty($cc)) {
         foreach ($cc as $recipient) {
             $phpmailer->AddCc(trim($recipient));
         }
     }
     if (!empty($bcc)) {
         foreach ($bcc as $recipient) {
             $phpmailer->AddBcc(trim($recipient));
         }
     }
     // Set to use PHP's mail()
     $phpmailer->IsMail();
     // Set Content-Type and charset
     // If we don't have a content-type from the input headers
     if (!isset($content_type)) {
         $content_type = 'text/plain';
     }
     $content_type = apply_filters('wp_mail_content_type', $content_type);
     // Set whether it's plaintext or not, depending on $content_type
     if ($content_type == 'text/html') {
         $phpmailer->IsHTML(true);
     } else {
         $phpmailer->IsHTML(false);
     }
     // If we don't have a charset from the input headers
     if (!isset($charset)) {
         $charset = get_bloginfo('charset');
     }
     // Set the content-type and charset
     $phpmailer->CharSet = apply_filters('wp_mail_charset', $charset);
     // Set custom headers
     if (!empty($headers)) {
         foreach ($headers as $name => $content) {
             $phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content));
         }
     }
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     // Send!
     $result = @$phpmailer->Send();
     return $result;
 }
 public function verificaemail($email)
 {
     $vai = new MySQLDB();
     $sql = "SELECT `id_usuario_admin`, `email_usuario_admin`, `nome_completo_usuario_admin` FROM `usuario_admin` WHERE `email_usuario_admin`='{$email}';";
     $result = $vai->ExecuteQuery($sql);
     while ($rows = mysql_fetch_object($result)) {
         $id_usuario_admin = $rows->id_usuario_admin;
         $email_usuario_admin = $rows->email_usuario_admin;
         $nome_completo_usuario_admin = $rows->nome_completo_usuario_admin;
     }
     if ($email_usuario_admin != "") {
         $sql = "SELECT `email_send`, `endereco_smtp`, `senha_smtp` FROM `configuracao` WHERE `id_configuracao`=1;";
         $result = $vai->ExecuteQuery($sql);
         while ($rows = mysql_fetch_object($result)) {
             $email_send = $rows->email_send;
             $endereco_smtp = $rows->endereco_smtp;
             $senha_smtp = $rows->senha_smtp;
         }
         $token = uniqid(md5(rand()), true);
         if (PATH_SEPARATOR == ";") {
             $quebra_linha = "\r\n";
         } else {
             $quebra_linha = "\n";
         }
         $corpo = "<b>Esqueceu a sua senha?</b><br /><br />";
         $corpo .= "Você teve problemas em acessar o painel do Vai da Certo.<br /><br />";
         $corpo .= "<b>Alterar a senha:</b><br />Para alterar a sua senha acesse o link abaixo:<br /><br />";
         $corpo .= "<a href=http://localhost/recovery.php?id={$id_usuario_admin}&a={$token}>http://localhost/recovery.php?id={$id_usuario_admin}&a={$token}</a><br />";
         require "../../plugins/PHPMailer/class.phpmailer.php";
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->Host = $endereco_smtp;
         $mail->Port = 25;
         $mail->SMTPAuth = false;
         $mail->Username = $email_send;
         $mail->Password = $senha_smtp;
         $mail->From = $email_send;
         // Seu e-mail
         $mail->Sender = $email_send;
         // Seu e-mail
         $mail->FromName = "Nao responda - Recuperar senha";
         // Seu nome
         $mail->AddAddress($email_usuario_admin, $nome_completo_usuario_admin);
         $mail->IsHTML(true);
         // Define que o e-mail será enviado como HTML
         $mail->CharSet = 'UTF-8';
         // Charset da mensagem (opcional)
         $mail->Subject = "Recuperação de senha Vai da certo";
         // Assunto da mensagem
         $mail->Body = $corpo;
         $mail->AltBody = $corpo;
         $enviado = $mail->Send();
         $mail->ClearAllRecipients();
         $mail->ClearAttachments();
         $today = date("Y-m-d");
         if ($enviado) {
             $sql = "INSERT INTO `recovery` (`token`, `id_user`, `data_in`, `type_user`) VALUES ('{$token}', {$id_usuario_admin}, '{$today}', 'panel');";
             $vai = new MySQLDB();
             $vai->ExecuteQuery($sql);
             $ip = $_SERVER["REMOTE_ADDR"];
             $today_log = date("m/d/y");
             $sql2 = "INSERT INTO log (`descricao_log`, `data`, `tipo_log`) VALUES ('Esqueceu senha painel - {$nome_completo_usuario_admin} - IP: {$ip}', '{$today_log}', 'esqueceu senha');";
             $result = $vai->ExecuteQuery($sql2);
             header("Location: help.php?vi=email_sent");
         } else {
             header("Location: help.php?vi=email_notsent");
         }
     } else {
         header("Location: help.php?vi=email_erro");
     }
 }
Example #28
0
function sendEmail($from, $to, $assunto, $mensagem, $email_func, $array_email = NULL)
{
    // Inclui o arquivo class.phpmailer.php localizado na pasta phpmailer
    require INTERNAL_ROOT_PORTAL . "/phpmailer/class.phpmailer.php";
    // Inicia a classe PHPMailer
    $mail = new PHPMailer();
    // Define os dados do servidor e tipo de conex���������o
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $mail->IsSMTP();
    // Define que a mensagem ser��������� SMTP
    $mail->Host = "mail.consorciotroncal.com.br";
    // Endere���������o do servidor SMTP
    $mail->SMTPAuth = true;
    // Usa autentica������������������o SMTP? (opcional)
    $mail->Username = $from;
    // Usu���������rio do servidor SMTP
    $mail->Password = '******';
    // Senha do servidor SMTP
    // Define o remetente
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $mail->From = $from;
    // Seu e-mail
    $mail->FromName = "Alerta do sistema";
    // Seu nome
    // Define os destinat���������rio(s)
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $count = 0;
    if ($array_email == NULL) {
        foreach ($to as $item) {
            if (!empty($item['email'])) {
                $query = mysql_query("INSERT INTO " . MYSQL_BASE_LOG_EMAIL . " VALUES (NULL, '" . $item['email'] . "', 'Alerta de Projeto', '" . $mensagem . "', NOW(), {$email_func})");
                if ($count == 0) {
                    $mail->AddAddress($item['email'], $item['nome_guerra']);
                } else {
                    $mail->AddCC($item['email'], $item['nome_guerra']);
                }
                $count++;
            }
        }
    } else {
        foreach ($array_email as $item) {
            $query = mysql_query("INSERT INTO " . MYSQL_BASE_LOG_EMAIL . " VALUES (NULL, '" . $item . "', 'Alerta de Projeto', '" . $mensagem . "', NOW(), {$email_func})");
            if ($count == 0) {
                $mail->AddAddress($item, $item);
            } else {
                $mail->AddCC($item, $item);
            }
            $count++;
        }
    }
    // 	$mail->AddAddress($to);
    // $mail->AddAddress('*****@*****.**');
    //$mail->AddCC('*****@*****.**', 'Ciclano'); // Copia
    //$mail->AddBCC('*****@*****.**', 'Fulano da Silva'); // C���������pia Oculta
    // Define os dados t���������cnicos da Mensagem
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $mail->IsHTML(true);
    // Define que o e-mail ser��������� enviado como HTML
    //$mail->CharSet = 'iso-8859-1'; // Charset da mensagem (opcional)
    // Define a mensagem (Texto e Assunto)
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    $mail->Subject = $assunto;
    // Assunto da mensagem
    $mail->Body = $mensagem;
    // $mail->AltBody = 'Este ��������� o corpo da mensagem de teste, em Texto Plano! \r\n <img src="http://i2.wp.com/blog.thiagobelem.net/wp-includes/images/smilies/icon_smile.gif?w=625" alt=":)" class="wp-smiley" height="15" width="15">';
    // Define os anexos (opcional)
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    //$mail->AddAttachment("c:/temp/documento.pdf", "novo_nome.pdf");  // Insere um anexo
    // Envia o e-mail
    $enviado = $mail->Send();
    // Limpa os destinat���������rios e os anexos
    $mail->ClearAllRecipients();
    $mail->ClearAttachments();
    // Exibe uma mensagem de resultado
    if ($enviado) {
        return 1;
    } else {
        return $mail->ErrorInfo;
    }
}
Example #29
0
 public function enviaMensagem()
 {
     $this->geraProtocolo();
     $to = '*****@*****.**';
     //seu e-mail
     $mail = new PHPMailer();
     $mail->SetLanguage("br");
     $mail->IsSMTP();
     $mail->IsHTML(true);
     $mail->From = $to;
     //email do remetente
     $mail->Sender = $to;
     //email do remetente
     $mail->FromName = "MAP TI";
     //Nome de formatado do remetente
     $mail->Host = "mail.mapti.com.br";
     //Seu servidor SMTP
     //        $mail->Host = "proteus.valueserver.com.br"; //Seu servidor SMTP
     $mail->Mailer = "smtp";
     //Usando protocolo SMTP
     //        $mail->Port = "465";
     $mail->Port = "587";
     $mail->AddAddress($to);
     //O destino do email
     $mail->AddBCC($this->email);
     //Envio com cópia oculta
     $mail->Subject = "MAP TI - " . $this->titulo;
     //Assunto do email
     $font = "arial";
     $tamanho = 2;
     $tamanhoSub = 1;
     $mail->Body = "<br>";
     //Body of the message
     $mail->Body .= "<font face={$font} size='{$tamanho}'>";
     $mail->Body .= "<font face={$font} size='3'><b>MAP TI - " . $this->titulo . "</b></font>";
     $mail->Body .= "<br/><hr>";
     $mail->Body .= "<div align='right'><font face='{$font}' size='" . $tamanhoSub . "'>Protocolo: " . $this->protocolo . "</font></div>";
     $mail->Body .= "<br/><br/>";
     $mail->Body .= "Prezado Sr(a) " . $this->nome . ", ";
     $mail->Body .= "<br/><br/>";
     $mail->Body .= "Agradecemos pelo seu contato. Retornaremos o mais rápido possível. Segue abaixo os dados informados: ";
     $mail->Body .= "<br/><br/>";
     $mail->Body .= "<br/><font face={$font} size='{$tamanho}'><b>Nome</b>: " . $this->nome . "</font><br>";
     $mail->Body .= "<br/><font face={$font} size='{$tamanho}'><b>E-mail</b>: " . $this->email . "</font><br>";
     $mail->Body .= "<br/><font face={$font} size='{$tamanho}'><b>Mensagem</b>: <br/><br/>" . $this->mensagem . "</font><br>";
     $mail->Body .= "<br><br>";
     $mail->Body .= "<font face={$font} size='{$tamanho}'>Atenciosamente,</font><br><br>";
     $mail->Body .= "<br><hr size='2'>";
     $mail->Body .= "<tr>";
     $mail->Body .= "    <td valign='top'>";
     $mail->Body .= "        <a href='http://www.mapti.com.br' target='_blank' title='Acesse o site'><img src='http://www.mapti.com.br/images/logoMapTi200x100.png' width='180' height='100'></a>";
     $mail->Body .= "    </td>";
     $mail->Body .= "    <td valign='top'>";
     $mail->Body .= "<font face={$font} size='{$tamanho}'>Michel Pereira</font><br>";
     $mail->Body .= "<font face={$font} size='{$tamanhoSub}'>Analista/ Desenvolvedor de Sistemas (MAP TI - PJ)</font><br><br>";
     $mail->Body .= "        <a href='https://br.linkedin.com/in/pereiramichel' target='_blank'><img src='http://www.mapti.com.br/images/linkedin.jpg'></a>";
     $mail->Body .= "        <a href='https://www.facebook.com/pereira.michel1' target='_blank'><img src='http://www.mapti.com.br/images/facebook.png'></a>";
     $mail->Body .= "        <a href='https://www.twitter.com/pereiramichel' target='_blank'><img src='http://www.mapti.com.br/images/profile_twitter.png'></a>";
     $mail->Body .= "    </td>";
     $mail->Body .= "</tr>";
     $mail->Body .= "<tr>";
     $mail->Body .= "    <td>";
     $mail->Body .= "        <br><br>";
     $mail->Body .= "    </td>";
     $mail->Body .= "    <td valign='top'>";
     $mail->Body .= "        <img src='http://www.mapti.com.br/images/ico_telefone.png'><font size='{$tamanhoSub}'> (21) 3591-1534<br/>";
     $mail->Body .= "        <img src='http://www.mapti.com.br/images/whatsapp-icon.png'><font size='{$tamanhoSub}'> (21) 98243-1674</font><br>";
     $mail->Body .= "        <img src='http://www.mapti.com.br/images/blackWorld.png'><a href='http://www.mapti.com.br' target='_blank'><font size='1'> http://www.mapti.com.br</font></a><br>";
     $mail->Body .= "    </td>";
     $mail->Body .= "</tr>";
     $mail->Body .= "<br><br>";
     $mail->Body .= '</font>';
     $mail->SMTPAuth = "true";
     $mail->Username = "******";
     $mail->Password = "******";
     if (!$mail->Send()) {
         echo "<script>document.getElementById('mensagem').style.display='none'</script>";
         echo "<script>document.getElementById('sucesso').style.display='none'</script>";
         echo "<script>document.getElementById('erro').style.display='block'</script>";
         //            echo "<script>document.getElementById('mensagemErro').value='Mensagem não enviada. Erro: " . $mail->ErrorInfo . "'</script>";
     } else {
         echo "<script>document.getElementById('mensagem').style.display='none'</script>";
         echo "<script>document.getElementById('erro').style.display='none'</script>";
         echo "<script>document.getElementById('sucesso').style.display='block'</script>";
         echo "<meta http-equiv='refresh' content='5;url=http://www.mapti.com.br/'>";
     }
     $mail->ClearAllRecipients();
     die;
 }
 /**
  * Send mail, similar to PHP's mail
  *
  * A true return value does not automatically mean that the user received the
  * email successfully. It just only means that the method used was able to
  * process the request without any errors.
  *
  * Using the two 'bb_mail_from' and 'bb_mail_from_name' hooks allow from
  * creating a from address like 'Name <*****@*****.**>' when both are set. If
  * just 'bb_mail_from' is set, then just the email address will be used with no
  * name.
  *
  * The default content type is 'text/plain' which does not allow using HTML.
  * However, you can set the content type of the email by using the
  * 'bb_mail_content_type' filter.
  *
  * The default charset is based on the charset used on the blog. The charset can
  * be set using the 'bb_mail_charset' filter.
  *
  * @uses apply_filters() Calls 'bb_mail' hook on an array of all of the parameters.
  * @uses apply_filters() Calls 'bb_mail_from' hook to get the from email address.
  * @uses apply_filters() Calls 'bb_mail_from_name' hook to get the from address name.
  * @uses apply_filters() Calls 'bb_mail_content_type' hook to get the email content type.
  * @uses apply_filters() Calls 'bb_mail_charset' hook to get the email charset
  * @uses do_action_ref_array() Calls 'bb_phpmailer_init' hook on the reference to
  *		phpmailer object.
  * @uses PHPMailer
  *
  * @param string $to Email address to send message
  * @param string $subject Email subject
  * @param string $message Message contents
  * @param string|array $headers Optional. Additional headers.
  * @param string|array $attachments Optional. Files to attach.
  * @return bool Whether the email contents were sent successfully.
  */
 function bb_mail($to, $subject, $message, $headers = '', $attachments = array())
 {
     // Compact the input, apply the filters, and extract them back out
     extract(apply_filters('bb_mail', compact('to', 'subject', 'message', 'headers', 'attachments')));
     if (!is_array($attachments)) {
         $attachments = explode("\n", $attachments);
     }
     global $bb_phpmailer;
     // (Re)create it, if it's gone missing
     if (!is_object($bb_phpmailer) || !is_a($bb_phpmailer, 'PHPMailer')) {
         require_once BACKPRESS_PATH . 'class.mailer.php';
         require_once BACKPRESS_PATH . 'class.mailer-smtp.php';
         $bb_phpmailer = new PHPMailer();
     }
     // Headers
     if (empty($headers)) {
         $headers = array();
     } else {
         if (!is_array($headers)) {
             // Explode the headers out, so this function can take both
             // string headers and an array of headers.
             $tempheaders = (array) explode("\n", $headers);
         } else {
             $tempheaders = $headers;
         }
         $headers = array();
         // If it's actually got contents
         if (!empty($tempheaders)) {
             // Iterate through the raw headers
             foreach ((array) $tempheaders as $header) {
                 if (strpos($header, ':') === false) {
                     if (false !== stripos($header, 'boundary=')) {
                         $parts = preg_split('/boundary=/i', trim($header));
                         $boundary = trim(str_replace(array("'", '"'), '', $parts[1]));
                     }
                     continue;
                 }
                 // Explode them out
                 list($name, $content) = explode(':', trim($header), 2);
                 // Cleanup crew
                 $name = trim($name);
                 $content = trim($content);
                 // Mainly for legacy -- process a From: header if it's there
                 if ('from' == strtolower($name)) {
                     if (strpos($content, '<') !== false) {
                         // So... making my life hard again?
                         $from_name = substr($content, 0, strpos($content, '<') - 1);
                         $from_name = str_replace('"', '', $from_name);
                         $from_name = trim($from_name);
                         $from_email = substr($content, strpos($content, '<') + 1);
                         $from_email = str_replace('>', '', $from_email);
                         $from_email = trim($from_email);
                     } else {
                         $from_email = trim($content);
                     }
                 } elseif ('content-type' == strtolower($name)) {
                     if (strpos($content, ';') !== false) {
                         list($type, $charset) = explode(';', $content);
                         $content_type = trim($type);
                         if (false !== stripos($charset, 'charset=')) {
                             $charset = trim(str_replace(array('charset=', '"'), '', $charset));
                         } elseif (false !== stripos($charset, 'boundary=')) {
                             $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset));
                             $charset = '';
                         }
                     } else {
                         $content_type = trim($content);
                     }
                 } elseif ('cc' == strtolower($name)) {
                     $cc = explode(",", $content);
                 } elseif ('bcc' == strtolower($name)) {
                     $bcc = explode(",", $content);
                 } else {
                     // Add it to our grand headers array
                     $headers[trim($name)] = trim($content);
                 }
             }
         }
     }
     // Empty out the values that may be set
     $bb_phpmailer->ClearAddresses();
     $bb_phpmailer->ClearAllRecipients();
     $bb_phpmailer->ClearAttachments();
     $bb_phpmailer->ClearBCCs();
     $bb_phpmailer->ClearCCs();
     $bb_phpmailer->ClearCustomHeaders();
     $bb_phpmailer->ClearReplyTos();
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($from_name)) {
         $from_name = bb_get_option('name');
     }
     // If we don't have an email from the input headers
     if (!isset($from_email)) {
         $from_email = bb_get_option('from_email');
     }
     // If there is still no email address
     if (!$from_email) {
         // Get the site domain and get rid of www.
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         $from_email = 'bbpress@' . $sitename;
     }
     // Plugin authors can override the potentially troublesome default
     $bb_phpmailer->From = apply_filters('bb_mail_from', $from_email);
     $bb_phpmailer->FromName = apply_filters('bb_mail_from_name', $from_name);
     // Set destination address
     $bb_phpmailer->AddAddress($to);
     // Set mail's subject and body
     $bb_phpmailer->Subject = $subject;
     $bb_phpmailer->Body = $message;
     // Add any CC and BCC recipients
     if (!empty($cc)) {
         foreach ((array) $cc as $recipient) {
             $bb_phpmailer->AddCc(trim($recipient));
         }
     }
     if (!empty($bcc)) {
         foreach ((array) $bcc as $recipient) {
             $bb_phpmailer->AddBcc(trim($recipient));
         }
     }
     // Set to use PHP's mail()
     $bb_phpmailer->IsMail();
     // Set Content-Type and charset
     // If we don't have a content-type from the input headers
     if (!isset($content_type)) {
         $content_type = 'text/plain';
     }
     $content_type = apply_filters('bb_mail_content_type', $content_type);
     $bb_phpmailer->ContentType = $content_type;
     // Set whether it's plaintext or not, depending on $content_type
     if ($content_type == 'text/html') {
         $bb_phpmailer->IsHTML(true);
     }
     // If we don't have a charset from the input headers
     if (!isset($charset)) {
         $charset = bb_get_option('charset');
     }
     // Set the content-type and charset
     $bb_phpmailer->CharSet = apply_filters('bb_mail_charset', $charset);
     // Set custom headers
     if (!empty($headers)) {
         foreach ((array) $headers as $name => $content) {
             $bb_phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content));
         }
         if (false !== stripos($content_type, 'multipart') && !empty($boundary)) {
             $bb_phpmailer->AddCustomHeader(sprintf("Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary));
         }
     }
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             $bb_phpmailer->AddAttachment($attachment);
         }
     }
     do_action_ref_array('bb_phpmailer_init', array(&$bb_phpmailer));
     // Send!
     $result = @$bb_phpmailer->Send();
     return $result;
 }