简体   繁体   English

如何让PHP向本地用户发送邮件(cakePHP,Linux SLES)

[英]How to get PHP to send mail to local users (cakePHP, Linux SLES)

Currently I have a mail server configured (a real one from my ISP) and mail internal and external works on the command line. 目前我配置了一个邮件服务器(来自我的ISP的真实邮件服务器),并在命令行上邮件内部和外部工作。 In PHP only external users work. 在PHP中只有外部用户才能工作。

For testing I would like to send to internal users only. 对于测试,我只想发送给内部用户。

( Ideally I would like to set up lots of aliases that point to one user so mail to: tom@localhost.com, dick@localhost.com, harry@localhost.com end up in /var/mail/johnsmith ) (理想情况下,我想设置许多指向一个用户的别名,所以邮件发送到:tom@localhost.com,dick @ localhost.com,harry @ localhost.com最终发送到/ var / mail / johnsmith)

I'd be greatful if someone could help here. 如果有人可以帮助我,我会很高兴。 I'm hesitant to edit the postfix config files... 我对编辑postfix配置文件犹豫不决...

On the command line johnsmith@localhost works but not in PHP. 在命令行上johnsmith @ localhost可以工作但不能在PHP中工作。 It's using cakePHP and I checked the value of $email-addr just before the send ($this->Email->send();) and the value is johnsmith@localhost. 它正在使用cakePHP,我在发送之前检查了$ email-addr的值($ this-> Email-> send();),值为johnsmith @ localhost。 I'm not that familiar with cakePHP yet. 我对cakePHP还不熟悉。 The var/log/mail shows nothing, only external email addresses. var / log / mail没有显示任何内容,只显示外部电子邮件地址。

(server is Suse linux) (服务器是Suse linux)

You can use the basic mail php function 您可以使用基本邮件php功能

http://php.net/manual/en/function.mail.php http://php.net/manual/en/function.mail.php

Under linux, mail php function relies on sendmail, just check that sendmail is properly installed. 在linux下,邮件php功能依赖于sendmail,只需检查sendmail是否正确安装。

In /etc/postfix/main.cf add localhost.com: 在/etc/postfix/main.cf中添加localhost.com:

mydestination = $myhostname, localhost.$mydomain,localhost,localhost.com

This allows sending on "localuser@localhost.com" via command line. 这允许通过命令行发送“localuser@localhost.com”。 I loaded up a test php mail form script in a browser and it works, sending mail through to /var/mail/localuser. 我在浏览器中加载了一个测试php邮件表单脚本,它可以工作,将邮件发送到/ var / mail / localuser。

At the moment it means I have to check each local users /var/mail file. 目前,这意味着我必须检查每个本地用户/ var / mail文件。 I'm working on the alias. 我正在研究别名。 My first attempt at that failed. 我的第一次尝试失败了。

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

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