Ir para conteúdo
paulo padua

PHPMailer com conta hotmail

Recommended Posts

Olá  pessoal  

Estou precisando de uma ajuda. Utilizo o PHPMailer com Gmail e tudo ok. Mas preciso configurar ele para um conta Hotmail. Já verifiquei na Internet as configurações mas gera erra no envio. Utilizei o servidor SMTP.live.com e porta 587  e tls e até ssl e não gera o mesmo  erro.

 

Alguém poderia me informar como eu resolvo esse problema?

 

 

 

 019-10-08 20:18:00 Connection: opening to smtp.live.com:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),)
2019-10-08 20:18:00 Connection: opened
2019-10-08 20:18:00 SMTP INBOUND: "220 CP2P15201CA0018.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 8 Oct 2019 20:17:58 +0000"
2019-10-08 20:18:00 SERVER -> CLIENT: 220 CP2P15201CA0018.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 8 Oct 2019 20:17:58 +0000
2019-10-08 20:18:00 CLIENT -> SERVER: EHLO localhost
2019-10-08 20:18:00 SMTP INBOUND: "250-CP2P15201CA0018.outlook.office365.com Hello [2804:14c:c0:83d8:899e:1d6c:a4ab:f228]"
2019-10-08 20:18:00 SMTP INBOUND: "250-SIZE 157286400"
2019-10-08 20:18:00 SMTP INBOUND: "250-PIPELINING"
2019-10-08 20:18:00 SMTP INBOUND: "250-DSN"
2019-10-08 20:18:00 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2019-10-08 20:18:00 SMTP INBOUND: "250-STARTTLS"
2019-10-08 20:18:00 SMTP INBOUND: "250-8BITMIME"
2019-10-08 20:18:00 SMTP INBOUND: "250 SMTPUTF8"
2019-10-08 20:18:00 SERVER -> CLIENT: 250-CP2P15201CA0018.outlook.office365.com Hello [2804:14c:c0:83d8:899e:1d6c:a4ab:f228]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250 SMTPUTF8
2019-10-08 20:18:00 CLIENT -> SERVER: STARTTLS
2019-10-08 20:18:00 SMTP INBOUND: "220 2.0.0 SMTP server ready"
2019-10-08 20:18:00 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2019-10-08 20:18:00 CLIENT -> SERVER: EHLO localhost
2019-10-08 20:18:00 SMTP INBOUND: "250-CP2P15201CA0018.outlook.office365.com Hello [2804:14c:c0:83d8:899e:1d6c:a4ab:f228]"
2019-10-08 20:18:00 SMTP INBOUND: "250-SIZE 157286400"
2019-10-08 20:18:00 SMTP INBOUND: "250-PIPELINING"
2019-10-08 20:18:00 SMTP INBOUND: "250-DSN"
2019-10-08 20:18:00 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2019-10-08 20:18:00 SMTP INBOUND: "250-AUTH LOGIN XOAUTH2"
2019-10-08 20:18:00 SMTP INBOUND: "250-8BITMIME"
2019-10-08 20:18:00 SMTP INBOUND: "250 SMTPUTF8"
2019-10-08 20:18:00 SERVER -> CLIENT: 250-CP2P15201CA0018.outlook.office365.com Hello [2804:14c:c0:83d8:899e:1d6c:a4ab:f228]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250 SMTPUTF8
2019-10-08 20:18:00 Auth method requested: UNSPECIFIED
2019-10-08 20:18:00 Auth methods available on the server: LOGIN,XOAUTH2
2019-10-08 20:18:00 Requested auth method not available: 
2019-10-08 20:18:00 Auth method selected: LOGIN
2019-10-08 20:18:00 CLIENT -> SERVER: AUTH LOGIN
2019-10-08 20:18:00 SMTP INBOUND: "334 VXNlcm5hbWU6"
2019-10-08 20:18:00 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-10-08 20:18:00 CLIENT -> SERVER: cGF1bG9fZGVfbGFjZXJkYUBob3RtYWlsLmNvbQ==
2019-10-08 20:18:00 SMTP INBOUND: "334 UGFzc3dvcmQ6"
2019-10-08 20:18:00 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-10-08 20:18:00 CLIENT -> SERVER: UEB1bG9QYWR1YTI0MDYg
2019-10-08 20:18:03 SMTP INBOUND: "235 2.7.0 Authentication successful"
2019-10-08 20:18:03 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2019-10-08 20:18:03 CLIENT -> SERVER: MAIL FROM:<emailtambem@gmail.com>
2019-10-08 20:18:03 SMTP INBOUND: "250 2.1.0 Sender OK"
2019-10-08 20:18:03 SERVER -> CLIENT: 250 2.1.0 Sender OK
2019-10-08 20:18:03 CLIENT -> SERVER: RCPT TO:<emailtambem@gmail.com>
2019-10-08 20:18:03 SMTP INBOUND: "250 2.1.5 Recipient OK"
2019-10-08 20:18:03 SERVER -> CLIENT: 250 2.1.5 Recipient OK
2019-10-08 20:18:03 CLIENT -> SERVER: DATA
2019-10-08 20:18:03 SMTP INBOUND: "354 Start mail input; end with <CRLF>.<CRLF>"
2019-10-08 20:18:03 SERVER -> CLIENT: 354 Start mail input; end with <CRLF>.<CRLF>
2019-10-08 20:18:03 CLIENT -> SERVER: Date: Tue, 8 Oct 2019 20:18:00 +0000
2019-10-08 20:18:03 CLIENT -> SERVER: To: Nome esta correto  <emailtambem@gmail.com>
2019-10-08 20:18:03 CLIENT -> SERVER: From: First Last <emailtambem@gmail.com>
2019-10-08 20:18:03 CLIENT -> SERVER: Reply-To: First Last <replyto@example.com>
2019-10-08 20:18:03 CLIENT -> SERVER: Subject: PHPMailer GMail SMTP test
2019-10-08 20:18:03 CLIENT -> SERVER: Message-ID: <aIAlUeaoBd7VG6a2DIVHBqZ6KXzxaPmnUxcn1jlcXYQ@localhost>
2019-10-08 20:18:03 CLIENT -> SERVER: X-Mailer: PHPMailer 6.1.1 (https://github.com/PHPMailer/PHPMailer)
2019-10-08 20:18:03 CLIENT -> SERVER: MIME-Version: 1.0
2019-10-08 20:18:03 CLIENT -> SERVER: Content-Type: multipart/alternative;
2019-10-08 20:18:03 CLIENT -> SERVER: boundary="b1_aIAlUeaoBd7VG6a2DIVHBqZ6KXzxaPmnUxcn1jlcXYQ"
2019-10-08 20:18:03 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: This is a multi-part message in MIME format.
2019-10-08 20:18:03 CLIENT -> SERVER: --b1_aIAlUeaoBd7VG6a2DIVHBqZ6KXzxaPmnUxcn1jlcXYQ
2019-10-08 20:18:03 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: This is a plain-text message body
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: --b1_aIAlUeaoBd7VG6a2DIVHBqZ6KXzxaPmnUxcn1jlcXYQ
2019-10-08 20:18:03 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: <h1> Teste </h1>
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: --b1_aIAlUeaoBd7VG6a2DIVHBqZ6KXzxaPmnUxcn1jlcXYQ--
2019-10-08 20:18:03 CLIENT -> SERVER: 
2019-10-08 20:18:03 CLIENT -> SERVER: .
2019-10-08 20:18:04 SMTP INBOUND: "554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A00D884, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:49020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:4E020000, 1.44866:2E010000, 16.55847:E2030000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891500001043050000, 20.50032:140F17898617001000000000, 0.35180:0A000000, 255.23226:0000"
2019-10-08 20:18:04 SERVER -> CLIENT: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A00D884, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:49020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:4E020000, 1.44866:2E010000, 16.55847:E2030000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891500001043050000, 20.50032:140F17898617001000000000, 0.35180:0A000000, 255.23226:0000
2019-10-08 20:18:04 SMTP ERROR: DATA END command failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A00D884, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:49020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:4E020000, 1.44866:2E010000, 16.55847:E2030000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891500001043050000, 20.50032:140F17898617001000000000, 0.35180:0A000000, 255.23226:0000
SMTP Error: data not accepted.
Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A00D884, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:49020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:4E020000, 1.44866:2E010000, 16.55847:E2030000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F17891500001043050000, 20.50032:140F17898617001000000000, 0.35180:0A000000, 255.23226:0000 SMTP code: 554 Additional SMTP info: 5.2.02019-10-08 20:18:04 CLIENT -> SERVER: QUIT
2019-10-08 20:18:04 SMTP INBOUND: "0000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 0.35250:00000000, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:42000000, 1.36674:32000000, 1.61250:00000000, 1.45378:47000000, 1.44866:01000000, 16.55847:AE000000, 17.43559:0000000000030000000000000000000000000000, 20.52176:140F1789150070200A005C85, 20.50032:140F17898617F01F6B050000, 0.35180:0A000000, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:02000000, 4.21921:DC040000, 255.27962:FA"
2019-10-08 20:18:04 SMTP INBOUND: "000000, 255.1494:00000000, 0.38698:0F010480, 0.37692:01000000, 0.37948:13000100, 5.33852:00000000534D545000000100, 7.36354:010000000000010905000780, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000000000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:FDBF0600AF84EF3B000000000000000013000100, 5.10786:0000000031352E32302E323332372E3030343A424C30505231324D42323438343A62366536333132362D623762352D346531622D613639632D34326465393539653533363500101013000100, 7.51330:4AF8789F2C4CD7081300010"
2019-10-08 20:18:04 SMTP INBOUND: "0, 255.1750:AC050000, 255.31418:0A00CF85, 0.22753:0A00F136, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A00F636, 4.30158:DC040000 [Hostname=BL0PR12MB2484.namprd12.prod.outlook.com]"
2019-10-08 20:18:04 SMTP INBOUND: "221 2.0.0 Service closing transmission channel"
2019-10-08 20:18:04 SERVER -> CLIENT: 0000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 0.35250:00000000, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:42000000, 1.36674:32000000, 1.61250:00000000, 1.45378:47000000, 1.44866:01000000, 16.55847:AE000000, 17.43559:0000000000030000000000000000000000000000, 20.52176:140F1789150070200A005C85, 20.50032:140F17898617F01F6B050000, 0.35180:0A000000, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:02000000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:00000000, 0.38698:0F010480, 0.37692:01000000, 0.37948:13000100, 5.33852:00000000534D545000000100, 7.36354:010000000000010905000780, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000000000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:FDBF0600AF84EF3B000000000000000013000100, 5.10786:0000000031352E32302E323332372E3030343A424C30505231324D42323438343A62366536333132362D623762352D346531622D613639632D34326465393539653533363500101013000100, 7.51330:4AF8789F2C4CD70813000100, 255.1750:AC050000, 255.31418:0A00CF85, 0.22753:0A00F136, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A00F636, 4.30158:DC040000 [Hostname=BL0PR12MB2484.namprd12.prod.outlook.com]221 2.0.0 Service closing transmission channel
2019-10-08 20:18:04 SMTP ERROR: QUIT command failed: 0000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 0.35250:00000000, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:42000000, 1.36674:32000000, 1.61250:00000000, 1.45378:47000000, 1.44866:01000000, 16.55847:AE000000, 17.43559:0000000000030000000000000000000000000000, 20.52176:140F1789150070200A005C85, 20.50032:140F17898617F01F6B050000, 0.35180:0A000000, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:02000000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:00000000, 0.38698:0F010480, 0.37692:01000000, 0.37948:13000100, 5.33852:00000000534D545000000100, 7.36354:010000000000010905000780, 4.56248:DC040000, 7.40748:010000000000010B05000780, 7.57132:000000000000000000000000, 1.63016:32000000, 4.39640:DC040000, 8.45434:FDBF0600AF84EF3B000000000000000013000100, 5.10786:0000000031352E32302E323332372E3030343A424C30505231324D42323438343A62366536333132362D623762352D346531622D613639632D34326465393539653533363500101013000100, 7.51330:4AF8789F2C4CD70813000100, 255.1750:AC050000, 255.31418:0A00CF85, 0.22753:0A00F136, 255.21817:DC040000, 4.60547:DC040000, 0.21966:0A00F636, 4.30158:DC040000 [Hostname=BL0PR12MB2484.namprd12.prod.outlook.com]221 2.0.0 Service closing transmission channel
2019-10-08 20:18:04 Connection: closed

A configuração do arquivo PHP

 

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
 
 
require './PHPMailer/Exception.php';
require './PHPMailer/PHPMailer.php';
require './PHPMailer/SMTP.php';


/**

 * This example shows settings to use when sending via Google's Gmail servers.

 * This uses traditional id & password authentication - look at the gmail_xoauth.phps

 * example to see how to use XOAUTH2.

 * The IMAP section shows how to save this message to the 'Sent Mail' folder using IMAP commands.

 */



//Import PHPMailer classes into the global namespace


//Create a new PHPMailer instance

$mail = new PHPMailer;



//Tell PHPMailer to use SMTP

$mail->isSMTP();



//Enable SMTP debugging

// SMTP::DEBUG_OFF = off (for production use)

// SMTP::DEBUG_CLIENT = client messages

// SMTP::DEBUG_SERVER = client and server messages

$mail->SMTPDebug = 4;



//Set the hostname of the mail server

$mail->Host = 'smtp.live.com';

// use

// $mail->Host = gethostbyname('smtp.gmail.com');

// if your network does not support SMTP over IPv6



//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission

$mail->Port = 587;



//Set the encryption mechanism to use - STARTTLS or SMTPS

$mail->SMTPSecure = 'tsl';



//Whether to use SMTP authentication

$mail->SMTPAuth = true;

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);



