Selamun Aleyküm,
cdo.message ve normal php ile dns ayarları yandex e yönlendirilmiş mail adresine mail gönderemiyorum. belki binden fazla deneme yaptım bir türlü başarılı olamadım.
daha önceden konuyla alakalı elinde çalışan kod olan var mı
örnek olarak gönderiyorum asp
<%
If Request.Form("submit") <> "" Then
Set myMail=CreateObject("CDO.Message")
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.yandex.com.tr"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ismail@website.com.tr"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "zE*****7"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")= "True"
myMail.Configuration.Fields.Update
myMail.Subject= "website.com.tr iletişim formu" 'This is the subject of the e-mail
myMail.To="ismail@website.com.tr" 'This is the e-mail address the e-mail will be delivered to
myMail.From=Request.Form("email")
myMail.TextBody="İsim Soyisim: " & Request.Form("ad") & vbnewline & "E-Mail Address: " & Request.Form("email") & vbnewline & "Telefon: " & Request.Form("tel") & vbnewline & "Mesaj: " & Request.Form("mesaj")
myMail.Send
set myMail=nothing
Response.Write "<script language='JavaScript'>alert('Mesajınız İletilmiştir..Teşekkür Ederiz.');</script>"
End If
%>
php kodu
<?php
$owner_email='ismail@websitesi.com';
//SMTP server settings
$subject='Yeni Bir mesaj aldınız ';
$user_email='';
$message_body='';
$message_type='html';
$max_file_size=50;//MB
$file_types='/(doc|docx|txt|pdf|zip|rar)$/';
$error_text='something goes wrong';
$error_text_filesize='File size must be less than';
$error_text_filetype='Failed to upload file. This file type is not allowed. Accepted files types: doc, docx, txt, pdf, zip, rar.';
$private_recaptcha_key='6LeZwukSAAAAACmqrbLmdpvdhC68NLB1c9EA5vzU'; //localhost
$use_recaptcha=isset( $_POST["recaptcha_challenge_field"]) and isset($_POST["recaptcha_response_field"]);
$use_smtp=($host=='' or $username=='' or $password=='');
$max_file_size*=1048576;
if($owner_email=='' || $owner_email=='#'){
die('Attention, recipient e-mail is not set! Please define "owner_email" variable in the MailHanlder.php file.');
}
if(preg_match('/^(127\.|192\.168\.)/',$_SERVER['REMOTE_ADDR'])){
die('Attention, contact form will not work locally! Please upload your template to a live hosting server.');
}
if($use_recaptcha){
require_once('recaptchalib.php');
$resp = recaptcha_check_answer ($private_recaptcha_key,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
if (!$resp->is_valid){
die ('wrong captcha');
}
}
if(isset($_POST['name']) and $_POST['name'] != ''){$message_body .= '<p>Visitor: ' . $_POST['name'] . '</p>' . "\n" . '<br>' . "\n"; $subject.=$_POST['name'];}
if(isset($_POST['email']) and $_POST['email'] != ''){$message_body .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n" . '<br>' . "\n"; $user_email=$_POST['email'];}
if(isset($_POST['state']) and $_POST['state'] != ''){$message_body .= '<p>State: ' . $_POST['state'] . '</p>' . "\n" . '<br>' . "\n";}
if(isset($_POST['phone']) and $_POST['phone'] != ''){$message_body .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n" . '<br>' . "\n";}
if(isset($_POST['fax']) and $_POST['fax'] != ''){$message_body .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n" . '<br>' . "\n";}
if(isset($_POST['message']) and $_POST['message'] != ''){$message_body .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";}
if(isset($_POST['stripHTML']) and $_POST['stripHTML']=='true'){$message_body = strip_tags($message_body);$message_type='text';}
try{
include "libmail.php";
$m= new Mail("utf-8");
$m->From($user_email);
$m->To($owner_email);
$m->Subject($subject);
$m->Body($message_body,$message_type);
//$m->log_on(true);
if(isset($_FILES['attachment'])){
if($_FILES['attachment']['size']>$max_file_size){
$error_text=$error_text_filesize . ' ' . $max_file_size . 'bytes';
die($error_text);
}else{
if(preg_match($file_types,$_FILES['attachment']['name'])){
$m->Attach($_FILES['attachment']['tmp_name'],$_FILES['attachment']['name'],'','attachment');
}else{
$error_text=$error_text_filetype;
die($error_text);
}
}
}
if(!$use_smtp){
$m->smtp_on( $host, $username, $password, $port);
}
if($m->Send()){
die('başarılı');
}
}catch(Exception $mail){
die($mail);
}
?>
şimdiden teşekkür ederim.
Toplam 3 cevap
Yandex üzerinden asp ile ya da farklı bir dil ile smtp üzerinden mail göndermeye çalışırken şunlara dikkat et:
ismailix 7 yıl önce
giriş yapıp istenilen bilgileri daha önceden girdim. 587 ssl li olarak da denedim ama malesef bir sonuç alamadım.
Yandex için phpmailer class dosyasını include ederek gönderim yapabilirsin.
<?php
include 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.yandex.com";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet ="utf-8";
$mail->Username = "isim@siteismi.com";
$mail->Password = "PASSWORD";
$mail->SetFrom("isim@siteismi.com", "Isim");
$mail->AddAddress("ahmetmakal@msn.com");
$mail->Subject = "Mesaj Basligi";
$mail->Body = "Mesaj icerigi";
if(!$mail->Send()){
echo "Mailer Error: ".$mail->ErrorInfo;
} else {
echo "Mesaj gonderildi";
}
?>