PHP邮件带有www-data

如何解决PHP邮件带有www-data

| 我正在尝试通过以下代码通过PHP的mail函数调用sendmail:
$to      = \'blah@email.state.edu\';
    $subject = \'test\';
    $message = \'test\';
    $headers = \'From: mail@smartrek.blah.me\' . \"\\r\\n\" .
               \'Reply-To: mail@smartrek.blah.me\' . \"\\r\\n\" .
                \'X-Mailer: PHP/\' . phpversion();
mail($to,$subject,$message,$headers);
但是在我的mail.log中,我收到一条消息,发件人不是我在标头中指定的地址:
<www-data@Name>: Sender address rejected: Domain not found
为什么是这样??我在ubuntu上运行PHP的fast-cgi 为什么sendmail不使用我通过PHP代码指定的标头?     

解决方法

看来ѭ2是您信封的“发件人”地址。信封的“发件人”地址与电子邮件的“发件人:”标题中显示的地址不同。这就是sendmail在与接收邮件服务器的\“ MAIL FROM / RCPT TO \”交换中使用的名称。其被称为\“ envelope \”地址的主要原因是出现在原始邮件的标题和正文之外邮件服务器之间的SMTP交换。 Unix上的默认信封“发件人”地址取决于您所使用的sendmail实现。但通常将其设置为正在运行的进程的用户名,后跟\“ @ \”和计算机的主机名。在典型配置中,该外观类似于
username@example.com
。 如果您的电子邮件被接收邮件服务器拒绝,或者需要更改退回电子邮件的发送地址,则可以更改信封“发件人”地址来解决问题。 要更改unix上的信封“发件人”地址,请为sendmail二进制文件指定一个“ -r”选项。通过在\“ sendmail_path \”命令行中添加\“-r \”选项,可以在php.ini中全局执行此操作。您还可以通过在PHP中以编程方式通过将
-r mail@smartrek.blah.me
作为附加参数参数传递给mail()函数(第5个参数)来完成此操作。如果您在两个地方都指定了一个地址,则将使用两个\“-r \”选项来调用sendmail二进制文件,这些选项可能具有不确定的行为,具体取决于您的sendmail实现。使用Postfix MTA,以后的\“ -r \”选项将默默地覆盖以前的选项,从而可以设置全局默认值,并且在尝试在本地覆盖它时仍会表现出合理的行为。 编辑 关于可以传递给sendmail的可选标志:
-f
将设置发件人地址,
-r
将覆盖sendmail生成的默认返回路径(通常使用发件人地址)。如果您希望回弹到发件人地址以外的其他地址,请尝试同时使用两个标志:
-f mail@smartrek.blah.me -r bounced-mail@smartrek.blah.me
我的php.ini
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: \"sendmail -t -i\").
; http://php.net/sendmail-path
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(),even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; Log all mail() calls including the full path of the script,line #,to address and headers
;mail.log =
    ,尽管这是一个古老的问题,但我还是添加了此答案,以防对某人有所帮助: 我遇到了同样的问题,将
From:
标头重写为
www-data@host...
我最终将其跟踪到ssmtp网桥服务,该服务将邮件从我们的Web服务器传送到我们的邮件服务器。我在文件
/etc/ssmtp/ssmtp.conf
中添加了行
FromLineOverride=YES
,问题消失了。     ,就我而言,我有一个托管服务器,因此我需要编辑此文件:   /etc/ssmtp/ssmtp.conf 然后取消注释此行:   FromLineOverride =是 完成后,交友标题将正常工作。     ,发送和接收所有带有此标头的邮件时,我在www-data上也遇到类似的问题:
From: www-data <www-data@example.com>
我将
-f info@example.com
标志用作PHP email()函数的第五个参数(如已接受的答案所述),但我仍收到以下电子邮件:
From: www-data <info@example.com>
因此,我又添加了一个标记
-f info@example.com -F info
来设置电子邮件的全名,最后我得到了想要的电子邮件:
From: info <info@example.com>
我发布此答案是因为在这里没有人提及,我对此有些困惑。     ,这为我工作:
$mail->Sendmail = $mail->Sendmail.\' -f \'.$mail_errorsto; 
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-