2012-09-30 21 views
0

我试图创建一个简单的php电子邮件表单,将提交的内容发送到指定的地址,但是我试图解决的问题是电子邮件正在发送的地址从 - 目前,它从[email protected]发送,但我希望能够将其更改为简单的[email protected]或其他内容。以php的形式将发件人的电子邮件地址更改为收件人

<?php 

$message = $_POST['message']; 

$formcontent="$message"; 

$recipient = "[email protected]"; 

$subject = "question"; 

mail($recipient, $subject, $formcontent, $header, '[email protected]') or die("Error!"); 

header("Location: webpage_user_is_redirected_to.html"); 

?> 
+0

不使用邮件()使用第三方库[phpmailer](http://phpmailer.worxware.com/) – 2012-09-30 20:47:15

回答

0

您可以使用邮件功能的第五个参数:

mail($recipient, $subject, $formcontent, $header, '[email protected]'); 

manual

的additional_parameters参数可用于传递附加 标志作为命令行选项到发送邮件时配置为使用 的程序,如sendmail_path配置 设置所定义。例如,当使用带有-f sendmail选项的sendmail时,可以使用它来设置信封发件人 地址。

+0

我更新了代码,但现在它不工作。 – Ryan

+0

我看不到你的'$ header'?如果你没有任何其他的头文件信息,请使用null'mail($ recipient,$ subject,$ formcontent,null,'-fno-repl[email protected]');' – JvdBerg

+0

并且不需要传递'$ _POST ['消息'];'超过3层变量:'邮件($收件人,$主题,$ _POST ['消息'],null,'[email protected]');' – JvdBerg

相关问题