//Username to use for SMTP authentication - use full email address for gmail

$mail->Username = " meu email "; meu email do hotmail



//Password to use for SMTP authentication

$mail->Password = "senha "; //aqui eu coloquei minha  senha do hotmail



//Set who the message is to be sent from

$mail->setFrom('meuemail@gmail.com', 'First Last');



//Set an alternative reply-to address

$mail->addReplyTo('replyto@example.com', 'First Last');



//Set who the message is to be sent to

$mail->addAddress('meuemail@gmail.com', 'meunome');



//Set the subject line

$mail->Subject = 'PHPMailer GMail SMTP test';



//Read an HTML message body from an external file, convert referenced images to embedded,

//convert HTML into a basic plain-text alternative body

$mail->msgHTML( "<h1> Teste </h1>");



//Replace the plain text body with one created manually

$mail->AltBody = 'This is a plain-text message body';



//Attach an image file

//$mail->addAttachment('images/phpmailer_mini.png');



//send the message, check for errors

if (!$mail->send()) {

    echo "Mailer Error: " . $mail->ErrorInfo;

} else {

    echo "Message sent!";

    //Section 2: IMAP

    //Uncomment these to save your message in the 'Sent Mail' folder.

    #if (save_mail($mail)) {

    #    echo "Message saved!";

    #}

}


