简体   繁体   English

将php形式的发件人电子邮件地址更改为收件人

[英]change sender email address in php form to recipient

I'm trying to create a simple php email form that sends the submitted contents to a specified address, but the problem I'm trying to fix is the address the email is being sent from — currently, it sends from myusername@myhostingservice.com, but I want to be able to change that to a simple no-reply@mydomain.com or something else. 我正在尝试创建一个简单的php电子邮件表单,该表单将提交的内容发送到指定的地址,但是我要解决的问题是电子邮件发送的地址-当前,它是从myusername@myhostingservice.com发送的,但我希望能够将其更改为简单的no-reply@mydomain.com或其他名称。

<?php 

$message = $_POST['message'];

$formcontent="$message";

$recipient = "reciever@example.com";

$subject = "question";

mail($recipient, $subject, $formcontent, $header, '-fno-reply@mydomain.com') or die("Error!");

header("Location: webpage_user_is_redirected_to.html");

?>

You can use the 5th parameter of the mail function: 您可以使用mail函数的第5个参数:

mail($recipient, $subject, $formcontent, $header, '-fno-replay@mydomain.com');

From the manual : 手册

The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail, as defined by the sendmail_path configuration setting. 根据sendmail_path配置设置的定义,additional_parameters参数可用于将其他标志作为命令行选项传递给配置为在发送邮件时使用的程序。 For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option. 例如,当将sendmail与-f sendmail选项一起使用时,可用于设置信封发件人地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM