Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
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><?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.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';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['bcc_batch_mode'] = false;
$config['bcc_batch_size'] = 200;Espero ter ajudado.
Atenciosamente,
Cesar
Veja aqui
/**
*String que armazena o email de onde partirá os emails (remetente).
*@var string
*/