为Bareos配置外部SMTP邮件服务器
Bareos可以用电子邮件将有关信息发送到邮箱,并提供了bsmtp邮件发送工具。bsmtp工具很简单,并不适用一般中小微企业情况。本文将介绍如何配置外部SMTP服务器为Bareos发送邮件。
安装配置postfix服务
安装Postfix
root@bareos:~# apt install libsasl2-modules postfix mailutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
libsasl2-modules is already the newest version (2.1.27~101-g0780600+dfsg-3ubuntu2).
The following additional packages will be installed:
guile-2.0-libs libgc1c2 libgsasl7 libkyotocabinet16v5 libltdl7 libmailutils5 libmysqlclient20 libntlm0 libpython2.7 libpython2.7-minimal
libpython2.7-stdlib mailutils-common mysql-common ssl-cert
Suggested packages:
mailutils-mh mailutils-doc procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre postfix-lmdb postfix-sqlite sasl2-bin
dovecot-common resolvconf postfix-cdb postfix-doc openssl-blacklist
The following NEW packages will be installed:
guile-2.0-libs libgc1c2 libgsasl7 libkyotocabinet16v5 libltdl7 libmailutils5 libmysqlclient20 libntlm0 libpython2.7 libpython2.7-minimal
libpython2.7-stdlib mailutils mailutils-common mysql-common postfix ssl-cert
0 upgraded, 16 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,916 kB of archives.
After this operation, 43.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
......
......
......
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for rsyslog (8.32.0-1ubuntu4) ...
Processing triggers for ufw (0.35-5) ...
root@bareos:~#
当询问邮件设置类型时,暂时选择“No configuration”,我们将在后面手工配置。
配置postfix
现在的SMTP服务,一般都会有严格的安全控制,包括QQ邮箱、阿里邮箱。如以前经常使用的方式:以account1授权发送邮件,在邮件头使用From:account2或Reply-to:account3的方式来说明不同的邮件来源,现在已不可行,account2和account3都必须独立验证授权。为此,我们需要为postfix配置三个文件,分别是main.cf
、sasl_passwd
和sender_relay
。
配置 main.cf
/etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Bareos)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = lswin.cn
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
myne