简体   繁体   English

设置Ubuntu / Apache / PHP计算机以发送电子邮件

[英]Setting up a Ubuntu/Apache/PHP machine to send email

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. 在Ubuntu盒子上没有特别的程序,而是我在实际服务器上做的唯一一件事是从Windows XP重新格式化整个硬盘驱动器并在其上安装Natty Narwhal,然后安装Apache和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. 我想让PHP在有人申请会员资格时立即向用户和管理员发送电子邮件。 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 -Duong Van

sudo apt-get install sendmail will install a copy of sendmail that listens locally. sudo apt-get install sendmail将安装一个本地监听的sendmail副本。 If you install that, then php can use the built in mail() function. 如果你安装它,那么php可以使用内置的mail()函数。 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. 如果您计划将邮件发送到其他Internet域,则需要确保发送邮件的计算机的IP地址也设置了反向DNS条目(PTR记录)。 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 (eg 1.2.3.3.domain.isp.com). 如果您的IP没有PTR记录或者指向通用主机(例如1.2.3.3.domain.isp.com),大多数大型ISP都会拒绝您的邮件。 It should reverse to something like mail.yourdomain.com 它应该反转到mail.yourdomain.com之类的东西

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. mail函数是PHP核心的一部分,但它确实需要在服务器上安装sendmail。

I believe sendmail might already be installed with the packages you have already selected, but you can check for it using the command: 我相信sendmail可能已经安装了您已经选择的软件包,但您可以使用以下命令检查它:

dpkg --get-selections | grep sendmail

If that comes up empty, you can install sendmail with: 如果出现空白,您可以使用以下命令安装sendmail:

sudo apt-get install sendmail
sudo apt-get install sendmail
sudo sendmailconfig

The second command was needed for me to run correctly. 我需要第二个命令才能正确运行。 (it asks about some configuration, just type Y everytime it asks) (它询问一些配置,每次询问时都输入Y

I recommend installing Postfix MTA to send e-mails out the Ubuntu server: 我建议安装Postfix MTA从Ubuntu服务器发送电子邮件:

aptitude install postfix

And using the PHP Mailer class to send e-mails from PHP: http://phpmailer.worxware.com/ 并使用PHP Mailer类从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 Postfix + DKIM-proxy + Dovecot + Roundcube + PHP Mailer + SpamAssassin +正确的DNS设置+ SSL证书以启用加密连接

(And I prefer NginX as HTTP server...) (我更喜欢NginX作为HTTP服务器......)

sendmail does the trick. sendmail可以解决问题。 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/ 您可以将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 /十分之二千零十/ 14 /尖端固定-sendmail的配置错误/

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

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