PHP邮件功能'来自'地址 [英] PHP mail function 'from' address

查看:147
本文介绍了PHP邮件功能'来自'地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我甚至不确定这是可能的,但是我想要做的是如下。我有一个HTML表单,使用 PHP 脚本生成并发送电子邮件。我想要的是从这个表单接收电子邮件到 abc@xyz.com ,然后我想从地址中的显示为表单中的一个字段。

I'm not even sure this is possible, however what I'm trying to do is as follows. I have an HTML form that generates and email using a PHP script. What I want is to recieve emails from this form to abc@xyz.com, then I want the from address to appear as one of the fields in the form.

我已经看了一下,发现了一些有用的信息,这个网站。我不知道在这种情况下是否可以使用 sendmail_from ,或者是否正在提出要求。

I have had a look around and found some useful information on this site. I'm not sure whether sendmail_from can be used in this situation, or if it does what I'm asking.

这是可能的,如果是这样吗?

Is this possible, if so how?

推荐答案

在同一个网站上看到这个页面(示例2): http://www.w3schools.com/php/func_mail_mail.asp

See this page on the same site (example 2): http://www.w3schools.com/php/func_mail_mail.asp

您将必须设置邮件的标题以包含发件人和其他内容,如CC或BCC:

You will have to set the headers of the message to include the From and other stuff like CC or BCC:

<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com\r\n";

mail($to,$subject,$txt,$headers);
?>

请注意,您必须使用换行符序列\ r \\\

Note that you have to separate the headers with a newline sequence "\r\n".

这篇关于PHP邮件功能'来自'地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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