?>

Se algum colega puder me dar uma luz eu agradeço. Com Gmail funciona normalmente. 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Veja aqui

 

/**
        *String que armazena o email de onde partirá os emails (remetente).
        *@var string
        */
        const GUSER = 'email';

        /**
        *String que armazena a senha do email de onde partirá os emails (remetente).
        *@var string
        */
        const GPWD = 'senha';

        /**
        *String que armazena o email para qual as mensagens serão enviadas (destinatário).
        *@var string
        */
        const GSEND = 'teste';


       static function contactUsEmail(){

            $emailRemetente = $_POST['email'];
            $name = $_POST['name'];
            $subject = $_POST['subject'];
            $mensagem = $_POST["message"];
            $corpoMensagem = '<b>CONCTACT US EMAIL</b>'.'<br /><b>Email Remetente: </b>'.$emailRemetente.
            '<br /><b>Nome:</b>'.$name.'<br /><b>Assunto:</b>'.$subject.'<br /><b>Mensagem:</b>'.$mensagem;

            $sendResult = SendEmail::smtpMailer(SendEmail::GSEND, SendEmail::GUSER, $name, $subject, $corpoMensagem);

            if($sendResult === true){
                 echo 'Mensagem Enviada com Sucesso';
            }else{
                echo $sendResult;
            }
        }

        function smtpMailer($destinatario, $remetente, $nomeRemetente, $assunto, $corpo){

            /*
            *Objeto que realizará a composição do email com os dados passados como parametros, 
            *armazenara as configurações do servidor SMTP utilizado e todas as outras configurações 
            *e realizará o envio do email.
            *@var PHPMailer object
            */
            $mail = new PHPMailer();

            /**
            *Define o charset do email a ser enviado.
            */
            $mail->CharSet = 'UTF-8';

            /**
            *Ativa SMTP para uso.
            */
            $mail->IsSMTP();

            /**
            *Não exibirá erros e mensagens, outras configurações possiveis: 
            *Debugar: 1 = erros e mensagens, 2 = mensagens apenas.
            */
            $mail->SMTPDebug = 0;

            /**
            *Ativa a autenticação.
            */
            $mail->SMTPAuth = true;

            /**
            *Protocolo utilizado, o gmail (servidor utilizado) requere o uso de tls.
            */
            $mail->SMTPSecure = 'tls';

            /**
            *SMTP utilizado
            */
            $mail->Host = 'smtp.gmail.com';

            /**
            *Porta utilizado para envio de mensagens (ela deverá estar aberta em seu servidor).
            */
            $mail->Port = 587;

            /**
            *Login do usuário utilizado para envio do email (no caso usuário comum do gmail).
            */
            $mail->Username = SendEmail::GUSER;

            /**
            *Senha do login de usuário utilizado para envio do email.
            */
            $mail->Password = SendEmail::GPWD;

            /**
            *Identificação do remetente do email (usuário de email utilizado para envio do 
            *email pelo sistema (logo de propriedade do sistema) e o nome do usuário remetente 
            *(informado na hora da criação do email)) do email.
            */
            $mail->SetFrom($remetente, $nomeRemetente);

            /**
            *Assunto do email.
            */
            $mail->Subject = $assunto;

            /**
            *Corpo do email.
            */
            $mail->Body = $corpo;

            /**
            *Email destinatário do email (de propriedade do sistema).
            */
            $mail->AddAddress($destinatario);

            /**
            *Seta o email como HTML (por padrão ele é text/plain).
            */
            $mail->IsHTML(true);

            $sendResult = $mail->Send();

            if(!$sendResult){
                return "<b>Informações do erro:</b> " . $mail->ErrorInfo;
            }else{
                return true;
            }
        }

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Caro 

 

