Merhaba Arkadaşlar phpmailler clasında sorun yaşıyorum site email göndermiyor posta iletildi yazısı alıyorum ama gelen giden email yok
$mail->SMTPDebug = 2; yapıp hata yazdırmasını istediğim zaman çıkan hata
2023-02-27 19:37:45
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
phpmailler kodlaırm
function email_gonder($email,$icerik,$konu){
global $db;
global $dil;
global $site;
global $dil;
$ayar = $db->query("SELECT * FROM ayar WHERE dil = '{$dil}' LIMIT 1")->fetch(PDO::FETCH_ASSOC);
$mailbody = '<!DOCTYPE html>
<html>
<head>
<title>'.$ayar['title'].'</title>
<meta charset="utf-8">
</head>
<body style="padding: 30px">
<div style="width: 98%;margin:0 auto;background: #02add9;padding: 1%;display: inline-block;border-radius: 10px">
<div style="width: 90%;float: left;background: #fff;padding: 10px 5% 20px 5%;">
<center><img src="'.$site.'upload/'.$ayar['logo'].'" style="max-width: 200px"></center>
'.$icerik.'
</div>
</div>
<style type="text/css">
body{font-family:arial}table{width:100%;border:1px solid #ddd}table tr{padding:0;margin:0}table tr th{border:1px solid #ddd;padding:0;margin:0;background:#02add9;color:#fff;padding:10px}table tr td{border:1px solid #ddd;padding:0;text-align:center;margin:0;border-spacing:0}
</style>
</body>
</html>';
$smtp = $db->query("SELECT * FROM smtp WHERE dil = '{$dil}' LIMIT 1")->fetch(PDO::FETCH_ASSOC);
if(!empty($smtp['host']) AND !empty($smtp['email']) AND !empty($smtp['sifre'])){
if(is_file('vendor/autoload.php')){
require 'vendor/autoload.php';
}else{
require '../vendor/autoload.php';
}
try {
$mail = new PHPMailer(true);
//$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = $smtp['host'];
$mail->SMTPAuth = true;
$mail->Username = $smtp['email'];
$mail->Password = $smtp['sifre'];
if($smtp['port'] == 0){
$mail->SMTPSecure = $smtp['_ssl'];
$mail->Port = $smtp['port'];
}else{
$mail->SMTPSecure = 'tls';
$mail->Port = 25;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
}
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = 0;
$mail->setFrom($smtp['email']);
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = $konu;
$mail->Body = $mailbody;
$mail->AltBody = '';
$mail->send();
} catch (Exception $e) {
}
}