ubuntu配置邮件服务

Centos下直接在/etc/mail.rc下配置就可以发送文件了

set from=abc@163.com smtp=smtp.163.com smtp-auth-user=abc@163.com smtp-auth-password=passwd  smtp-auth=login

 

ubuntu下可以安装ssmtp来实现邮件的发送

首先安装ssmtp

aptitude install ssmtp mailutils


然后再/etc/ssmtp目录下配置

ssmtp.conf的配置文件

# Config file for sSMTP sendmail

#

# The person who gets all mail for userids < 1000

# Make this empty to disable rewriting.

root=自己邮箱地址

# The place where the mail goes. The actual machine name is required no

# MX records are consulted. Commonly mailhosts are named mail.domain.com

mailhub=邮箱smtp服务器地址

# Where will the mail seem to come from?

#rewriteDomain=

# The full hostname

hostname=主机名

# Are users allowed to set their own From: address?

# YES - Allow the user to specify their own From: address

# NO - Use the system generated From: address

FromLineOverride=YES

AuthUser=邮箱地址

AuthPass=邮箱密码

 

Revaliases文件的配置

# sSMTP aliases

#

# Format:   local_account:outgoing_address:mailhub

#

# Example: root:your_login@your.domain:mailhub.your.domain[:port]

# where [:port] is an optional port number that defaults to 25.

root:自己的邮箱:邮箱smtp服务器地址:端口  (如果这里写root,那么只有root用户有权限使用,其他用户使用会报错cannot send message: Process exited with a non-zero status  )

#如自己的邮箱是腾讯的企业邮箱:

#root:自己邮箱:imap.exmail.qq.com:465    

 

配置完成后之后用 mail abc@163.com  发送邮件了


在这里我遇到过一个问题,mail时报错 cannot send message: Process exited with a non-zero status

检查之后发现是我把邮箱密码写错了,修改之后不再报错

如果报这个错有以下可能

1.配置文件写的不正确

2.安装了sendmail之类的邮件服务没有关闭,会导致冲突

