Vorrei inviare tramite phpmailer e smtp autenticato di office365.
Lo sto provando in locale tramite XAMPP.
codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHPMailer SMTP Autenticato</title> </head> <body> <?php //includiamo la classe PHPMailer require "PHPMailer/class.phpmailer.php"; require "PHPMailer/class.smtp.php"; $from = "miamail@outlook.com"; $from_name = "VALENTINO Luca"; $to = "miamailr@outlook.com"; $oggetto=" SMTP autenticato con PHPMailer"; $mail = new PHPMailer(); // creiamo l"oggetto $mail->IsSMTP(); // abilitiamo l"SMTP $mail->SMTPDebug = 1; // debug: 1 = solo messaggi, 2 = errori e messaggi $mail->SMTPAuth = true; // abilitiamo l"autenticazione $mail->SMTPSecure = "STARTTLS"; // abilitiamo il protocollo tls richiesto per office365 $mail->Host = "smtp.office365.com"; // ecco il server smtp di office365 $mail->Port = 587; // la porta che dobbiamo utilizzare $mail->Username = "miamailr@outlook.com"; //email del nostro account office365 $mail->Password = 'pass$word'; //password del nostro account office365 $mail->SetFrom($from, $from_name); $mail->Subject = $oggetto; $mail->Body = "invio email non html"; $mail->AddAddress($to); //inseriamo i tag HTML e i CSS per formattare il messaggio $mail->Body = "<html><body><head><style>"; $mail->Body .= ".up{background-color:#FF0000;color:#000000;font-size:12px}"; $mail->Body .= ".down{color:#FF0000;text-align:left;font-size:15px}"; $mail->Body .= "</style></head>"; $mail->Body .= "<center><table><tr><td class=\'up\'>Ciao!!</td></tr>"; $mail->Body .= "<tr><td class=\'down\'>ciao!!!</td></tr></table></center>"; $mail->Body .= "</body></html>"; // Invio Email e controllo esito if($mail->Send()) { echo "Email inviata correttamente"; } else { echo "Errore: email non inviata. " . $mail->ErrorInfo; } ?> </body> </html>
L'errore che mi da il codice:
codice:SMTP -> ERROR: AUTH not accepted from server: 504 5.7.4 Unrecognized authentication type SMTP -> ERROR: MAIL not accepted from server: 530 5.7.1 Client was not authenticated The following From address failed: miamailr@outlook.com : MAIL not accepted from server,530,5.7.1 Client was not authenticated SMTP server error: 5.7.1 Client was not authenticated Errore: email non inviata. The following From address failed: assistsegr@biblico.it : MAIL not accepted from server,530,5.7.1 Client was not authenticated SMTP server error: 5.7.1 Client was not authenticated SMTP server error: 5.7.1 Client was not authenticated

Rispondi quotando
