Mail

############################

#######   postfix #######

############################

·准备


1.

postfix提供smtp协议用来投递邮件

默认端口25

/var/log/maillog##服务日志

mail [email protected]

Subject: hello

hello world

.#用"."来结束录入内容并发送

mailq##查看邮件队列

postqueue -f##重新处理邮件队列

默认情况下邮件端口只在127.0.0.1上开启

2.

配置

vim /etc/postfix/main.cf

116 inet_interfaces = all##25端口开启的网络接口

76 myhostname = westos-mail.westos.com##指定mta主机名称

83 mydomain = westos.com##指定mta的域名

99 myorigin = westos.com##指定邮件来源结尾(@后面的字符内容)

164 mydestination = $myhostname, $mydomain, localhost##接收邮件结尾字符的指定

systemctl restart postfix.service

systemctl stop firewalld

3.邮件别名

[[email protected] ~]# vim /etc/aliases

别名:真名##邮件别名

别名::include:filename##邮件群发

vim filename

user1

user2

postalias /etc/aliases

mail 别名

4.通过远程主机测试邮件服务

[[email protected] Desktop]$ telnet 172.25.254.100 25

Trying 172.25.254.100...

Connected to 172.25.254.100.

Escape character is ‘^]‘.

220 westos-mail.westos.com ESMTP Postfix

ehlo hello

250-westos-mail.westos.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

adsf

asdf

asdf

.

5.邮件客户端的访问控制

#限制客户端

在mta上

postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"

vim /etc/postfix/access

172.25.254.22REJECT

postmap /etc/postfix/access

systemctl restart postfix

测试

[[email protected] ~]# telnet 172.25.254.100 25

Trying 172.25.254.100...

Connected to 172.25.254.100.

Escape character is ‘^]‘.

220 westos-mail.westos.com ESMTP Postfix

mail from:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

554 5.7.1 <unknown[172.25.254.22]>: Client host rejected: Access denied

##限制用户发送

postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

vim /etc/postfix/sender

[email protected]

postmap  /etc/postfix/sender

systemctl restart postfix

测试

[[email protected] Desktop]$ telnet 172.25.254.100 25

Trying 172.25.254.100...

Connected to 172.25.254.100.

Escape character is ‘^]‘.

220 westos-mail.westos.com ESMTP Postfix

mail from:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

554 5.7.1 <[email protected]>: Sender address rejected: Access denied

##限制用户接收

postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"

vim /etc/postfix/recip

[email protected]

postmap /etc/postfix/recip

systemctl restart postfix

测试

[[email protected] Desktop]$ telnet 172.25.254.100 25

Trying 172.25.254.100...

Connected to 172.25.254.100.

Escape character is ‘^]‘.

220 westos-mail.westos.com ESMTP Postfix

mail from:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

adsf

adsf

asdf

.

250 2.0.0 Ok: queued as DE17D2461EA

qiut

502 5.5.2 Error: command not recognized

mail from:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

554 5.7.1 <[email protected]>: Recipient address rejected: Access denied

##出站地址伪装

postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"

vim /etc/postfix/generic

[email protected]@sb.com

postmap /etc/postfix/generic

systemctl restart postfix

测试

su - westos

mail [email protected]

##入战地址转换

dns mx 记录解析先做好

postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

/etc/postfix/virtual

虚拟名字真实用户

[email protected]@westos.com

postmap /etc/postfix/virtual

systectl restart postfix

测试

mail [email protected]

####################################

#########   dovecot  ###############

####################################

1.

dovecot 用来提供收件协议

pop3   110

imap   143

pop3s  995

imaps  993

/etc/services   ###所有服务的所有端口

2.

yum install dovecot y

3.

vim /etc/dovecot/dovecot.conf

24 protocols = imap pop3 lmtp

48 login_trusted_networks = 0.0.0.0/0

49 disable_plaintext_auth = no

vim /etc/dovecot/conf.d/10-mail.conf

30 mail_location = mbox:~/mail:INBOX=/var/mail/%u

systemctl restart dovecot

mkdir /etc/skel/mail/.imap -p           ###在用户骨架文件中建立所需目录及文件

touch /etc/skel/mail/.imap/INBOX

useradd westos

passwd westos

测试

yum install mutt -y

mutt -f pop://[email protected]

###################

thunderbrid

####################

thunderbird

收发邮件应用

#########################

postfix + mariadb

#########################

准备工作

yum install httpd php php-mysql mariadb-server -y

config mariadb

mysql_secure_installation

create databs

create table

1.

vim /etc/postfix/mailuser.cf  ##用户名称查询

host = localhost##数据库所在主机

user = postuser##登陆数据库的用户

password = 123##登陆数据库的密码

dbname = email##postfix要查询的名称

table = emailuser##postfix要查询的表的名称

select_field = username##postfix要查询的字段

where_field = username##用户给定postfix的查询条件

vim /etc/postfix/maildomain.cf      ##用户域名查询

host = localhost

user = postuser

password = 123

dbname = email

