PHPMailer non funziona

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
Ragazzi sto cercando di usare PHPMailer per ricevere emails tramite un contact form ma c'è qualcosa che non va nel codice perchè ho sempre errore.

PHP:
<?php
require 'src/PHPMailerAutoload.php';

$fromEmail = '[email protected]';
$fromName = 'Demo contact form';

$sendToEmail = '[email protected]';
$sendToName = 'Demo contact form';

$subject = 'Nuovo messaggio';

$smtpHost = 'smtp.tiscali.it';
$smtpUsername = '[email protected]';
$smtpPassword = '12345';

$fields = array('name' => 'Name', 'surname' => 'Surname', 'email' => 'Email', 'message' => 'Message');

$okMessage = 'Email inviata consuccesso!';

$errorMessage = 'Impossibile inviare la mail';

error_reporting(E_ALL & ~E_NOTICE);

try {
    if (count($_POST) == 0) {
        throw new \Exception('Campi vuoti');
    }
   
    $emailTextHtml = "<h1>Nuovo messaggio dal form</h1><hr>";
    $emailTextHtml .= "<table>";
   
    foreach ($_POST as $key => $value) {
        if (isset($fields[$key])) {
            $emailTextHtml .= "<tr><th>$fields[$key]</th><td>$value</td></tr>";
        }
    }
    $emailTextHtml .= "</table><hr>";
    $emailTextHtml .= "<p>Buona giornata,<br>Salutij</p>";
   
    $mail = new PHPMailer;
   
    $mail->setFrom($fromEmail, $fromName);
    $mail->addAddress($sendToEmail, $sendToName);
    $mail->addReplyTo($from);
   
    $mail->isHTML(true);
   
    $mail->Subject = $subject;
    $mail->Body    = $emailTextHtml;
    $mail->msgHTML($emailTextHtml);
   
    $mail->isSMTP();
   
    $mail->SMTPDebug = 0;
    $mail->Debugoutput = 'html';
   
   $mail->Host = gethostbyname($smtpHost);
   
    $mail->Port = 587;
   
    $mail->SMTPSecure = 'tls';
   
    $mail->SMTPAuth = true;
   
    $mail->Username = $smtpHost;
   
    $mail->Password = $smtpPassword;
   
    if (!$mail->send()) {
        throw new \Exception('I could not send the email.' . $mail->ErrorInfo);
    }
   
    $responseArray = array('type' => 'success', 'message' => $okMessage);
} catch (\Exception $e) {
    // $responseArray = array('type' => 'danger', 'message' => $errorMessage);
    $responseArray = array('type' => 'danger', 'message' => $e->getMessage());
}

Chi mi da una manina? :D
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
qui ci va il nome dell'utente titolare dell'account
$mail->Username = $smtpHost;

ti consiglio di usare il parametro 4 per il debug, soprattutto nella fase di test, per vedere come avviene la connessione al server della posta ed eventuali errori
$mail->SMTPDebug = 4;

rifatti vivo se non risolvi
 

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
qui ci va il nome dell'utente titolare dell'account
$mail->Username = $smtpHost;

ti consiglio di usare il parametro 4 per il debug, soprattutto nella fase di test, per vedere come avviene la connessione al server della posta ed eventuali errori
$mail->SMTPDebug = 4;

rifatti vivo se non risolvi
Ciao Marino, grazie per aver risposto. Ho seguito il tuo consiglio e come Debug output ho questo:

