ownCloud 7邮件系统设置


2014-10-29




基于Ubuntu 14.04 Server安装了OwnCloud 7.0.2.


其邮件系统有2种解决方案:1是自建邮件服务器(SMTP服务器),发自己的邮件;2是借用类似gmail/qq之类的邮件服务器发送自己的邮件


以下示例如何自建一个自己的邮件服务器 -- 其实只是一个拥有自己域名的简单的SMTP(MTA)服务器而已.



一. 安装邮件服务器Postfix 2.11


$ sudo apt-get install postfix


默认安装,两个提示处回车即可(后面牵涉的域名是我的测试系统域名.我的云https://adwangs.ezua.com).


Reading package lists... Done

Building dependency tree

Reading state information... Done

Suggested packages:

  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin

  dovecot-common postfix-cdb mail-reader postfix-doc

The following NEW packages will be installed:

  postfix

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 1,085 kB of archives.

After this operation, 3,609 kB of additional disk space will be used.

Get:1 http://ca.archive.ubuntu.com/ubuntu/ trusty/main postfix amd64 2.11.0-1 [1,085 kB]

Fetched 1,085 kB in 2s (388 kB/s)

Preconfiguring packages ...

Selecting previously unselected package postfix.

(Reading database ... 65582 files and directories currently installed.)

Preparing to unpack .../postfix_2.11.0-1_amd64.deb ...

Unpacking postfix (2.11.0-1) ...

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for man-db (2.6.7.1-1ubuntu1) ...

Setting up postfix (2.11.0-1) ...

Adding group `postfix' (GID 115) ...

Done.

Adding system user `postfix' (UID 106) ...

Adding new user `postfix' (UID 106) with group `postfix' ...

Not creating home directory `/var/spool/postfix'.                            <---------------

Creating /etc/postfix/dynamicmaps.cf

Adding tcp map entry to /etc/postfix/dynamicmaps.cf

Adding sqlite map entry to /etc/postfix/dynamicmaps.cf

Adding group `postdrop' (GID 116) ...

Done.

setting myhostname: adwangs.ezua.com                      <---------------

setting alias maps

setting alias database

changing /etc/mailname to adwangs.ezua.com        <-----------

setting myorigin

setting destinations: adwangs.ezua.com, localhost.ezua.com, localhost   <---------

setting relayhost:

setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

setting mailbox_size_limit: 0

setting recipient_delimiter: +

setting inet_interfaces: all

/etc/aliases does not exist, creating it.

WARNING: /etc/aliases exists, but does not have a root alias.


Postfix is now set up with a default configuration.  If you need to make

changes, edit

/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration

values, see postconf(1).


After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.


Running newaliases

 * Stopping Postfix Mail Transport Agent postfix                                                                                [ OK ]

 * Starting Postfix Mail Transport Agent postfix                                                                                [ OK ]

Processing triggers for ufw (0.34~rc-0ubuntu2) ...

Processing triggers for ureadahead (0.100.0-16) ...

Processing triggers for libc-bin (2.19-0ubuntu6.3) ...


手工修改Postfix的主配置文件


$ sudo mv /etc/postfix/main.cf /etc/postfix/main.cf.bak

$ sudo vi /etc/postfix/main.cf


myhostname = adwangs

mydomain = adwangs.ezua.com

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

#myorigin = /etc/mailname

myorigin = $mydomain

mydestination = adwangs.ezua.com, localhost

relayhost =

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128


我的hosts文件设置:


$ more /etc/hosts

127.0.0.1       localhost

#127.0.1.1      adwangs.ezua.com        adwangs

96.53.80.174   adwangs.ezua.com adwangs



去域名供应商(changeip)添加邮件设置记录:


添加一个mail的A记录,指向96.53.80.174(我的主机),然后再添加一个MX记录,指向mail.adwang.ezua.com(就是host内容不填,value填mail.adwang.ezua.com)



然后修改ownCloud的配置:


这里有两个地方需要修改 -- 服务器后台和客户端前台.因为owncloud提供了多种访问云端存储的前台方法,如电脑桌面客户端,智能手机客户端,和浏览器联网直接访问等.

这里以"浏览器联网直接访问"方式为例.


1.系统后台,管理员在管理界面(Admin)修改配置


因为我的Postfix是安装在OwnCloud7同一台主机上,因此,在Admin的Email Server里设置sendmail,而From Address里可以随便设置一个邮箱,如abc@adwangs.ezua.com,让收件人知道该邮件从哪里发来的.


2.用户以浏览器方式进入ownCloud时,登录后,在自己的personel里添加一个邮箱,如abc@hotmail.com.(每个用户自己可以决定输入自己的有效email地址),然后还可以根据自己的需要勾选Notifications里的选项.