سلام دوستان در فرم تماس با ما php مشکلی هست که من فکر می کردم از طرفه سرور هست که ایمیل زدم آنها گفتند از سورس پی اچ پی هست من متاسفانه زیاد با پی اچ پی کار نکردم.
این خطای وب سایت هست:
Warning: mail() [function.mail]: SMTP server response: 503 This mail server requires authentication when attempting to
send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the
domain or address is defined for this server. in C:\Inetpub\vhosts\MyHost.ir\httpdocs\mail\fns.php on line 184
ایمیل شما ارسال نشد.ممکن است مشکلی در سایت ایجاد شده باشد.لطفا بعدا دوباره سعی کنید
و این هم سورس مربوط به فرم پی اچ پی:
لطفا اگه کسی آشنایی داره راهنمایی کنه????
این خطای وب سایت هست:
Warning: mail() [function.mail]: SMTP server response: 503 This mail server requires authentication when attempting to
send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the
domain or address is defined for this server. in C:\Inetpub\vhosts\MyHost.ir\httpdocs\mail\fns.php on line 184
ایمیل شما ارسال نشد.ممکن است مشکلی در سایت ایجاد شده باشد.لطفا بعدا دوباره سعی کنید
و این هم سورس مربوط به فرم پی اچ پی:
<?php
//start session
session_start();
/**
* Design By M.Majidi
*
*/
//start session
session_start();
/**
* Design By M.Majidi
*
*/
// prints form
function print_form(){
?>
<p><span class="required">*</span> فیلدهای مهم</p>
<form method="post" action="<?php echo $_SERVER[’PHP_SELF’];?>" id="uploadform" enctype="multipart/form-data">
<p><label for="namefrom">نام <span class="required">*</span></label>
<input name="namefrom" id="namefrom" type="text" class="field" value="<?= $_SESSION['myForm']['namefrom']; ?>" tabindex="1"/></p>
function print_form(){
?>
<p><span class="required">*</span> فیلدهای مهم</p>
<form method="post" action="<?php echo $_SERVER[’PHP_SELF’];?>" id="uploadform" enctype="multipart/form-data">
<p><label for="namefrom">نام <span class="required">*</span></label>
<input name="namefrom" id="namefrom" type="text" class="field" value="<?= $_SESSION['myForm']['namefrom']; ?>" tabindex="1"/></p>
<p><label for="company">شرکت</label>
<input name="company" id="company" type="text" class="field" value="<?= $_SESSION['myForm']['company']; ?>" tabindex="2"/></p>
<input name="company" id="company" type="text" class="field" value="<?= $_SESSION['myForm']['company']; ?>" tabindex="2"/></p>
<p><label for="emailfrom">ایمیل <span class="required">*</span></label>
<input name="emailfrom" id="emailfrom" type="text" class="field" value="<?= $_SESSION['myForm']['emailfrom']; ?>" tabindex="3"/></p>
<input name="emailfrom" id="emailfrom" type="text" class="field" value="<?= $_SESSION['myForm']['emailfrom']; ?>" tabindex="3"/></p>
<p><label for="phone">تلفن تماس</label>
<input name="phone" id="phone" type="text" class="field" value="<?= $_SESSION['myForm']['phone']; ?>" tabindex="4"/></p>
<input name="phone" id="phone" type="text" class="field" value="<?= $_SESSION['myForm']['phone']; ?>" tabindex="4"/></p>
<p><label for="subject">موضوع <span class="required">*</span></label>
<input name="subject" id="subject" type="text" class="field" value="<?= $_SESSION['myForm']['subject']; ?>" tabindex="5"/></p>
<input name="subject" id="subject" type="text" class="field" value="<?= $_SESSION['myForm']['subject']; ?>" tabindex="5"/></p>
<p><label for="comments">پیام <span class="required">*</span></label>
<textarea name="comments" id="comments" rows="7" cols="10" class="field" tabindex="6"><?= $_SESSION['myForm']['comments']; ?></textarea></p>
<textarea name="comments" id="comments" rows="7" cols="10" class="field" tabindex="6"><?= $_SESSION['myForm']['comments']; ?></textarea></p>
<p><label for="attachment">ارسال فایل<br /></label>
<input name="attachment" id="attachment" type="file" tabindex="7"><br />
(حداکثر حجم مجاز 5 مگابایت می باشد.فایل های مجاز rar, zip, pdf, doc, jpg, bmp)
<input name="attachment" id="attachment" type="file" tabindex="7"><br />
(حداکثر حجم مجاز 5 مگابایت می باشد.فایل های مجاز rar, zip, pdf, doc, jpg, bmp)
<p><input type="submit" name="submit" id="submit" value="ارسال پیام" tabindex="8"/></p>
<p><input type="hidden" name="submitted" value="true" /></p>
</form>
<?php
}
// enquiry form validation
function process_form() {
// Read POST request params into global vars
// FILL IN YOUR EMAIL
$to = "[email protected]";
$subject = trim($_POST['subject']);
$namefrom = trim($_POST['namefrom']);
$company = trim($_POST['company']);
$phone = trim($_POST['phone']);
$emailfrom = trim($_POST['emailfrom']);
$comments = trim($_POST['comments']);
<p><input type="hidden" name="submitted" value="true" /></p>
</form>
<?php
}
// enquiry form validation
function process_form() {
// Read POST request params into global vars
// FILL IN YOUR EMAIL
$to = "[email protected]";
$subject = trim($_POST['subject']);
$namefrom = trim($_POST['namefrom']);
$company = trim($_POST['company']);
$phone = trim($_POST['phone']);
$emailfrom = trim($_POST['emailfrom']);
$comments = trim($_POST['comments']);
// Allowed file types. add file extensions WITHOUT the dot.
$allowtypes=array("zip", "rar", "doc", "jpg", "gif", "bmp", "pdf");
$allowtypes=array("zip", "rar", "doc", "jpg", "gif", "bmp", "pdf");
// Require a file to be attached: false = Do not allow attachments true = allow only 1 file to be attached
$requirefile="false";
$requirefile="false";
// Maximum file size for attachments in KB NOT Bytes for simplicity. MAKE SURE your php.ini can handel it,
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
$max_file_size="5120";
// post_max_size, upload_max_filesize, file_uploads, max_execution_time!
// 2048kb = 2MB, 1024kb = 1MB, 512kb = 1/2MB etc..
$max_file_size="5120";
// Thank you message
$thanksmessage="پیام شما با موفقیت ارسال شد.در صورت نیاز پاسخ شما را خواهیم داد.با تشکر";
$errors = array(); //Initialize error array
//checks for a name
if (empty($_POST['namefrom']) ) {
$errors[]='نام خود را وارد نکردید';
}
//checks for an email
if (empty($_POST['emailfrom']) ) {
$errors[]='ایمیل خود را وارد نکرده اید';
} else {
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['emailfrom'])))) {
$errors[]='آدرس ایمیل وارد شده اشتباه می باشد';
} // if eregi
} // if empty email
//checks for a subject
if (empty($_POST['subject']) ) {
$errors[]='موضوع پیام خود را وارد نکرده اید';
}
//checks for a message
if (empty($_POST['comments']) ) {
$errors[]='پیام خود را وارد نکرده اید';
}
$thanksmessage="پیام شما با موفقیت ارسال شد.در صورت نیاز پاسخ شما را خواهیم داد.با تشکر";
$errors = array(); //Initialize error array
//checks for a name
if (empty($_POST['namefrom']) ) {
$errors[]='نام خود را وارد نکردید';
}
//checks for an email
if (empty($_POST['emailfrom']) ) {
$errors[]='ایمیل خود را وارد نکرده اید';
} else {
if (!eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['emailfrom'])))) {
$errors[]='آدرس ایمیل وارد شده اشتباه می باشد';
} // if eregi
} // if empty email
//checks for a subject
if (empty($_POST['subject']) ) {
$errors[]='موضوع پیام خود را وارد نکرده اید';
}
//checks for a message
if (empty($_POST['comments']) ) {
$errors[]='پیام خود را وارد نکرده اید';
}
// checks for required file
// http://amiworks.co.in/talk/handling-file-uploads-in-php/
if($requirefile=="true") {
if($_FILES['attachment']['error']==4) {
$errors[]='You forgot to attach a file';
}
}
// http://amiworks.co.in/talk/handling-file-uploads-in-php/
if($requirefile=="true") {
if($_FILES['attachment']['error']==4) {
$errors[]='You forgot to attach a file';
}
}
//checks attachment file
// checks that we have a file
if((!empty($_FILES["attachment"])) && ($_FILES['attachment']['error'] == 0)) {
// basename -- Returns filename component of path
$filename = basename($_FILES['attachment']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$filesize=$_FILES['attachment']['size'];
$max_bytes=$max_file_size*1024;
// checks that we have a file
if((!empty($_FILES["attachment"])) && ($_FILES['attachment']['error'] == 0)) {
// basename -- Returns filename component of path
$filename = basename($_FILES['attachment']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$filesize=$_FILES['attachment']['size'];
$max_bytes=$max_file_size*1024;
//Check if the file type uploaded is a valid file type.
if (!in_array($ext, $allowtypes)) {
$errors[]="Invalid extension for your file: <strong>".$filename."</strong>";
if (!in_array($ext, $allowtypes)) {
$errors[]="Invalid extension for your file: <strong>".$filename."</strong>";
// check the size of each file
} elseif($filesize > $max_bytes) {
$errors[]= "Your file: <strong>".$filename."</strong> is to big. Max file size is ".$max_file_size."kb.";
}
} elseif($filesize > $max_bytes) {
$errors[]= "Your file: <strong>".$filename."</strong> is to big. Max file size is ".$max_file_size."kb.";
}
} // if !empty FILES
if (empty($errors)) { //If everything is OK
if (empty($errors)) { //If everything is OK
// send an email
// Obtain file upload vars
$fileatt = $_FILES['attachment']['tmp_name'];
$fileatt_type = $_FILES['attachment']['type'];
$fileatt_name = $_FILES['attachment']['name'];
// Obtain file upload vars
$fileatt = $_FILES['attachment']['tmp_name'];
$fileatt_type = $_FILES['attachment']['type'];
$fileatt_name = $_FILES['attachment']['name'];
// Headers
$headers = "From: $emailfrom";
$headers = "From: $emailfrom";
// create a boundary string. It must be unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message ="This is a multi-part message in MIME format.\n\n";
$message.="--{$mime_boundary}\n";
$message.="Content-Type: text/plain; charset=\"UTF-8\"\n";
$message.="Content-Transfer-Encoding: 7bit\n\n";
$message.="از طرف: ".$namefrom."\n";
$message.="شرکت: ".$company."\n";
$message.="تلفن: ".$phone."\n";
$message.="پیام: ".$comments."\n\n";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message ="This is a multi-part message in MIME format.\n\n";
$message.="--{$mime_boundary}\n";
$message.="Content-Type: text/plain; charset=\"UTF-8\"\n";
$message.="Content-Transfer-Encoding: 7bit\n\n";
$message.="از طرف: ".$namefrom."\n";
$message.="شرکت: ".$company."\n";
$message.="تلفن: ".$phone."\n";
$message.="پیام: ".$comments."\n\n";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Send the completed message
$envs = array("HTTP_USER_AGENT", "REMOTE_ADDR", "REMOTE_HOST");
foreach ($envs as $env)
$message .= "$env: $_SERVER[$env]\n";
foreach ($envs as $env)
$message .= "$env: $_SERVER[$env]\n";
if(!mail($to,$subject,$message,$headers)) {
exit("ایمیل شما ارسال نشد.ممکن است مشکلی در سایت ایجاد شده باشد.لطفا بعدا دوباره سعی کنید\n");
} else {
echo '<div id="formfeedback"><h3>با تشکر</h3><p>'. $thanksmessage .'</p></div>';
unset($_SESSION['myForm']);
print_form();
exit("ایمیل شما ارسال نشد.ممکن است مشکلی در سایت ایجاد شده باشد.لطفا بعدا دوباره سعی کنید\n");
} else {
echo '<div id="formfeedback"><h3>با تشکر</h3><p>'. $thanksmessage .'</p></div>';
unset($_SESSION['myForm']);
print_form();
} // end of if !mail
} else { //report the errors
echo '<div id="formfeedback"><h3>Error!</h3><p>The following error(s) has occurred:<br />';
foreach ($errors as $msg) { //prints each error
echo " - $msg<br />\n";
} // end of foreach
echo '</p><p>دوباره سعی کنید</p></div>';
print_form();
} //end of if(empty($errors))
} // end of process_form()
?>
echo '<div id="formfeedback"><h3>Error!</h3><p>The following error(s) has occurred:<br />';
foreach ($errors as $msg) { //prints each error
echo " - $msg<br />\n";
} // end of foreach
echo '</p><p>دوباره سعی کنید</p></div>';
print_form();
} //end of if(empty($errors))
} // end of process_form()
?>
در خط 51 گفته باید ایمیل که می خواهم این محتویات ارسال شود را بنویسم : $to = "[email protected]";
لطفا اگه کسی آشنایی داره راهنمایی کنه????