2014-08-31 57 views
0

我有聯繫表格的問題,不要發送它。不幸的是,我不喜歡我的服務器提供商提供的PHP Bellow答案。 「聯繫表格不起作用2個錯誤

」謝謝你與我們聯繫。我想告訴你,聯繫表顯示發件人的電子郵件地址(應顯示在服務器home.pl內創建的電子郵件地址): 30.08.2014 12:49:26 [/ usr/run/smtp] socket/plain(php5:xxxx.com/form/contact.php [1 work] DOCUMENT_ROOT =/SCRIPT_FILENAME =/form/contact.php)[serwer111111] mess:e72823aae943c292 1108 from:[magda.serwer111111] to:[magda。 serwer111111] status:LOCAL ERROR 554 5.7.1僞造的發件人地址:

此外,默認電子郵件地址字段THIS的管理由一個無效值(變量不替代正確值)補充: 30.08。 2014 12:49:26 [/ usr/run/smtp] socket/plain(php5:xxxx.com/form/contact.php [1 work] DOCUMENT_ROOT =/SCRIPT_FILENAME =/form/contact.php)[serwer111111] mess: bf5e99f8a1316c4b 703從:[serwer111111]到:[]狀態:遠程OK [0830124926_FE40E30F]

這是我的聯繫方式:

<?php 

$receiving_email_address = "[email protected]"; // Set your email address here which you want to receive emails to 

$receiving_email_address_name = "Zydol"; // Add name that is associated with your email address above. 

$custom_subject = "email from xxxx.com"; // Change the subject line of email as per your choice. 

// ============================= DO NOT EDIT BELOW THIS LINE ====================================== 

if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) { $name = stripslashes(strip_tags($_POST['name'])); } else {$name = 'No name entered';} 

if ((isset($_POST['phone'])) && (strlen(trim($_POST['phone'])) > 0)) { $phone = stripslashes(strip_tags($_POST['phone'])); } else {$phone = 'No phone entered';} 

if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) { $email = stripslashes(strip_tags($_POST['email'])); } else {$email = 'No email entered';} 

if ((isset($_POST['datetimepicker'])) && (strlen(trim($_POST['datetimepicker'])) > 0)) { $datetimepicker = stripslashes(strip_tags($_POST['datetimepicker'])); } else {$datetimepicker = 'No email entered';} 

if ((isset($_POST['comment'])) && (strlen(trim($_POST['comment'])) > 0)) { $comment = stripslashes(strip_tags($_POST['comment'])); } else {$phone = 'No comment entered';} ob_start(); 

// Email Building 
$to = $receiving_email_address; 
$email = $_POST['email']; 
$fromaddress = $_POST['email']; 
$fromname = $_POST['name']; 
$body = "Below are the details submitted by the user on your website. 

Name: ".$_POST['name']." 

Email: ".$_POST['email']." 

Phone: ".$_POST['phone']." 

Date & Time: ".$_POST['datetimepicker']." 

Comment: ".$_POST['comment'].""; 

// Check if the security is filled 

if ($_POST['security'] == '') { 

    require("phpmailer.php"); 
    $mail = new PHPMailer(); 

    $mail->From      = "$email"; 
    $mail->FromName   = "$fromname"; 
    $mail->AddAddress("$receiving_email_address","$receiving_email_address_name"); 

    $mail->IsHTML(true); 

    $mail->Subject     = "$custom_subject"; 
    $mail->Body      = $body; 
    $mail->AltBody      = "This is the text-only body"; 

    if(!$mail->Send()) { 
     $recipient      = '$receiving_email_address'; 
     $subject      = 'Contact form failed'; 
     $content      = $body; 



    // Send Mail 


mail($recipient, $subject, $content, "From: $receiving_email_address\r\nReply-To: $email\r\nX-Mailer: DT_formmail"); 
    exit; 
} 

} ?> 

有人可以幫助我嗎? 預先感謝您 Zydol

回答

1

第一條消息是因爲你曾經設置$email

添加一行

$email = $_POST['email']; 
+0

你能告訴我,我必須把線? – Zydol 2014-08-31 08:41:46

+0

@Zydol之前'要求( 「phpmailer.php」);' – Jens 2014-08-31 10:50:12

+0

無我有,一些代碼:'$至\t \t = $ receiving_email_address;'' $電子郵件\t \t = $ _ POST [ '電子郵件']; ' '$ fromaddress \t = $ _POST ['email'];' '$ fromname \t \t = $ _POST ['name'];' – Zydol 2014-08-31 11:19:51