PHPMailer non funziona

  • Creatore Discussione Creatore Discussione iTonto
  • Data di inizio Data di inizio

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 = 'demo@domain.com';
$fromName = 'Demo contact form';

$sendToEmail = 'miaemail@tiscali.it';
$sendToName = 'Demo contact form';

$subject = 'Nuovo messaggio';

$smtpHost = 'smtp.tiscali.it';
$smtpUsername = 'miaemail@tiscali.it';
$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
 
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
 
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 :)
 
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 = "CAMBIAMI@libero.it";
            $eM_Password = "CAMBIAMI";
inserisci questi parametri nel tuo script
 
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 = "CAMBIAMI@libero.it";
            $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

:(
 
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
    )
);
 
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 = 'miamail@tiscali.it';
$sendToName = 'Davide';

$subject = 'Nuovo messaggio';

$smtpHost = 'smtp.tiscali.it';
$smtpUsername = 'miamail@tiscali.it';
$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 = 'miamail@tiscali.it';
 
    $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:<j.shot@mail.com>
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 <j.shot@mail.com> 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 <j.shot@mail.com> 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 <j.shot@mail.com> 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: j.shot@mail.com : MAIL FROM command failed,<j.shot@mail.com> 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: <j.shot@mail.com> 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

"j.shot@mail.com" è il finto indirizzo email che ho inserito nel campo Email del form.
 
Ultima modifica:
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
 
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: emailprova@libero.it : 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 = 'miaemail@mail.com';
    $mail->Password = '12345';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
   
    $mail->setFrom($_POST['email'], $_POST['name']);
    $mail->addAddress('miaemail@mail.com', '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!
 
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"
 
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...
 
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 …..
 
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