mail mailx 发送邮件 163 gmail 阿里云

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.


阿里云免费个人邮箱IMAP、POP、SMTP地址和端口信息

阿里邮箱SMTP发信代码示例 Python PHP Java

阿里邮箱域名解析IP

在阿里云上无法使用mailx发送邮件的解决办法,验证可用

linux脚本空间预警,并发送邮件

Linux使用mail发送电子邮件

Centos8配置Mail

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值