Codice:
2018-12-08 15:50:31 Connection: opening to 213.209.1.144:587, timeout=300, options=array ()
2018-12-08 15:50:32 Connection: opened
2018-12-08 15:50:32 SMTP -> get_lines(): $data is ""
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "220 smtp-16.iol.local smtp-16.iol.local ESMTP server ready"
2018-12-08 15:50:32 SERVER -> CLIENT: 220 smtp-16.iol.local smtp-16.iol.local ESMTP server ready
2018-12-08 15:50:32 CLIENT -> SERVER: EHLO localhost
2018-12-08 15:50:32 SMTP -> get_lines(): $data is ""
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-HELP"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-SIZE 50000000"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 50000000"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-8BITMIME"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 50000000250-8BITMIME"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250-STARTTLS"
2018-12-08 15:50:32 SMTP -> get_lines(): $data is "250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 50000000250-8BITMIME250-STARTTLS"
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "250 OK"
2018-12-08 15:50:32 SERVER -> CLIENT: 250-smtp-16.iol.local hello [87.21.186.253], pleased to meet you250-HELP250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 50000000250-8BITMIME250-STARTTLS250 OK
2018-12-08 15:50:32 CLIENT -> SERVER: STARTTLS
2018-12-08 15:50:32 SMTP -> get_lines(): $data is ""
2018-12-08 15:50:32 SMTP -> get_lines(): $str is "220 Ready to start TLS"
2018-12-08 15:50:32 SERVER -> CLIENT: 220 Ready to start TLS
2018-12-08 15:50:32 Connection failed. Error #2: stream_socket_enable_crypto(): Peer certificate CN=`*.libero.it' did not match expected CN=`213.209.1.144' [C:\xampp\htdocs\prova\src\class.smtp.php line 374]
SMTP Error: Could not connect to SMTP host.
2018-12-08 15:50:32 CLIENT -> SERVER: QUIT
2018-12-08 15:50:33 SMTP -> get_lines(): $data is ""
2018-12-08 15:50:33 SMTP -> get_lines(): $str is ""
2018-12-08 15:50:33 SERVER -> CLIENT:
2018-12-08 15:50:33 SMTP ERROR: QUIT command failed:
2018-12-08 15:50:33 Connection: closed
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Sapresti indicarmi dov'è l'errore? Grazie :)
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
nello script del primo post leggo che usi tiscali come provider di posta
$smtpHost = 'smtp.tiscali.it';

nel debug che hai postato usi invece libero.it
se fai ping di "smtp.libero.it" ti risponde l'indirizzo ip sottostante
213.209.1.144

i parametri da usare per la connessione a "libero.it" sono,
PHP:
            $eM_Host     = "smtp.libero.it";     // ok PHPmailer
            $eM_Port     = 465;
            $eM_Auth     = true;
            $eM_Secure   = "ssl";
            $eM_Username = "[email protected]";
            $eM_Password = "CAMBIAMI";
inserisci questi parametri nel tuo script
 

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
nello script del primo post leggo che usi tiscali come provider di posta
$smtpHost = 'smtp.tiscali.it';

nel debug che hai postato usi invece libero.it
se fai ping di "smtp.libero.it" ti risponde l'indirizzo ip sottostante
213.209.1.144

i parametri da usare per la connessione a "libero.it" sono,
PHP:
            $eM_Host     = "smtp.libero.it";     // ok PHPmailer
            $eM_Port     = 465;
            $eM_Auth     = true;
            $eM_Secure   = "ssl";
            $eM_Username = "[email protected]";
            $eM_Password = "CAMBIAMI";
inserisci questi parametri nel tuo script
Fatto, ora mi da questo:

Codice:
2018-12-08 20:31:20 Connection: opening to ssl://213.209.1.144:465, timeout=300, options=array ()
2018-12-08 20:31:21 Connection failed. Error #2: stream_socket_client(): Peer certificate CN=`*.libero.it' did not match expected CN=`213.209.1.144' [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-08 20:31:21 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-08 20:31:21 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://213.209.1.144:465 (Unknown error) [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-08 20:31:21 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

