Centos - 如何安装 SMTP 服务器、POP3 和 IMAP 以将电子邮件发送到 Gmail、Yahoo、Hotmail、Live、Yandex?

Centos - 如何安装 SMTP 服务器、POP3 和 IMAP 以将电子邮件发送到 Gmail、Yahoo、Hotmail、Live、Yandex?

我在 mediatemple.net 上有一个 CentOS 6.4,我需要向 Gmail、Hotmail 等发送电子邮件。

我尝试安装 postfix、sendmail、dovecot、cyrus、procmail、spamassassin 等,但甚至不起作用,因为在测试时,邮件从未离开或抛出错误。

我可以说我安装了 SMTP 服务器、POP3、IMAP,它可以将邮件发送到 Gmail、Hotmail、Live、Yandex、Yahoo 等。

安装:

# yum install sendmail*
# yum install cyrus*
# yum install dovecot
# yum install procmail
# yum install spamassassin

配置Sendmail:

# nano /etc/mail/sendmail.mc

define(`confLOG_LEVEL', `20')dnl 
define(`confAUTH_OPTIONS', `A p')dnl 
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl 
define(`confCACERT_PATH', `/etc/pki/tls/certs')dnl
define(`confCACERT', `/etc/pki/tls/certs/ca-bundle.crt')dnl
define(`confSERVER_CERT', `/etc/pki/tls/certs/sendmail.pem')dnl
define(`confSERVER_KEY', `/etc/pki/tls/certs/sendmail.pem')dnl
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl 
DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl 
DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl 
dnl FEATURE(`accept_unresolvable_domains')dnl 
INPUT_MAIL_FILTER(`spamassassin', `S=unix:/var/run/spamassassin/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnl 
define(`confMILTER_MACROS_CONNECT',`t, b, j, _, {daemon_name}, {if_name}, {if_addr}')dnl 
define(`confMILTER_MACROS_HELO',`s, {tls_version}, {cipher}, {cipher_bits}, {cert_subject}, {cert_issuer}')dnl

# nano /etc/mail/local-host-names
*

配置 Devcot:

# nano /etc/dovecot.conf

protocols = imap imaps pop3 pop3s 
ssl_cert_file = /etc/pki/tls/certs/sendmail.pem 
ssl_key_file = /etc/pki/tls/certs/sendmail.pem 
ssl_ca_file = /etc/pki/tls/certs/sendmail.pem 
verbose_ssl = yes


# chkconfig dovecot on

配置SpamAssassin:

# cd /etc/mail/spamassassin
# mv local.cf local.cf.orig
# nano local.cf

required_score          5.0 
rewrite_header subject  [SPAM] 
report_safe             1 
use_bayes               1 
use_bayes_rules         1 
bayes_auto_learn        1 
skip_rbl_checks         0

# chkconfig spamassassin on
# cd /usr/src
# wget http://www.voztovoice.org/tmp/spamass-milter-0.3.1.tar.gz
# tar -xf spamass-milter-0.3.1.tar.gz
# cd spamass-milter-0.3.1
# yum install gcc ncurses ncurses-devel make gcc-c++ libtermcap libtermcap-devel zlib zlib-devel libtool
# ./configure
# make
# make install
# cd contrib
# nano spamass-milter-redhat.rc

SM_SOCKET=/var/run/spamassassin/spamass-milter.sock 
[ -x /usr/local/sbin/spamass-milter ] || exit 0 
PATH=$PATH:/usr/local/sbin

# cp spamass-milter-redhat.rc /etc/init.d/spamass-milter
# cd /etc/init.d
# chmod +x spamass-milter
# chkconfig --level 2345 spamass-milter on
# nano /etc/sysconfig/spamass-milter

SOCKET=/var/run/spamassassin/spamass-milter.sock 
EXTRA_FLAGS="-r 15"

# reboot

日志和测试

# nano /var/log/maillog
# yum install telnet
# telnet

telnet> o localhost 25 
Trying 127.0.0.1... 
Connected to localhost.localdomain (127.0.0.1). 
Escape character is '^]'. 
220 ejemplo.org ESMTP Sendmail 8.13.8/8.13.8; Tue, 13 Oct 2009 15:20:59 GMT 
ehlo root.com 
250-example.org Hello localhost [127.0.0.1], pleased to meet you 
250-ENHANCEDSTATUSCODES 
250-PIPELINING 
250-8BITMIME 
250-SIZE 
250-DSN 
250-ETRN 
250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5 
250-STARTTLS 
250-DELIVERBY 
250 HELP


quit


# spamassassin -t < /usr/share/doc/spamassassin-3.3.1/sample-nonspam.txt | grep X-Spam


X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on ejemplo.org 
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=no version=3.2.5


spamassassin -t < /usr/share/doc/spamassassin-3.3.1/sample-spam.txt | grep X-Spam


X-Spam-Flag: YES 
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on astercurso.com 
X-Spam-Level: ************************************************** 
X-Spam-Status: Yes, score=1000.0 required=5.0 tests=GTUBE,NO_RECEIVED,

答案1

不起作用不是描述问题的最佳方式,dovecot 接收电子邮件,而 sendmail/postfix 发送电子邮件,因此您只需安装其中一个,如果你问我,sendmail 更简单。如果你从表单发送,那么问题很可能出在你的代码上。

如果你只想创建联系表单,那么使用foxyform.com。如果安装邮件服务器对你来说很困难,那么可以考虑使用邮件系统,这是一个包含所有内容的包。

要安装 sendmail,只需

yum install sendmail

这样就可以了,问题更可能出在你的代码中,请提供更多细节

相关内容