将发件人电子邮件地址以php形式更改为收件人 [英] change sender email address in php form to recipient

查看:150
本文介绍了将发件人电子邮件地址以php形式更改为收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的php电子邮件表单,将提交的内容发送到指定的地址,但是我要修复的问题是电子邮件地址发送 - 目前,它是从myusername @ myhostingservice.com,但我希望能够将其改成一个简单的no-reply@mydomain.com或其他的东西。

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 

$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");

?>


推荐答案

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

You can use the 5th parameter of the mail function:

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

手册


additional_parameters参数可用于传递额外的
标志作为命令行选项,配置为在发送邮件时使用
,由sendmail_path配置
设置定义。例如,当使用-f sendmail选项的sendmail时,这可以用于设置信封发件人
地址。

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. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

这篇关于将发件人电子邮件地址以php形式更改为收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