设置 Ubuntu/Apache/PHP 机器来发送电子邮件
我在胡志明市的一家小公司工作,该公司唯一的服务器只是一台旧的小型计算机。现在仅仅几个月后,我们正在迅速扩张,对新用户的要求之一就是要求他们验证他们的电子邮件地址。
Ubuntu 机器上没有特殊程序,我在实际服务器上所做的唯一一件事就是从 Windows XP 重新格式化整个硬盘并在其上安装 Natty Narwhal,然后安装 Apache 和 PHPMYADMIN。
我希望 PHP 在有人申请会员资格后立即向用户和管理员发送电子邮件。但我不知道我需要做什么才能开始。
任何关于我需要首先设置什么的想法将不胜感激;我并不是在寻找一步一步的指导,只是寻找一些提示来指引我正确的方向。
-杨文
I am working for a small Ho Chi Minh City company whose only server was just one old small computer. Now just a few months later, we are expanding rapidly and one of the requirements for new users is to require them to verify their email addresses.
There are no special programs on the Ubuntu box, instead the only thing I did on the actual server was re-format the entire hard drive from windows XP and installed Natty Narwhal on it, then install Apache and PHPMYADMIN.
I would like to have PHP to send out an email to both the user and the administrators as soon as somebody applies for membership. But I have no idea what I need to do to start.
Any ideas on what I need to set up first would be humbly appreciated; I am not looking for a step by step, just some tips to point me in the right direction.
-Duong Van
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
sudo apt-get install sendmail
将安装在本地侦听的 sendmail 副本。如果你安装了它,那么 php 就可以使用内置的mail()
函数。如果您也这样安装,也不会有成为远程中继的风险。如果您计划将邮件发送到其他互联网域,则需要确保发送邮件的计算机的 IP 地址也设置了反向 DNS 条目(PTR 记录)。如果您的 IP 没有 PTR 记录或指向通用主机(例如 1.2.3.3.domain.isp.com),大多数大型 ISP 都会拒绝您的邮件。它应该反转为类似 mail.yourdomain.com 的内容
sudo apt-get install sendmail
will install a copy of sendmail that listens locally. If you install that, then php can use the built inmail()
function. There also won't be a risk of becoming a remote relay if you install like this as well.If you plan on sending mail out to other internet domains, you will need to make sure the IP address of the machine sending mail has a reverse DNS entry (PTR record) set up as well. Most large ISP's will reject your mail if your IP does not have a PTR record or one that points to a generic host (e.g. 1.2.3.3.domain.isp.com). It should reverse to something like mail.yourdomain.com
本机邮件功能是一个很好的内置选项。
邮件功能是PHP核心的一部分,但它确实需要在服务器上安装sendmail。
我相信 sendmail 可能已经安装了您已经选择的软件包,但您可以使用以下命令检查它:
如果显示为空,您可以使用以下命令安装 sendmail:
The native mail function is a good built-in option.
The mail function is part of the PHP core, but it does require sendmail to be installed on the server.
I believe sendmail might already be installed with the packages you have already selected, but you can check for it using the command:
If that comes up empty, you can install sendmail with:
我需要第二个命令才能正确运行。 (它询问一些配置,只需每次询问时输入
Y
)The second command was needed for me to run correctly. (it asks about some configuration, just type
Y
everytime it asks)我建议安装 Postfix MTA 以从 Ubuntu 服务器发送电子邮件:
并使用 PHP Mailer 类从 PHP 发送电子邮件: http://phpmailer.worxware.com/
对于“功能齐全”的电子邮件服务,我的秘诀是:
Postfix + DKIM-proxy + Dovecot + Roundcube + PHP Mailer + SpamAssassin + 正确的 DNS 设置 + SSL 证书以启用加密连接
(我更喜欢 NginX 作为 HTTP 服务器......)
I recommend installing Postfix MTA to send e-mails out the Ubuntu server:
And using the PHP Mailer class to send e-mails from PHP: http://phpmailer.worxware.com/
For "fully featured" e-mail services my recipe is:
Postfix + DKIM-proxy + Dovecot + Roundcube + PHP Mailer + SpamAssassin + proper DNS settings + SSL certificate to enable encrypted connections
(And I prefer NginX as HTTP server...)
sendmail 就可以解决这个问题。您可以将sendmail配置为使用您的常规电子邮件smtp帐户,详细信息如下:
http:// developernote.com/2012/07/how-i-configured-sendmail-for-php-on-ubuntu-server-12-04/
专门针对 Gmail 的:
http://linuxconfig.org/configuring-gmail-as-sendmail-email-relay
sendmail 配置文件中有一个错误,您可以在此处阅读:
http://linux.koolsolutions.com/2010/ 10/14/提示-修复-sendmail-配置-错误/
sendmail does the trick. You can configure sendmail to use your regular email smtp account, details are here:
http://developernote.com/2012/07/how-i-configured-sendmail-for-php-on-ubuntu-server-12-04/
and specifically for gmail here:
http://linuxconfig.org/configuring-gmail-as-sendmail-email-relay
There is a bug in the sendmail configuration files which you can read about here:
http://linux.koolsolutions.com/2010/10/14/tip-fixing-sendmail-configuration-error/