centos 7 x64
在这个系统中 mail 是 mailx 的一个符号链接,所以是一样的。
配置文件在 /etc/mail.rc 也可以在用户主目录下创建 ~/.mailrc
对当前用户优先使用 ~/.mailrc
连接 163 和 gmail 配置如下:
163
account cn163 {
set from=nickname<user@163.com>
set smtp=smtp.163.com
set smtp-auth=login
set smtp-auth-user=user@163.com
set smtp-auth-password=password
}
Gmail
account gmailttls {
set smtp-use-starttls
set nss-config-dir=~/.mozilla/firefox/it-is-random-here.default/
set ssl-verify=ignore
set from=nickname<user@gmail.com>
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=user@gmail.com
set smtp-auth-password=password
}
发送示例:
echo “infos in body text” | mail -v -s “test-subject-text” -A cn163 destination@mail.com
echo “infos in body text” | mail -v -s “test-subject-text” -A gmailttls destination@mail.com
注意:
gmail 没有设置 2-step 验证的帐户需要打开允许不够安全的应用:已启用
。设置了 2-step 验证的参照 ref 4 使用 App password 验证。
1 https://myaccount.google.com/security?pli=1
2 https://www.digitalocean.com/community/questions/unable-to-send-mail-through-smtp-gmail-com
3 https://www.google.com/settings/security/lesssecureapps
4 https://support.google.com/mail/answer/7126229?visit_id=1-636238617108087543-2247862638&rd=2#cantsignin
5 https://support.google.com/accounts/answer/6010255
6 http://www.systutorials.com/1411/sending-email-from-mailx-command-in-linux-using-gmails-smtp/
7 http://milejko.com/blog/mailx-using-gmail-smtp
补充
阿里云个人免费邮箱 (需要在设置里启用POP/IMAP)
account aliyun {
set from=nickname<name@aliyun.com>
set smtp=smtp://smtp.aliyun.com:25
set smtp-auth=login
set smtp-auth-user=name@aliyun.com
set smtp-auth-password=pass-word
}
echo "infos in body text" | mail -v -s "test-subject-text" -A aliyun destination@mail.com
加密的方式,阿里云邮箱使用 smtps
CA证书: Let’s encrypt 不支持邮箱, 使用 Geo Trust 证书
命令: certutil
CERTUTIL(1) NSS Security Tools CERTUTIL(1)
NAME
certutil - Manage keys and certificate in both NSS databases and other NSS tokens
...
-A
Add an existing certificate to a certificate database. The certificate database should already exist; if one is not present, this
command option will initialize one by default.
...
-n nickname
Specify the nickname of a certificate or key to list, create, add to a database, modify, or validate. Bracket the nickname string
with quotation marks if it contains spaces.
The nickname can also be a PKCS #11 URI. For example, if you have a certificate named "my-server-cert" on the internal certificate
store, it can be unambiguously specified as "pkcs11:token=NSS%20Certificate%20DB;object=my-server-cert". For details about the
format, see RFC 7512.
...
-d [prefix]directory
Specify the database directory containing the certificate and key database files.
certutil supports two types of databases: the legacy security databases (cert8.db, key3.db, and secmod.db) and new SQLite databases
(cert9.db, key4.db, and pkcs11.txt).
NSS recognizes the following prefixes:
• sql: requests the sql-lite database
If no prefix is specified the default type is retrieved from NSS_DEFAULT_DB_TYPE. If NSS_DEFAULT_DB_TYPE is not set then sql: is the
default.
...
-t trustargs
Specify the trust attributes to modify in an existing certificate or to apply to a certificate when creating it or adding it to a
database. There are three available trust categories for each certificate, expressed in the order SSL, email, object signing for each
trust setting. In each category position, use none, any, or all of the attribute codes:
• p - Valid peer
• P - Trusted peer (implies p)
• c - Valid CA
• C - Trusted CA (implies c)
• T - trusted CA for client authentication (ssl server only)
The attribute codes for the categories are separated by commas, and the entire set of attributes enclosed by quotation marks. For
example:
-t "TC,C,T"
Use the -L option to see a list of the current certificates and trust attributes in a certificate database.
Note that the output of the -L option may include "u" flag, which means that there is a private key associated with the certificate.
It is a dynamic flag and you cannot set it with certutil.
...
-i input_file
Pass an input file to the command. Depending on the command option, an input file can be a specific certificate, a certificate
request file, or a batch file of commands.