fix
This commit is contained in:
@@ -76,10 +76,10 @@ define('USE_SMTP', true); // Imposta false per usare mail() PHP di base
|
|||||||
// Impostazioni SMTP - Gmail
|
// Impostazioni SMTP - Gmail
|
||||||
// Per Gmail: usa password applicazione da https://myaccount.google.com/apppasswords
|
// Per Gmail: usa password applicazione da https://myaccount.google.com/apppasswords
|
||||||
define('SMTP_HOST', 'smtp.gmail.com');
|
define('SMTP_HOST', 'smtp.gmail.com');
|
||||||
define('SMTP_PORT', 465);
|
define('SMTP_PORT', 587);
|
||||||
define('SMTP_USERNAME', 'pyco.networking@gmail.com'); // Inserisci la tua email Gmail
|
define('SMTP_USERNAME', 'pyco.networking@gmail.com'); // Inserisci la tua email Gmail
|
||||||
define('SMTP_PASSWORD', 'iaxuxsvggkfmbzpa'); // Password applicazione (16 caratteri)
|
define('SMTP_PASSWORD', 'iaxuxsvggkfmbzpa'); // Password applicazione (16 caratteri)
|
||||||
define('SMTP_ENCRYPTION', 'ssl'); // tls o ssl
|
define('SMTP_ENCRYPTION', 'tls'); // tls (porta 587) o ssl (porta 465)
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// CONFIGURAZIONE UPLOAD FILE
|
// CONFIGURAZIONE UPLOAD FILE
|
||||||
|
|||||||
@@ -442,11 +442,28 @@ function send_email($to, $subject, $message) {
|
|||||||
*/
|
*/
|
||||||
function send_smtp_email($to, $subject, $message) {
|
function send_smtp_email($to, $subject, $message) {
|
||||||
try {
|
try {
|
||||||
// Connessione al server SMTP
|
// Connessione al server SMTP con supporto SSL/TLS
|
||||||
$smtp = fsockopen(SMTP_HOST, SMTP_PORT, $errno, $errstr, 30);
|
$context = stream_context_create([
|
||||||
|
'ssl' => [
|
||||||
|
'verify_peer' => false,
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
'allow_self_signed' => true
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Per SSL (porta 465) usa protocollo ssl://, per TLS (porta 587) connessione normale
|
||||||
|
$protocol = (SMTP_ENCRYPTION === 'ssl') ? 'ssl://' : '';
|
||||||
|
$smtp = stream_socket_client(
|
||||||
|
$protocol . SMTP_HOST . ':' . SMTP_PORT,
|
||||||
|
$errno,
|
||||||
|
$errstr,
|
||||||
|
30,
|
||||||
|
STREAM_CLIENT_CONNECT,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
if (!$smtp) {
|
if (!$smtp) {
|
||||||
error_log("SMTP Error: Impossibile connettersi a " . SMTP_HOST . ":" . SMTP_PORT);
|
error_log("SMTP Error: Impossibile connettersi a " . SMTP_HOST . ":" . SMTP_PORT . " - $errstr ($errno)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user