:(
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
prova ad inserire queste opzioni nel tuo script, in posizione successiva ai parametri di connessione soprastanti
PHP:
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
 

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
Allora, riposto il codice perchè con il primo ho fatto un casino, questa volta è con tiscali:

PHP:
<?php
require 'src/PHPMailerAutoload.php';

$fromEmail = $_POST['email'];
$fromName = 'Demo contact form';

$sendToEmail = '[email protected]';
$sendToName = 'Davide';

$subject = 'Nuovo messaggio';

$smtpHost = 'smtp.tiscali.it';
$smtpUsername = '[email protected]';
$smtpPassword = '12345';

$fields = array('name' => 'Name', 'surname' => 'Surname', 'email' => 'Email', 'subject' => 'Subject', 'message' => 'Message');

$okMessage = 'Email inviata consuccesso!';

$errorMessage = 'Impossibile inviare la mail';

error_reporting(E_ALL & ~E_NOTICE);

try {
    if (count($_POST) == 0) {
        throw new \Exception('Campi vuoti');
    }
 
    $emailTextHtml = "<h1>Nuovo messaggio dal form</h1><hr>";
    $emailTextHtml .= "<table>";
 
    foreach ($_POST as $key => $value) {
        if (isset($fields[$key])) {
            $emailTextHtml .= "<tr><th>$fields[$key]</th><td>$value</td></tr>";
        }
    }
    $emailTextHtml .= "</table><hr>";
    $emailTextHtml .= "<p>Buona giornata,<br>Saluti</p>";
 
    $mail = new PHPMailer;
 
    $mail->setFrom($fromEmail, $fromName);
    $mail->addAddress($sendToEmail, $sendToName);
    //$mail->addReplyTo($from);
 
    $mail->isHTML(true);
 
    $mail->Subject = $subject;
    $mail->Body    = $emailTextHtml;
    $mail->msgHTML($emailTextHtml);
 
    $mail->isSMTP();
 
    $mail->SMTPDebug = 4;
    $mail->Debugoutput = 'html';
 
   $mail->Host = gethostbyname('smtp.tiscali.it');
 
    $mail->Port = 465;
 
    $mail->SMTPSecure = 'ssl';
 
    $mail->SMTPAuth = true;
 
    $mail->Username = '[email protected]';
 
    $mail->Password = 12345';
   
     if (!$mail->send()) {
        throw new \Exception('I could not send the email.' . $mail->ErrorInfo);
    }
 
    $responseArray = array('type' => 'success', 'message' => $okMessage);
} catch (\Exception $e) {
    // $responseArray = array('type' => 'danger', 'message' => $errorMessage);
    $responseArray = array('type' => 'danger', 'message' => $e->getMessage());
}

E questo è il debug output:

Codice:
2018-12-09 15:26:20 Connection: opening to ssl://213.205.33.13:465, timeout=300, options=array ()
2018-12-09 15:26:20 Connection failed. Error #2: stream_socket_client(): Peer certificate CN=`*.tiscali.it' did not match expected CN=`213.205.33.13' [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-09 15:26:20 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-09 15:26:20 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://213.205.33.13:465 (Unknown error) [C:\xampp\htdocs\prova\src\class.smtp.php line 298]
2018-12-09 15:26:20 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Questo invece è il debug output con:

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

Codice:
2018-12-09 15:28:36 Connection: opening to ssl://213.205.33.13:465, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),)
2018-12-09 15:28:37 Connection: opened
2018-12-09 15:28:37 SMTP -> get_lines(): $data is ""
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "220 santino.mail.tiscali.it ESMTP service ready"
2018-12-09 15:28:37 SERVER -> CLIENT: 220 santino.mail.tiscali.it ESMTP service ready
2018-12-09 15:28:37 CLIENT -> SERVER: EHLO localhost
2018-12-09 15:28:37 SMTP -> get_lines(): $data is ""
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you"
2018-12-09 15:28:37 SMTP -> get_lines(): $data is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you"
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5"
2018-12-09 15:28:37 SMTP -> get_lines(): $data is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5"
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250-SIZE 34865152"
2018-12-09 15:28:37 SMTP -> get_lines(): $data is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 34865152"
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
2018-12-09 15:28:37 SMTP -> get_lines(): $data is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 34865152250-ENHANCEDSTATUSCODES"
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250-8BITMIME"
2018-12-09 15:28:37 SMTP -> get_lines(): $data is "250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 34865152250-ENHANCEDSTATUSCODES250-8BITMIME"
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "250 OK"
2018-12-09 15:28:37 SERVER -> CLIENT: 250-santino.mail.tiscali.it hello [79.22.177.243], pleased to meet you250-AUTH LOGIN PLAIN CRAM-MD5 DIGEST-MD5250-SIZE 34865152250-ENHANCEDSTATUSCODES250-8BITMIME250 OK
2018-12-09 15:28:37 Auth method requested: UNKNOWN
2018-12-09 15:28:37 Auth methods available on the server: LOGIN,PLAIN,CRAM-MD5,DIGEST-MD5
2018-12-09 15:28:37 Auth method selected: CRAM-MD5
2018-12-09 15:28:37 CLIENT -> SERVER: AUTH CRAM-MD5
2018-12-09 15:28:37 SMTP -> get_lines(): $data is ""
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "334 PDkyNzMzLjE1NDQzNjkzMThAc2FudGluby5tYWlsLnRpc2NhbGkuaXQ+"
2018-12-09 15:28:37 SERVER -> CLIENT: 334 PDkyNzMzLjE1NDQzNjkzMThAc2FudGluby5tYWlsLnRpc2NhbGkuaXQ+
2018-12-09 15:28:37 CLIENT -> SERVER: ZGF2aWRlbWFyY2FAdGlzY2FsaS5pdCAxZjJkY2FkODJhNjAwZTY0NTYyZTkxNjg0YTMxMzYyMw==
2018-12-09 15:28:37 SMTP -> get_lines(): $data is ""
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "235 2.7.0 CRAM-MD5 authentication successful"
2018-12-09 15:28:37 SERVER -> CLIENT: 235 2.7.0 CRAM-MD5 authentication successful
2018-12-09 15:28:37 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2018-12-09 15:28:37 SMTP -> get_lines(): $data is ""
2018-12-09 15:28:37 SMTP -> get_lines(): $str is "550 5.1.0 <[email protected]> sender rejected - il mittente non coincide con la username configurata per l'autenticazione. Vedi http://assistenza.tiscali.it/tecnica/posta/mancato_invio.php"
2018-12-09 15:28:37 SERVER -> CLIENT: 550 5.1.0 <[email protected]> sender rejected - il mittente non coincide con la username configurata per l'autenticazione. Vedi http://assistenza.tiscali.it/tecnica/posta/mancato_invio.php
2018-12-09 15:28:37 SMTP ERROR: MAIL FROM command failed: 550 5.1.0 <[email protected]> sender rejected - il mittente non coincide con la username configurata per l'autenticazione. Vedi http://assistenza.tiscali.it/tecnica/posta/mancato_invio.php
The following From address failed: [email protected] : MAIL FROM command failed,<[email protected]> sender rejected - il mittente non coincide con la username configurata per l'autenticazione. Vedi http://assistenza.tiscali.it/tecnica/posta/mancato_invio.php,550,5.1.0SMTP server error: MAIL FROM command failed Detail: <[email protected]> sender rejected - il mittente non coincide con la username configurata per l'autenticazione. Vedi http://assistenza.tiscali.it/tecnica/posta/mancato_invio.php SMTP code: 550 Additional SMTP info: 5.1.0
2018-12-09 15:28:37 CLIENT -> SERVER: QUIT
2018-12-09 15:28:37 SERVER -> CLIENT:
2018-12-09 15:28:37 SMTP ERROR: QUIT command failed:
2018-12-09 15:28:37 Connection: closed

"[email protected]" è il finto indirizzo email che ho inserito nel campo Email del form.
 
Ultima modifica:

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
I parametri di connessione al server di posta di tiscali sono sicuramente diversi da quelli di libero
non ho un utente tiscali, per cui non posso indicarteli, cercali sul sito di tiscali
poi leggeri attentamente il log e porta le opportune correzioni al tuo script
 

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
Ciao Marino...dunque credo di avere un pò di confusione in testa, ti spiego: ho creato un contact form e vorrei far in modo che quando un utente lo utilizza phpmailer mi invii una mail con tutti i dati che sono stati inseriti nel form...compreso l'indirizzo email che va inserito nel campo email. Ora...il problema è proprio quest'ultimo, infatti phpmailer mi da sempre errore in "$mail->setFrom();":

Codice:
The following From address failed: [email protected] : MAIL FROM command failed,Requested action not taken: mailbox unavailableSender address is not allowed.,550,SMTP server error: MAIL FROM command failed Detail: Requested action not taken: mailbox unavailableSender address is not allowed. SMTP code: 550

a meno che in "$mail->setFrom();" non inserisca l'indirizzo email dell'host che sto utilizzando, in questo caso la mail viene inviata senza problema.

Cosa devo fare?

Ti posto il codice che sto usando ora, quello che ho inserito precedentemente forse è un pò troppo complicato al momento :D:

PHP:
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

$msg = '';
if (array_key_exists('email', $_POST)) {
    date_default_timezone_set('Etc/UTC');

    require 'src/Exception.php';
    require 'src/PHPMailer.php';
    require 'src/SMTP.php';
   
    $mail = new PHPMailer;
   
    $mail->SMTPDebug = 2;
    $mail->isSMTP();
    $mail->Host = 'smtp.mail.com';
    $mail->Username = '[email protected]';
    $mail->Password = '12345';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
   
    $mail->setFrom($_POST['email'], $_POST['name']);
    $mail->addAddress('[email protected]', 'John');
   
    if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
        $mail->Subject = 'PHPMailer contact form';
        $mail->isHTML(false);
        $mail->Body = <<<EOT

Email: {$_POST['email']}
Name: {$_POST['name']}
Message: {$_POST['message']}
EOT;
         if (!$mail->send()) {
             $msg = 'Sorry, something went wrong. Please try again later.';
        } else {
            $msg = 'Message sent! Thanks for contacting us.';
        }
    } else {
        $msg = 'Invalid email address, message ignored.';
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Contact form</title>
</head>
<body>
<h1>Contact us</h1>
<?php if (!empty($msg)) {
    echo "<h2>$msg</h2>";
} ?>
<form method="POST">
    <label for="name">Name: <input type="text" name="name" id="name"></label><br>
    <label for="email">Email address: <input type="email" name="email" id="email"></label><br>
    <label for="message">Message: <textarea name="message" id="message" rows="8" cols="20"></textarea></label><br>
    <input type="submit" value="Send">
</form>
</body>
</html>

Nel codice ho provato con "$mail->setFrom($_POST['email'], $_POST['name']);" ma non va, posso anche dirti che non è un problema di smtp o di porta.

Grazie!
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
Ora...il problema è proprio quest'ultimo, infatti phpmailer mi da sempre errore in "$mail->setFrom();":
premesso che l'indirizzo FROM deve essere un indirizzo valido non solo nella sintassi ma anche realmente esietente,
esistono regole internazionali che lo impongono,
non si può inventare un indirizzo al momento ed inserirlo come indirizzo del mittente,
a meno che in "$mail->setFrom();" non inserisca l'indirizzo email dell'host che sto utilizzando, in questo caso la mail viene inviata senza problema.
anche in questo caso occorre fare attenzione perchè
alcuni provider di posta vogliono l'indirizzo email dell'host che si sta utilizzando per questioni di sicurezza
altri accettano indirizzi esistenti anche se di altri provider, ma la mail potrebbe finire nella casella "spam" quindi non essere visibile nella posta in arrivo
mai viene accettato un indirizzo inesistente

quindi inserisci l'indirizzo email dell'host che stai utilizzando, risolvendo così il problema

eventualmente ti servisse verifica la possibilità di usare l'indirizzo "ReplyTo"
 

iTonto

Utente Attivo
8 Feb 2018
107
2
18
www.fiverr.com
Quindi tu dici di mettere in setFrom() l'indirizzo dell'host/provider che sto utilizzando? In questo modo però nella casella email alla voce "Da:" apparirà il mio indirizzo e non quello dell'utente che ha inviato la mail...
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
Quindi tu dici di mettere in setFrom() l'indirizzo dell'host/provider che sto utilizzando? In questo modo però nella casella email alla voce "Da:" apparirà il mio indirizzo e non quello dell'utente che ha inviato la mail...
ti ho scritto nel post precedente,
eventualmente ti servisse verifica la possibilità di usare l'indirizzo "ReplyTo"

nel "ReplyTo" metti l'indirizzo mail dell'utente che ha inviato la mail
prova e mi dici che succede …..
 

marino51

Utente Attivo
28 Feb 2013
3.203
207
63
Lombardia
di nuovo, prova ad inserire l'indirizzo mail del contatto nel "FROM"
$mailer->FromName = 'mailer';
$mailer->From = '........@..........….';

se il provider lo accetta, problema risolto,

se non lo accetta, lascia "ReplyTo" ed inserosci indirizzo mail nell'oggetto o nel corpo del messaggio
 
  • Like
Reactions: iTonto
Discussioni simili
Autore Titolo Forum Risposte Data
Z email phpmailer non arrivano PHP 0
metalgemini PHPmailer non arriva allegato PHP 10
G phpmailer e php 8.1 con estensione mysqli PHP 6
E Hosting e phpmailer PHP 0
E PHPMailer PHP 4
D PHPMailer con account gmail PHP 14
I Guida/Tutorial configurare PHPMailer per inviare mails tramite contact form? PHP 2
A PHPMAILER e UMLAUTS (lettere tedesche äüäöß) PHP 2
G PHPMailer: SMTP error Gmail PHP 8
M Come usare la nuova versione di phpmailer? PHP 2
P [PHPmailer] SMTP Aruba.. problemi PHP 8
G Invio Mail con PHPMailer, problemi SMTP PHP 7
V PHPMailer PHP 11
V PHPmailer allegato PHP 0
P problemi invio email con phpmailer PHP 47
P phpmailer PHP 0
localhost.nicola File log erroe con phpmailer PHP 3
A problema phpmailer PHP 32
L invio smtp con phpmailer - problema invia due volte la email allo stesso utente PHP 0
O PhpMailer, Composer e Netbeans PHP 1
M Come inviare due mail diverse con phpmailer PHP 6
B Invio email multiple PHPMAILER PHP 3
L Problema phpmailer,jquery e smtp PHP 1
P Problemi visualizzazione html con phpmailer PHP 6
P phpmailer e file_get_contents PHP 1
P Phpmailer ed wind-infostrada PHP 20
felino PHPMailer: Indirizzo IP e Immagine PHP 6
lsnight Phpmailer per principianti PHP 7
K form con phpmailer PHP 18
P Invio multiplo mail con phpmailer PHP 5
L problema classe phpmailer con la mia classe clsMail PHP 2
G problema con phpmailer 5.2.1 PHP 1
minatore Phpmailer PHP 6
M phpmailer multiplo in più pagine di un sito PHP 5
N PhpMailer SELECT e OPTION PHP 190
N PhpMailer e salvataggio allegato sul server PHP 11
R Phpmailer SMTP PHP 23
A problema con phpmailer PHP 10
piccino PHPMailer: inserire allegato PHP 5
E Invio email (era: phpmailer) PHP 52
F Phpmailer e l'indirizzo del mittente PHP 3
F PhpMailer PHP 5
borgo italia phpmailer?? PHP 7
C phpmailer PHP 7
emanuelevt phpmailer e altervista PHP 3
catellostefano Problema con la classe class.phpmailer.php PHP 5
SolidSnake4 PHPmailer errore PHP 4
A classe PHPMailer e mail di Libero PHP 1
S php mail vs phpmailer PHP 0
T Problemi phpmailer x invio ad indirizzi di libero. Aiutatemi! PHP 14

Discussioni simili