Paulo, saudações...

 

Tenta essa configuração, abaixo:

<?php defined('BASEPATH') OR exit('No direct script access allowed.');

$config['useragent']         = 'PHPMailer';              // Mail engine switcher: 'CodeIgniter' or 'PHPMailer'
$config['protocol']          = 'smtp';                   // 'mail', 'sendmail', or 'smtp'
$config['mailpath']          = '/usr/sbin/sendmail';
$config['smtp_host']         = 'smtp-mail.outlook.com';
$config['_smtp_auth']        = TRUE;                    // Whether to use SMTP authentication, boolean TRUE/FALSE. If this option is omited or if it is NULL, then SMTP authentication is used when both $config['smtp_user'] and $config['smtp_pass'] are non-empty strings.
$config['smtp_user']         = 'seu_email@hotmail.com';   // Informe um e-mail válido para enviar e-mail
$config['smtp_pass']         = 'sua_senha';               // Informe uma senha válida do seu e-mail informado acima
$config['smtp_port']         = 587;
$config['smtp_timeout']      = 30;                       // (in seconds)
$config['smtp_crypto']       = 'tls';                    // '' or 'tls' or 'ssl'
$config['smtp_debug']        = 0;                        // PHPMailer's SMTP debug info level: 0 = off, 1 = commands, 2 = commands and data, 3 = as 2 plus connection status, 4 = low level data output.
$config['debug_output']      = '';                       // PHPMailer's SMTP debug output: 'html', 'echo', 'error_log' or user defined function with parameter $str and $level. NULL or '' means 'echo' on CLI, 'html' otherwise.
$config['smtp_auto_tls']     = false;                    // Whether to enable TLS encryption automatically if a server supports it, even if `smtp_crypto` is not set to 'tls'.
$config['smtp_conn_options'] = array();                 // SMTP connection options, an array passed to the function stream_context_create() when connecting via SMTP.
$config['wordwrap']          = true;
$config['wrapchars']         = 76;
$config['mailtype']          = 'html';                   // 'text' or 'html'
$config['charset']           = null;                     // 'UTF-8', 'ISO-8859-15', ...; NULL (preferable) means config_item('charset'), i.e. the character set of the site.
$config['validate']          = true;
$config['priority']          = 3;                        // 1, 2, 3, 4, 5; on PHPMailer useragent NULL is a possible option, it means that X-priority header is not set at all, see https://github.com/PHPMailer/PHPMailer/issues/449
$config['crlf']              = "\n";                     // "\r\n" or "\n" or "\r"
$config['newline']           = "\n";                     // "\r\n" or "\n" or "\r"
$config['bcc_batch_mode']    = false;
$config['bcc_batch_size']    = 200;
$config['encoding']          = '8bit';                   // The body encoding. For CodeIgniter: '8bit' or '7bit'. For PHPMailer: '8bit', '7bit', 'binary', 'base64', or 'quoted-printable'.

 

