This commit is contained in:
Francesco Picone
2025-12-09 17:27:26 +01:00
parent b612146dfe
commit b79b31df69
2 changed files with 22 additions and 5 deletions

View File

@@ -76,10 +76,10 @@ define('USE_SMTP', true); // Imposta false per usare mail() PHP di base
// Impostazioni SMTP - Gmail
// Per Gmail: usa password applicazione da https://myaccount.google.com/apppasswords
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_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

View File

@@ -442,11 +442,28 @@ function send_email($to, $subject, $message) {
*/
function send_smtp_email($to, $subject, $message) {
try {
// Connessione al server SMTP
$smtp = fsockopen(SMTP_HOST, SMTP_PORT, $errno, $errstr, 30);
// Connessione al server SMTP con supporto SSL/TLS
$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) {
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;
}