Created
July 26, 2025 20:02
-
-
Save thinkphp/a83f434fc0f12188e0b9d61d65c9f007 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
require 'PHPMailer/src/Exception.php'; | |
require 'PHPMailer/src/PHPMailer.php'; | |
require 'PHPMailer/src/SMTP.php'; | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
$mail = new PHPMailer(true); | |
try { | |
// Configurare SMTP pentru Gmail | |
$mail->isSMTP(); | |
$mail->Host = 'smtp.gmail.com'; | |
$mail->SMTPAuth = true; | |
$mail->Username = '[email protected]'; | |
$mail->Password = ''; // vezi App Password mai sus | |
$mail->SMTPSecure = 'tls'; | |
$mail->Port = 587; | |
// Expeditor și destinatar | |
$mail->setFrom('[email protected]', 'Adrian'); | |
$mail->addAddress('[email protected]'); | |
// Conținut email | |
$mail->isHTML(true); | |
$mail->Subject = 'Test PHPMailer din localhost'; | |
$mail->Body = '<b>Salut!</b> Email trimis cu succes din localhost.'; | |
$mail->send(); | |
echo '✅ Email trimis cu succes!'; | |
} catch (Exception $e) { | |
echo "❌ Emailul nu s-a trimis. Eroare: {$mail->ErrorInfo}"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment