PDA

View Full Version : سوال: مشکل در ارسال ایمیل با دستور mail



smsoltani
پنج شنبه 05 آذر 1394, 14:12 عصر
با سلام خدمت همه کاربران و مدیران گرامی
کدی که در ذیل آوردم بدون اشکال کار میکرد اما اخیرا پیام error از طریق اجکس به صفحه جاوا اسکریپت برمیگرداند و ایمیل به کاربر ثبت نامی ارسال نمی شود.
آیا ایرادی در کدنویسی وجود دارد؟ یا تنظیماتی لازم است.





<?php
define( "EMAIL_SUBJECTB", "Newsletter request );
define( "EMAIL_MASSAGE", "Thank you for subscribing." );
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' ا-یa-zA-Z0-9]/u", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
if ( $senderName && $senderEmail && $message ) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
$headers .= "From: " . "myWebsite" . " <" . "mail@mymail.ir" . ">";
$success = mail($senderEmail, EMAIL_SUBJECTB, EMAIL_MASSAGE, $headers);
}
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks</title>
</head>
<body>
<?php if ( $success ) echo "<p style=\"direction: ltr;\">Thank you for subscribing our newsletter.</p>" ?>
<?php if ( !$error ) echo "<p style=\"direction: ltr;\">Sorry, There is a problem. Please try again!</p>" ?>
<p>Use BACK button on browser to return.</p>
</body>
</html>
<?php
}
?>






از راهنمایی شما تشکر می کنم.