我的 php 脚本以哪个用户身份发送电子邮件?
我已经设置了一个 postfix 邮件服务器,现在我可以通过“localhost”、端口 25 发送连接到 smtp 服务器的电子邮件。
但我不知道如何检查邮件是由哪个用户发送的。我可以在不验证自己身份的情况下发送,尽管它不是开放中继:它似乎只适用于本地主机。
我想被迫进行身份验证,或者至少知道哪个用户正在发送邮件,这样我就可以为他设置配额,以及允许的“发件人”(现在我可以选择任何可用的域作为发件人,当通过 php 脚本发送时)
除了 /var/log/maillog 中的“发件人”和“收件人”邮件之外,我找不到任何其他内容。
有什么想法吗?
I have set up a postfix mailserver, and now I can send emails connecting to the smtp server through 'localhost', port 25.
But I don't know how to check as which user the mail has been sent. I can send without authenticating myself, though it's not an open relay: it seems to work only for localhost.
I would like to be forced to authenticate, or at least know which user is sending the mail, so I can set a quota for him, and a permitted 'from' (right now I can pick any of the available domains as the sender, when sending through a php script)
I couldn't find anything other than the mail 'from' and 'to' in /var/log/maillog.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题很混乱。
我假设您正在谈论使用“mail”命令时会发生什么;在 Unix 系统上,这只运行 php.ini 文件中定义的程序 - 有一些库允许您通过创建到 MTA 的网络连接来发送邮件 - 在这种情况下,MTA 无法直接使用 uid - 并且是大多数管理员配置身份验证的场景。
发送者的 uid 将是 PHP 运行时的 uid。
MTA 是否需要身份验证与调用邮件的 uid 关系不大。
在这种情况下,电子邮件的发件人将是电子邮件的发件人地址。
然后使用基于套接字的邮件程序,例如 phpmailer() 并将您的 MTA 配置为需要身份验证。
You're question(s) is very confused.
I'll assume you are talking about what happens when you use the 'mail' command; on a Unix system this just runs a program defined in the php.ini file - there are libs which allow you to send a mail by creating a network connection to a MTA - in which case the uid is not available directly to the MTA - and is the scenarion in which most admins would configure authentication.
The uid of the sender will be the uid as whom PHP runs as.
Whether or not the MTA requires authentication has little to do with the uid invoking mail.
In this scenario, the sender of the email will be the FROM address of the email.
Then use a socket based mailer such as phpmailer() and configure your MTA to require authentication.