【问题标题】:Contact form doesn't work 2 errors [closed]联系表格不起作用2个错误[关闭]
【发布时间】:2014-08-31 08:12:48
【问题描述】:

我的联系表格有问题,请不要发送。不幸的是,我对服务器提供商的 PHP Bellow 回答不友好。

“感谢您与我们联系。我想通知您,联系表格显示发件人的电子邮件地址(应该显示在服务器 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]混乱:e72823aae943c292 1108 从:[magda.serwer111111] 到:[magda.serwer111111] 状态:本地错误 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]混乱:bf5e99f8a1316c4b 703 从:[serwer111111] 到:[] 状态:REMOTE OK [0830124926_FE40E30F]

这是我的联系方式:

<?php

$receiving_email_address = "zydol@xxxx.com"; // 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;
}

} ?>

有人可以帮助我吗? 先感谢您 齐多尔

【问题讨论】:

    标签: php html forms email post


    【解决方案1】:

    第一条消息是因为你曾经设置过$email

    添加行

    $email = $_POST['email'];
    

    【讨论】:

    • 你能告诉我把线放在哪里吗?
    • @Zydol 在require("phpmailer.php");之前
    • 不,我有,一些代码:$to = $receiving_email_address;$email = $_POST['email'];$fromaddress = $_POST['email'];$fromname = $_POST['name'];
    • @zydol 但是被注释掉了!
    • 好的,对不起我的错误,我只是错误地复制代码来发布,现在可以了。它没有评论。问题依然存在
    猜你喜欢
    • 2015-04-13
    • 1970-01-01
    • 1970-01-01
    • 2014-03-31
    • 2016-10-28
    • 2014-10-04
    • 2014-05-25
    相关资源
    最近更新 更多