【问题标题】:PHP Form sends to email form data in email header [closed]PHP表单在电子邮件标题中发送到电子邮件表单数据[关闭]
【发布时间】:2013-06-23 15:12:26
【问题描述】:

我在这里有一个表单,提交后会发送到我的电子邮件。有没有一种方法可以在发送时来自某个字段中的特定值(它将是一个询问其电子邮件地址的字段)。这只是为了更容易回复他们的消息。现在它作为我的 $where_form_is 发送到我的电子邮件地址。

<?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

$from = $_REQUEST['field_1'];

mail("email@gmail.com"," Application ","Application Data:

Email (so we can reply):
" . $_POST['field_1'] . " 

In Game Name:
" . $_POST['field_2'] . " 

Please name ALL characters that you still actively play:
" . $_POST['field_3'] . " 

Name/Nickname you prefer to be called:
" . $_POST['field_4'] . " 

Age:
" . $_POST['field_5'] . " 

Country/Time zone:
" . $_POST['field_6'] . " 

How often do you play?:
" . $_POST['field_7'] . " 

Which Boss Runs are you familiar with?:
" . $_POST['field_8'] . "

Previous guilds and reason for leaving/kick:
" . $_POST['field_9'] . " 

Why do you want to join?:
" . $_POST['field_10'] . " 

How did you find out about us?:
" . $_POST['field_11'] . " 

Do you know anyone from here? If so, who?:
" . $_POST['field_12'] . " 

Referrals (2-3 Contact IGNs of Previous Guild Masters/Junior Masters):
" . $_POST['field_13'] . " 

Best way to contact you?:
" . $_POST['field_14'] . " 

Any additional comments?:
" . $_POST['field_15'] . " 

", "$from"
);

include("confirm.html");

?>

【问题讨论】:

    标签: php forms email


    【解决方案1】:

    mail 有第四个参数:header,这是一个例子:

    $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
    mail($recipient, $subject, $mail_body, $header); 
    

    来自here 以上,可根据您的需要采用。

    【讨论】:

    • 非常感谢,这正是我所需要的!
    【解决方案2】:

    是的,只需将您的电子邮件替换为该值,就像其他值一样。

     $email = $_POST['email'];
    
     mail($email, $subject, $message, $headers);
    

    【讨论】:

    • 这会将邮件发送回填写表格的人???不是 OP 想要的,他想从表单中接收带有发件人地址的邮件,以便更轻松地回复。
    • @AxelAmthor 她的写作方式听起来像是我的解决方案。我不应该对此持否定态度。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    • 2020-04-22
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多