3.没有使用root权限来运行mail

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Ubuntu 20.04是一款非常流行的Linux操作系统,它可以非常方便地配置邮件服务器SMTP和IMAP。 首先,我们需要安装邮件服务器软件。Ubuntu 20.04系统中默认安装了Postfix邮件服务器,我们只需要打开终端输入以下命令进行安装即可: sudo apt-get update sudo apt-get install postfix 接下来,我们需要配置Postfix邮件服务器。我们可以在/etc/postfix/main.cf文件中进行配置。以下是一个简单的配置示例: myhostname = mail.example.com mydestination = example.com, mail.example.com, localhost.example.com, localhost mynetworks = 127.0.0.0/8, [::1]/128 smtpd_banner = $myhostname ESMTP smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous 在上述示例配置中,邮件服务器的主机名是mail.example.com,邮件服务器可以发送电子邮件到example.com,mail.example.com和本地主机名localhost.example.com。邮件服务器还可以忽略其他来源的Emails。 我们还需要配置SMTP和IMAP认证。可以使用Dovecot软件提供这些服务。我们可以使用以下命令来安装Dovecot: sudo apt-get install dovecot-core dovecot-imapd dovecot-pop3d 接下来我们可以在/etc/dovecot/conf.d/10-auth.conf和/etc/dovecot/conf.d/10-master.conf两个配置文件中进行认证配置。 最后,重启邮件服务器和Dovecot服务,我们就可以通过SMTP和IMAP协议使用邮件服务器发送和接收邮件了! ### 回答2: 配置邮件服务器SMTP和IMAP是一个相对复杂的过程,需要正确地设置各种参数,以确保基于Ubuntu 20.04的邮件服务器可以顺利地工作。下面是一些步骤供参考: 1. 安装邮件服务器软件:Ubuntu 20.04中默认安装了Postfix邮件服务器软件,运行以下命令进行安装: sudo apt-get update sudo apt-get install postfix 2. 配置SMTP服务器:默认情况下,Postfix配置为仅在本地主机上接受邮件。要允许其他计算机发送邮件,请编辑/etc/postfix/main.cf,在“myhostname”行下添加以下行: mydestination = example.com, localhost.example.com, localhost 其中“example.com”应替换为您的域名。保存配置更改并重新启动Postfix服务: sudo service postfix restart 3. 配置IMAP服务器:Ubuntu 20.04默认安装Dovecot IMAP服务器软件。编辑/etc/dovecot/conf.d/10-auth.conf文件,在“disable_plaintext_auth”行下添加以下行: auth_mechanisms = plain login 接下来,在/etc/dovecot/conf.d/10-master.conf文件中找到以下行,将其注释掉: #unix_listener /var/spool/postfix/private/auth { #mode = 0660 #user = postfix #group = postfix #} 最后,重新启动Dovecot服务: sudo service dovecot restart 4. 测试SMTP和IMAP服务器:你可以使用常见邮件客户端,如Outlook或Thunderbird,登录到你的SMTP和IMAP服务器并发送/接收邮件来测试服务器的配置。 以上是配置Ubuntu 20.04的邮件服务器SMTP和IMAP的一些基本步骤。这个过程可以有很多的细节,需要逐一处理以确保正确地连接和使用邮件服务器。 ### 回答3: Ubuntu20.04作为一款免费的开源操作系统,具有众多功能强大的特性,配置邮件服务器 stmp imap也是非常方便的。下面介绍一下如何在Ubuntu20.04上配置邮件服务器。 首先,我们需要安装基本的邮件服务软件,其中包括 Postfix、Dovecot、SASL 和 AnonTLS 等。我们可以使用以下命令来完成软件的安装: sudo apt-get update sudo apt-get install postfix dovecot-core dovecot-imapd dovecot-pop3d sasl2-bin libsasl2-modules-ldap openssl-blacklist 安装完毕后,我们需要通过以下命令来配置 Postfix: sudo nano /etc/postfix/main.cf 在该文件中,我们需要做如下配置: myhostname = your.mail.server.com mydomain = your.mail.server.com myorigin = your.mail.server.com inet_interfaces = all mydestination = your.mail.server.com, localhost smtpd_banner = $myhostname ESMTP 在这些设置中,myhostname、mydomain 和 myorigin 都应该设置为您的邮件服务器的主机名。接下来,我们需要配置 Dovecot,在 /etc/dovecot/dovecot.conf 文件中增加以下设置: protocols = imap pop3 auth_mechanisms = plain login disable_plaintext_auth = no ssl = no pop3_uidl_format = %08Xu%08Xv 在这些设置中,protocols 配置了 Dovecot 所支持的客户端访问协议,auth_mechanisms 配置了认证方式,disable_plaintext_auth 设置为 no 表示能够使用明文密码认证登录。pop3_uidl_format 是用于 POP3 下载时保证每个邮件的唯一性的设置。 此时我们已完成 SMTP 和 IMAP 邮件服务器的基本配置。接下来我们需要设置邮件用户的身份认证信息。具体的说明如下: 1. 在 /etc/saslpasswd2 文件中新建帐户信息,每行只能记录一个帐户,格式为“username: password”。 2. 我们需要设置 saslauthd 的配置参数,在 /etc/default/saslauthd 文件中设置以下参数: START=yes AUTHMECH=shadow MECHANISMS="ldap plain" ARGS="-c -m /var/run/saslauthd -O /etc/saslauthd.conf" 3. 根据上述命令执行后,我们需要在 /etc/saslauthd.conf 文件中设置 SASL 认证的基本参数: verbosity: 0 mech_options: <empty> pwcheck_method: saslauthd mech_list: plain login 4. 最后,我们需要设置用户帐户在 LDAP 数据库中的信息,在 /etc/postfix/sasl/smtpd.conf 文件中增加以下设置: pwcheck_method: saslauthd mech_list: plain login log_level: 4 auxprop_plugin: sasldb mech_disable: CRAM-MD5 DIGEST-MD5 至此,我们在 Ubuntu20.04 上已经设置好了邮件服务器,我们可以通过 IMAP、POP3、SMTP 等协议访问邮件服务器,获取邮箱中存储的邮件信息。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值