PHP表单通过电子邮件标题发送到电子邮件表单数据

时间:2013-06-23 15:12:26

标签: php forms email

我这里有一个表单,提交后会将其发送到我的电子邮箱。有没有一种方法,当它发送时,它可以是FROM其中一个字段中的特定值(它将是一个要求其电子邮件地址的字段)。这样就可以更轻松地回复他们的消息。现在它发送到我的电子邮件地址作为我的$ 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");

?>

2 个答案:

答案 0 :(得分:0)

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

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

,可以根据您的需要采用。

答案 1 :(得分:-1)

是的,只需用与其他值相同的值替换您的电子邮件。

 $email = $_POST['email'];

 mail($email, $subject, $message, $headers);