vps 配置邮件备份 solo

  |   0 评论   |   0 浏览

安装 mailx

yum install mailx -y

配置 mail.rc

vi /etc/mail.rc

 1 set from="[email protected]" 
 2
 3set smtp=smtps://smtp.163.com:465
 4
 5set smtp-auth-user=xxxxx
 6
 7set smtp-auth-password=xxxxx
 8
 9set smpt-auth=login
10
11#set smtp-use-starttls=true
12
13set ssl-verify=ignore
14
15set nss-config-dir=/root/.certs

生成 163 证书

 1mkdir -p /root/.certs/                           ####创建目录,用来存放证书  
 2echo -n | openssl s\_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt ####向163请求证书
 3  
 4depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA  
 5verify return:1  
 6depth=1 C = US, O = GeoTrust Inc., CN = GeoTrust SSL CA - G3  
 7verify return:1  
 8depth=0 C = CN, ST = Zhejiang, L = Hangzhou, O = "NetEase (Hangzhou) Network Co., Ltd", OU = MAIL Dept., CN = \*.163.com  
 9verify return:1  
10DONE  
11
12 certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt                  ####添加一个证书到证书数据库中  
13
14 certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt               ####添加一个证书到证书数据库中  
15
16 certutil -L -d /root/.certs                                                                                         ####列出目录下证书  
17Certificate Nickname Trust Attributes  
18SSL,S/MIME,JAR/XPI  
19GeoTrust SSL CA

测试邮件发送

1mailx -v -s 邮箱测试 [email protected] < 163.crt
 1Resolving host smtp.163.com . . . done.
 2
 3Connecting to 123.125.xx.133:465 . . . connected.
 4
 5Comparing DNS name: "\*.163.com"
 6
 7SSL parameters: cipher=AES-256-GCM, keysize=256, secretkeysize=256,
 8
 9issuer=CN=GeoTrust SSL CA - G3,O=GeoTrust Inc.,C=US
10
11subject=CN=\*.163.com,O="NetEase (Hangzhou) Network Co., Ltd",L=HangZhou,ST=ZheJiang,C=CN
12
13220 163.com Anti-spam GT for Coremail System (163com\[20141201\])
14
15\>>> EHLO vultr.guest
16
17250-mail
18
19250-PIPELINING
20
21250-AUTH LOGIN PLAIN
22
23250-AUTH=LOGIN PLAIN
24
25250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFqBWZOUCa0xDrUUUUj
26
27250-STARTTLS
28
29250 8BITMIME
30
31\>>> AUTH LOGIN
32
33334 dXNlcm5hbWU6
34
35\>>> bXVmZW5nNTYxOQ==
36
37334 UGFzc3dvcmQ6
38
39\>>> bXVmZW5nNTYxOQ==
40
41235 Authentication successful
42
43\>>> MAIL FROM:<[email protected]>
44
45250 Mail OK
46
47\>>> RCPT TO:<[email protected]>
48
49250 Mail OK
50
51\>>> DATA
52
53354 End data with <CR><LF>.<CR><LF>
54
55\>>> .
56
57250 Mail OK queued as smtp3,DdGowACHgZ3hrchb2KIvAA--.29S2 1539878374
58
59\>>> QUIT
60
61221 Bye

  到此邮件支持就已经完成了

定时任务脚本

1tar -czvf blog_$(date +%Y_%m_%d).tar.gz blog solo_h2
2
3echo "博客备份"| mailx -v -a ../blog\_2018\_10\_18.tar.gz -s 邮箱测试 [email protected]

添加定时任务

1[[email protected] ~]# crontab -l
2
30 0 3 * * /bin/bash /root/bakup.sh

  再也不用担心服务器挂掉的问题了

---------------------------------------------------------------
>> 博客地址:https://blog.mufengs.com
>> 邮箱地址:[email protected]
>> 微信帐号:Do8080
>> Github : https://github.com/mufengcoding
---------------------------------------------------------------