Espero ter ajudado.

 

Atenciosamente,

 

Cesar

Compartilhar este post


Link para o post
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora

  • Conteúdo Similar

    • Por 4Unknow
      Boa tarde pessoal, como vocês estão?
      Estou com uma bronca aqui que, mudei de host, e meu sistema de feedback não envia mais os e-mails por que algumas funções estão desativadas pelo host:

      "A função mail() do PHP é desativada por padrão em todos os nossos servidores. Isso porque é uma função perigosa que pode ser usada por códigos maliciosos para disparar mensagens de spam em massa pela sua hospedagem. Isso gera problemas tanto para seu site, quanto para o servidor como um todo.  Para disparar e-mails você precisa usar SMTP autenticado. Usando o protocolo SMTP você utiliza uma conta de e-mail existente em sua hospedagem para enviar suas mensagens de forma autenticada e segura. "

      Mas como não tenho conhecimento não sei como usar via SMTP.
      Meu arquivo que dispara é este abaixo:

       
      <?php $mail = $_POST['email']; $to = "feedback@roboeverest.app";/* SEU EMAIL */ $subject = "Feedback | Robô Everest"; $headers = "De: Feedback | Robô Everest <naoresponda@roboeverest.app>"; $message = "DETALHES\n"; $message .= "\nPrimeiro Nome: " . $_POST['firstname']; $message .= "\nSegundo Nome: " . $_POST['lastname']; $message .= "\nE-mail: " . $_POST['email']; $message .= "\nIdade: " . $_POST['age']; $message .= "\nGênero: " . $_POST['gender']; $message .= "\nTermos e condições aceitos: " . $_POST['terms']. "\n"; $message .= "\nComo você avalia sua satisfação geral com nossos serviços prestados? " . $_POST['question_1']. "\n"; $message .= "\nComo você ficou sabendo da nossa empresa?\n" ; foreach($_POST['question_2'] as $value) { $message .= "- " . trim(stripslashes($value)) . "\n"; }; $message .= "\nVocê pensa em sugerir nossa empresa para um amigo ou conhecido? " . $_POST['question_3']; if( isset( $_POST['additional_message'] ) && $_POST['additional_message']) { $message .= "\nMensagem Adicional: " . $_POST['additional_message']; } //Receive Variable $sentOk = mail($to,$subject,$message,$headers); //Confirmation page $user = "$mail"; $usersubject = "Obrigado"; $userheaders = "De: feedback@roboeverest.app\n"; /*$usermessage = "Thank you for your time. Your quotation request is successfully submitted.\n"; WITH OUT SUMMARY*/ //Confirmation page WITH SUMMARY $usermessage = "Obrigado pelo seu tempo. Sua solicitação foi enviada com sucesso. Nós responderemos em breve.\n\nABAIXO UM RESUMO\n\n$message"; mail($user,$usersubject,$usermessage,$userheaders); ?>  
      Sou muito leigo, gostaria de fazer envia via SMTP. É difícil de mais?
      Grato se alguém puder me ajudar ou me dar uma luz.
      Abraço.
    • Por fmcmf
      Boa tarde...
      Tenho um formulário no site e o envio é usando o PHPMailer... o email está chegando no destino.... mas o conteúdo inserido nos campos não chega.
       
      Segue o código do formulário em html:
       
      <div id="banner"> <img class="fotobanner" src="img/comprar.png" alt=""> </div> <div class="formulario"> <h3 align="center"> PREENCHA OS DADOS ABAIXO PARA CONTRATAR: </h3> <form action=”envia.php” method=”post” id=”contato”> <div class="form-group"> <label for="exampleFormControlInput1">Nome completo:</label> <input type="nome" class="form-control" id="nome" placeholder="Nome" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">CPF:</label> <input type="cpf" class="form-control" id="cpfcli" placeholder="CPF" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Gênero:</label> <select class="form-control" id="generocli" required> <option>Feminino</option> <option>Masculino</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">Data de Nascimento (dia/mês/ano):</label> <input type="" class="form-control" id="nasccli" placeholder="Data de nascimento (dia/mês/ano)" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Estado Civil:</label> <select class="form-control" id="ecivilcli" required> <option>Casado(a)</option> <option>Solteiro(a)</option> <option>Divorciado(a)</option> <option>Viúvo(a)</option> </select> </div> <div class="form-group"> <label for="exampleFormControlTextarea1">Endereço Completo + CEP:</label> <textarea class="form-control" id="endcli" rows="3" required></textarea> </div> <div class="form-group"> <label for="exampleFormControlInput1">Celular com DDD:</label> <input type="" class="form-control" id="celcli" placeholder="Celular com DDD" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">E-mail:</label> <input type="" class="form-control" id="emailcli" placeholder="E-mail" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">PLANO Desejado:</label> <select class="form-control" id="plano" required> <option>SELECT</option> <option>PLUS</option> <option>TOP</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">NOME do PET:</label> <input type="" class="form-control" id="nomedopet" placeholder="NOME do PET" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">IDADE do PET:</label> <input type="" class="form-control" id="idadedopet" placeholder="IDADE do PET" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Tipo do PET:</label> <select class="form-control" id="tipodopet" required> <option>GATO</option> <option>CACHORRO</option> </select> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Gênero do PET:</label> <select class="form-control" id="generodopet" required> <option>FÊMEA</option> <option>MACHO</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">RAÇA do PET:</label> <input type="" class="form-control" id="racadopet" placeholder="RAÇA do PET" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">PORTE do PET:</label> <select class="form-control" id="portedopet" required> <option>Pequeno</option> <option>Médio</option> <option>Grande</option> </select> </div> <div class="dobotao"> <button type="submit" class="botao"> <strong>ENVIAR DADOS </strong> </button></div> </form></div> Segue o código do enviar.php
       
      <?php require 'PHPMailerAutoload.php'; require 'class.phpmailer.php'; $mailer = new PHPMailer; //$mailer->SMTPDebug = 2; // Enable verbose debug output $mailer->isSMTP(); // Set mailer to use SMTP $mailer->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); if($_GET['acao'] = 'enviar'){ $nome = $_POST['nome']; $cpfcli = $_POST['cpfcli']; $generocli = $_POST['generocli']; $nasccli = $_POST['nasccli']; $ecivilcli = $_POST['ecivilcli']; $celcli = $_POST['celcli']; $plano = $_POST['plano']; $nomedopet = $_POST['nomedopet']; $tipodopet = $_POST['tipodopet']; $generodopet = $_POST['generodopet']; $racadopet = $_POST['racadopet']; $portedopet = $_POST['portedopet']; $mailer->Host = 'pleskl0040.hospedagemdesites.ws'; $mailer->SMTPAuth = true; // Enable SMTP authentication $mailer->IsSMTP(); $mailer->isHTML(true); // Set email format to HTML $mailer->Port = 587; // Ativar condição utf-8, para acentuação $mailer->CharSet = 'UTF-8'; $mailer->Username = 'formulario@thna.com.br'; // SMTP username $mailer->Password = '@Nathi1010'; // SMTP password // email do destinatario $address = "formulario@thna.com.br"; //$mailer->SMTPDebug = 1; $corpoMSG = "nome: $nome <br> cpf: $cpfcli <br> genero: $generocli <br> nascimento: $nasccli <br> estado: $ecivilcli <br> celular: $cel <br> plano: $plano <br> pet: $nomedopet <br> tipo: $tipodopet generopet $generodopet <br> racapet: $racadopet <br> porte: $portedopet"; $mailer->AddAddress($address, "destinatario"); $mailer->AddAddress("formulario@thna.com.br", "destinatario 2"); // 2º destinatário se querer enviar, se não, comente com // $mailer->From = 'formulario@thna.com.br'; $mailer->Sender = 'formulario@thna.com.br'; $mailer->FromName = "Site Saúde PET"; // Seu nome // assunto da mensagem $mailer->Subject = $assunto; // corpo da mensagem $mailer->MsgHTML($corpoMSG); if(!$mailer->Send()) { echo "Erro: " . $mailer->ErrorInfo; } else { echo "Mensagem enviada com sucesso!"; } } header('Location: /pet/confirmado.html');  ?> Como comentei,  o email chega... mas o conteúdo do form não chega... Segue anexo print da caixa do e-mail:
       
      Desde já agradeço.

    • Por fmcmf
      Boa tarde...
      Tenho um formulário no site e o envio é usando o PHPMailer... o email está chegando no destino.... mas o conteúdo inserido nos campos não chega.
       
      Segue o código do formulário em html:
      <div id="banner"> <img class="fotobanner" src="img/comprar.png" alt=""> </div> <div class="formulario"> <h3 align="center"> PREENCHA OS DADOS ABAIXO PARA CONTRATAR: </h3> <form action=”envia.php” method=”post” id=”contato”> <div class="form-group"> <label for="exampleFormControlInput1">Nome completo:</label> <input type="nome" class="form-control" id="nome" placeholder="Nome" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">CPF:</label> <input type="cpf" class="form-control" id="cpfcli" placeholder="CPF" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Gênero:</label> <select class="form-control" id="generocli" required> <option>Feminino</option> <option>Masculino</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">Data de Nascimento (dia/mês/ano):</label> <input type="" class="form-control" id="nasccli" placeholder="Data de nascimento (dia/mês/ano)" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Estado Civil:</label> <select class="form-control" id="ecivilcli" required> <option>Casado(a)</option> <option>Solteiro(a)</option> <option>Divorciado(a)</option> <option>Viúvo(a)</option> </select> </div> <div class="form-group"> <label for="exampleFormControlTextarea1">Endereço Completo + CEP:</label> <textarea class="form-control" id="endcli" rows="3" required></textarea> </div> <div class="form-group"> <label for="exampleFormControlInput1">Celular com DDD:</label> <input type="" class="form-control" id="celcli" placeholder="Celular com DDD" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">E-mail:</label> <input type="" class="form-control" id="emailcli" placeholder="E-mail" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">PLANO Desejado:</label> <select class="form-control" id="plano" required> <option>SELECT</option> <option>PLUS</option> <option>TOP</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">NOME do PET:</label> <input type="" class="form-control" id="nomedopet" placeholder="NOME do PET" required> </div> <div class="form-group"> <label for="exampleFormControlInput1">IDADE do PET:</label> <input type="" class="form-control" id="idadedopet" placeholder="IDADE do PET" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Tipo do PET:</label> <select class="form-control" id="tipodopet" required> <option>GATO</option> <option>CACHORRO</option> </select> </div> <div class="form-group"> <label for="exampleFormControlSelect1">Gênero do PET:</label> <select class="form-control" id="generodopet" required> <option>FÊMEA</option> <option>MACHO</option> </select> </div> <div class="form-group"> <label for="exampleFormControlInput1">RAÇA do PET:</label> <input type="" class="form-control" id="racadopet" placeholder="RAÇA do PET" required> </div> <div class="form-group"> <label for="exampleFormControlSelect1">PORTE do PET:</label> <select class="form-control" id="portedopet" required> <option>Pequeno</option> <option>Médio</option> <option>Grande</option> </select> </div> <div class="dobotao"> <button type="submit" class="botao"> <strong>ENVIAR DADOS </strong> </button></div> </form></div>  
      Segue o código do enviar.php

       
      <?php require 'PHPMailerAutoload.php'; require 'class.phpmailer.php'; $mailer = new PHPMailer; //$mailer->SMTPDebug = 2; // Enable verbose debug output $mailer->isSMTP(); // Set mailer to use SMTP $mailer->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); if($_GET['acao'] = 'enviar'){ $nome = $_POST['nome']; $cpfcli = $_POST['cpfcli']; $generocli = $_POST['generocli']; $nasccli = $_POST['nasccli']; $ecivilcli = $_POST['ecivilcli']; $celcli = $_POST['celcli']; $plano = $_POST['plano']; $nomedopet = $_POST['nomedopet']; $tipodopet = $_POST['tipodopet']; $generodopet = $_POST['generodopet']; $racadopet = $_POST['racadopet']; $portedopet = $_POST['portedopet']; $mailer->Host = 'pleskl0040.hospedagemdesites.ws'; $mailer->SMTPAuth = true; // Enable SMTP authentication $mailer->IsSMTP(); $mailer->isHTML(true); // Set email format to HTML $mailer->Port = 587; // Ativar condição utf-8, para acentuação $mailer->CharSet = 'UTF-8'; $mailer->Username = 'formulario@thna.com.br'; // SMTP username $mailer->Password = '@Nathi1010'; // SMTP password // email do destinatario $address = "formulario@thna.com.br"; //$mailer->SMTPDebug = 1; $corpoMSG = "nome: $nome <br> cpf: $cpfcli <br> genero: $generocli <br> nascimento: $nasccli <br> estado: $ecivilcli <br> celular: $cel <br> plano: $plano <br> pet: $nomedopet <br> tipo: $tipodopet generopet $generodopet <br> racapet: $racadopet <br> porte: $portedopet"; $mailer->AddAddress($address, "destinatario"); $mailer->AddAddress("formulario@thna.com.br", "destinatario 2"); // 2º destinatário se querer enviar, se não, comente com // $mailer->From = 'formulario@thna.com.br'; $mailer->Sender = 'formulario@thna.com.br'; $mailer->FromName = "Site Saúde PET"; // Seu nome // assunto da mensagem $mailer->Subject = $assunto; // corpo da mensagem $mailer->MsgHTML($corpoMSG); if(!$mailer->Send()) { echo "Erro: " . $mailer->ErrorInfo; } else { echo "Mensagem enviada com sucesso!"; } } header('Location: /pet/confirmado.html'); ?> Como comentei,  o email chega... mas o conteúdo do form não chega... Segue anexo print da caixa do e-mail:
       
      Desde já agradeço.
       
       
       
       

    • Por clayton.lima2020
      Bom dia!
       
      Pessoal estou com um problema estou tentando enviar um e-mail através de um formulário que criei no site da empresa que eu trabalho, porém na hora de enviar está dando erro.
       
      Obs: a hospedagem do site está na Locaweb
       
      Segue abaixo o erro:
       
      Fatal error: Uncaught Error: Call to undefined function eregi() in /home/storage/2/a8/c3/odontosmilesfran1/public_html/class.phpmailer.php:593 Stack trace: #0 /home/storage/2/a8/c3/odontosmilesfran1/public_html/class.phpmailer.php(518): PHPMailer->SmtpConnect() #1 /home/storage/2/a8/c3/odontosmilesfran1/public_html/class.phpmailer.php(410): PHPMailer->SmtpSend('Date: Sat, 5 Ju...', '--b1_b48d510d23...') #2 /home/storage/2/a8/c3/odontosmilesfran1/public_html/envio-franqueador.php(55): PHPMailer->Send() #3 {main} thrown in /home/storage/2/a8/c3/odontosmilesfran1/public_html/class.phpmailer.php on line 593
       
      Segue o código do script de envio:
       

        <? require_once("class.phpmailer.php"); //Nova instância do PHPMailer $mail = new PHPMailer; //Informa que será utilizado o SMTP para envio do e-mail $mail->IsSMTP(); //Informa que a conexão com o SMTP será autênticado $mail->SMTPAuth   = true; //Configura a segurança para SSL $mail->SMTPSecure = "ssl"; $mail->Port       = 465; $mail->Host       = "email-ssl.com.br"; //Usuário para autênticação do SMTP $mail->Username =   "sejaumfranqueado@odontosmilesfranchising.com.br"; //Senha para autênticação do SMTP $mail->Password =   "12345678"; // senha ficticia //Titulo do e-mail que será enviado $mail->Subject  =   "PEDIDO PARA SER UM FRANQUEADOR"; //Preenchimento do campo FROM do e-mail $mail->From = $mail->Username; $mail->FromName = $_POST['nome']; // Nome do remetente //E-mail para a qual o e-mail será enviado $mail->AddAddress("sejaumfranqueado@odontosmilesfranchising.com.br"); //Conteúdo do e-mail //$mail->Body = "Novo contato feito através do site Araújo Imóveis.";      $mail->From     = $_POST['email']; // E-mail do remetente         $mail->Body .= "Modelo de Franquia: ".$_POST['modelo']."<br>";         $mail->Body .= "Nome: ".$_POST['nome']."<br>";     $mail->Body .= "Email: ".$_POST['email']."<br>";      $mail->Body .= "Fone Móvel: ".$_POST['fone']."<br>";     $mail->Body .= "Fone Fixo: ".$_POST['movel']."<br>";     $mail->Body .= "Estado: ".$_POST['estado']."<br>";     $mail->Body .= "Cidade: ".$_POST['cidade']."<br>";           $mail->Body .= "Mensagem: ".nl2br($_POST['mensagem'])."";                        $mail->AltBody = $mail->Body; //Dispara o e-mail $enviado = $mail->Send(); //Imprime sucesso. if($enviado)   echo "<script>alert('Sua mensagem foi enviada com sucesso!')</script>"; echo "<meta http-equiv='refresh' content='2;URL=index.php'>"; ?>  
      Segue o trecho do código do arquivo class.phpmailer.php onde está dando o erro
       

         /* Choose the mailer */     switch($this->Mailer) {       case 'sendmail':         $result = $this->SendmailSend($header, $body);         break;       case 'smtp': [b][color=red]         $result = $this->SmtpSend($header, $body); // nessa linha 410 está dando erro [/color][/b]         break;       case 'mail':         $result = $this->MailSend($header, $body);         break;       default:         $result = $this->MailSend($header, $body);         break;         //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));         //$result = false;         //break;     }     return $result;   }   /**   Aqui está outro trecho do código:    /* Retry while there is no connection */     while($index < count($hosts) && $connection == false) {       $hostinfo = array(); [b][color=red]      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { // aqui está dando erro linha 593[/color][/b]         $host = $hostinfo[1];         $port = $hostinfo[2];       } else {         $host = $hosts[$index];         $port = $this->Port;       }       $tls = ($this->SMTPSecure == 'tls');       $ssl = ($this->SMTPSecure == 'ssl');       if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {         $hello = ($this->Helo != '' ? $this->Hello : $this->ServerHostname());         $this->smtp->Hello($hello);         if($tls) {           if(!$this->smtp->StartTLS()) {             $this->SetError($this->Lang("tls"));             $this->smtp->Reset();             $connection = false;           }           //We must resend HELLO after tls negociation           $this->smtp->Hello($hello);         }         $connection = true;         if($this->SMTPAuth) {           if(!$this->smtp->Authenticate($this->Username, $this->Password)) {             $this->SetError($this->Lang('authenticate'));             $this->smtp->Reset();             $connection = false;           }         }       }       $index++;     }     if(!$connection) {       $this->SetError($this->Lang('connect_host'));     }     return $connection;   }    

      Obrigado a todos que puderem ajudar
       
       
    • Por DinhoPHP
      Estou tentando enviar um anexo e o mesmo não chega no email, apenas quando não faço uso da função attach.
      arquivo que contém as functions responsáveis pelo envio do email.
      public function attach(string $filePath, string $fileName): Email{ $this->data->attach[$filePath] = $fileName; return $this; } Arquivo que utiliza a função attach.
      No arquivo que captura os dados do formulário, já passei os parâmetros de tudo quanto é jeito.
      require __DIR__ . "/include/head.php"; require __DIR__ . "/vendor/autoload.php"; use Source\Support\Email; $email = new Email(); // CAPTURANDO DADOS DO FORMULÁRIO $nome = trim(ucwords(preg_replace('/\s\s+/', ' ',($_POST['nome-curriculo'])))); $eemail = trim(strtolower(preg_replace('/\s\s+/', ' ',($_POST['email-curriculo'])))); $telefone = trim(preg_replace('/\s\s+/', ' ',($_POST['telefone-curriculo']))); $cidade = trim(preg_replace('/\s\s+/', ' ',($_POST['cidade-curriculo']))); $assunto = trim(preg_replace('/\s\s+/', ' ',($_POST['assunto-curriculo']))); $mensagem = trim(preg_replace('/\s\s+/', ' ',("<pre>".$_POST['mensagem-curriculo']."</pre>"))); // $file_tmp = ($_FILES['file'], $_POST['name']); $files = $_FILES['curriculo']; $email->add($assunto, "<h3>Nome: {$nome}<br>{$files['name']}<br>Email: {$eemail}<br><br>Telefone: {$telefone}<br><br>Cidade: {$cidade}<br><br></br>Mensagem:<br>{$mensagem}</h3>", $nome, $eemail)->attach($files['tmp_name'], $files['name'])->send(); var_dump($files); A função attach que recebe dois parâmetros, quando utilizada, não envia o anexo vindo do form HTML, já digitando os parâmetros na função, ela envia o anexo. Já li até alguns casos semelhantes aqui mesmo e nada! Só envia o anexo digitando os parâmetros manualmente. 
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.