table = emailuser

select_field = domain

where_field = domain

vim /etc/postfix/mailbox.cf     ##用户邮箱位置查询

host = localhost

user = postuser

password = 123

dbname = email

table = emailuser

select_field = maildir

where_field = username

postmap -q "[email protected]" mysql:/etc/postfix/mailuser.cf

[email protected]

postmap -q "mmm.com" mysql:/etc/postfix/maildomain.cf

mmm.com

postmap -q "[email protected]" mysql:/etc/postfix/mailbox.cf

/mnt/mmm.com/mmm

配置postfix

groupadd -g 666 vmail

useradd -s /sbin/nologin -u 666 -g 666 vmail

postconf -e "virtual_mailbox_base = /home/vmail"##设定虚拟账户的邮件目录

postconf -e "virtual_uid_maps = static:666"##虚拟账户建立文件的uid

postconf -e "virtual_gid_maps = static:666"##虚拟用户建立文件的gid

postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"

postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf"

postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

时间: 2024-10-11 17:57:17

Mail的相关文章

Linux发邮件之mail

1.安装 (需要sendmail或postfix服务) sendmail     # yum install sendmail      # systemctl start sendmail.service     # systemctl status sendmail.service postfix     # yum install mailx     # systemctl start postfix.service     # systemctl status postfix.servi

linux mail 命令参数

使用mail发邮件时,必须先将sendmail服务启动. mail –s “邮件主题” –c”抄送地址” –b “密送地址” -- -f 发送人邮件地址 –F 发件人姓名 < 要发送的邮件内容 三种常用格式发信    mail -s test [email protected]                         #第一种方法,你可以把当前shell当成编辑器来用,编辑完内容后Ctrl-D结束    echo “mail content”|mail -s test [email pr

Java Mail发送

package com.xuo.jms; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMess

#22 系统进程调度、at、batch、mail、crontab

Linux系统的进程调度(任务调度) 进度调度:在未来某个时间点,让系统自动执行我们事先编写好的命令或脚本的列表,从而使得即使用户不在计算机旁边也可以按时完成任务: 为了能够进行进程调度,就必须要有一种机制能够识别事件发生的时间并且能够运行用户所预期的命令:这种机制在Linux中是通过特定的守护进程来实现的: 这类守护进程包括: atd: 将预先编写好的命令在未来某个时间点执行一次: crond: 将预先编写好的命令在未来的符合条件的时间点重复执行: 查看此类守护进程是否正常运行: centos

System.net.mail 腾讯ssl发送邮件超时

我采用了.net 的自带组件 System.Web.Mail.MailMessage发送邮件,主要是在客户注册网站成功的时候发条欢迎邮件,最近邮件无法发送了,看了下腾讯smtp邮件配置,所有的邮件发送都换成ssl了,之前用的是25端口,现在换成了465或587,于是修改代码如下: MailMessage msgMail = new MailMessage("发件箱", "收件箱", "邮件标题", "邮件内容",2); Smt

zabbix使用系统自带mailx(mail)SMTP发送邮件

0x01,环境介绍: 我们用的是微软的邮箱打算用SMTP方式发送邮件.先登录账户看官方给出SMTP信息. 0x02,系统mailx(mail)设置. 通过命令可以看到,mail实际上是mailx的快捷方式.然后在/etc/mail.rc里加入账号等信息. SMTP加密方式是:STARTTLS set from=Zabbix使用的发送邮件地址 set smtp=smtp.office365.com set smtp-auth-user=Zabbix使用的发送邮件地址 set smtp-auth-p

com.sun.mail.smtp.SMTPSendFailedException: 553 Mail from must equal authorized user

1.错误描写叙述 553 Mail from must equal authorized user com.sun.mail.smtp.SMTPSendFailedException: 553 Mail from must equal authorized user at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333) at com.sun.mail.smtp.SMTPTransport.mail

使用mail.rc快速配置linux发邮件服务

1.系统环境. [[email protected] ~]# cat /etc/redhat-release  CentOS release 6.8 (Final) [[email protected] ~]# uname -r 2.6.32-642.el6.x86_64 [[email protected] ~]# uname -m x86_64 2.通过修改配置文件/etc/mail.rc可以使用外部SMTP服务器,轻松实现linux发邮件功能. [[email protected] ~]#

使用java mail 发送邮件

1.关联jar包:   activation.jar   mail.jar 2.调用 @Test public void test1() { List<String> imageUrlList = Arrays.asList(new String[] { "src/美女1.jpg", "src/2.jpg", "src/2.jpg" }); List<String> attachmentUrlList = Arrays.a

三.mail 接收权限 dovecot加密通信 php数据库 thunderbird

postconf -d:查看默认设置postconf -n:查看当前设置postconf -e "inet_interfaces = all":修改选项inet_interfaces 参数指定postfix系统监听的网络接口. 一.邮件的限制==access==   ##禁止某个ip接受邮件[[email protected] ~]# cd /etc/postfix/[[email protected] postfix]# lsaccess     generic        mai