phpmailler yandex hostinge çalışmıyor.
localhostta sorunsuz olarak çalışan sistem hostingte çalışmıyor.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
header('Content-Type: text/html; charset=utf-8');
$kim = @$_POST["email"];
$konu = @$_POST["subject"];
$mesaj = @$_POST["message"];
$adsoyad = @$_POST["name"];
$guvenlik = @$_POST["guvenlik"];//gelen
$guvenlikdogrula = @$_POST["guvenlikdogrula"]; //otomatik üretilen
if($guvenlik == $guvenlikdogrula)
{
require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';
$mail = new PHPMailer(true);
try
{
//Server settings
$mail->SMTPDebug = 0; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.yandex.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '[email protected]'; //SMTP username
$mail->Password = 'blablalba'; //SMTP password
$mail->SMTPSecure = 'ssl'; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
$mail->CharSet = 'UTF-8';
//Recipients
$mail->setFrom('[email protected]', 'Sistem Mesajı');
$mail->addAddress('[email protected]', 'Hasan ERYILMAZ'); //aynı mesaj banada gelsin
$mail->addAddress($kim,$adsoyad); //mesaj yollayanada gitsin
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
$mail->setLanguage('tr', 'phpmailer.lang-tr.php');
//Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
//Content
$mail->isHTML(true);
//Set email format to HTML
$mail->Subject = $konu;
$mail->Body = $mesaj;
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
?>
<script>
alert("Mesajınız Başarıyla Gönderildi.");
history.go(-1);
</script>
<?php
}
catch (Exception $e)
{
?>
<script>
alert("Mesajınız Gönderilirken bir hata oluştu. \n <?php echo $mail->ErrorInfo;?>");
history.go(-1);
</script>
<?php
}
}else
{
?>
<script>
alert("Güvenlik Kodunu yanlış Girdiniz..");
history.go(-1);
</script>
<?php
}
?>
olur da lazım olur html kodları
<form class="contact-form mt-6" method="post" action="maildosyasiyolu">
<div class="messages"></div>
<div class="row">
<div class="column col-md-6">
<div class="form-group">
<input type="text" class="form-control" name="name" id="name" placeholder="Ad Soyad" required="required" data-error="Ad soyad gerekli.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="column col-md-6">
<div class="form-group">
<input type="email" class="form-control" id="email" name="email" placeholder="E-Posta Adresi" required="required" data-error="E-Posta adresi gerekli.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="column col-md-12">
<div class="form-group">
<input type="text" class="form-control" id="subject" name="subject" placeholder="Konu" required="required" data-error="Konu gerekli.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="column col-md-12">
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="5" placeholder="Mesajınız" required="required" data-error="Mesaj Gerekli"></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="column col-md-12">
<div class="form-group">
<div style="padding-left:30px;">
Güvenlik Kodu: <b>291913</b>
</div>
<input type="number" class="form-control" name="guvenlik" placeholder="Güvenlik Kodunu Giriniz." required="required" data-error="Güvenlik Kodu gerekli.">
<input type="hidden" name="guvenlikdogrula" value="291913">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<button type="submit" name="submit" id="submit" value="Gönder" class="btn btn-default">Mesajı Gönder</button>
</form>
2021-09-08 16:38:22 SERVER -> CLIENT: 220-linux7.webarisi.com ESMTP Exim 4.91 #1 Wed, 08 Sep 2021 19:38:22 +0300 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2021-09-08 16:38:22 CLIENT -> SERVER: EHLO hasaneryilmaz.net
2021-09-08 16:38:22 SERVER -> CLIENT: 250-linux7.webarisi.com Hello hasaneryilmaz.net [91.227.6.17]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
2021-09-08 16:38:22 CLIENT -> SERVER: STARTTLS
2021-09-08 16:38:22 SERVER -> CLIENT: 220 TLS go ahead
SMTP Error: Could not connect to SMTP host.
2021-09-08 16:38:23 CLIENT -> SERVER: QUIT
2021-09-08 16:38:23
2021-09-08 16:38:23
SMTP Error: Could not connect to SMTP host.
başarısız SMTP Error: Could not connect to SMTP host.