亲测163邮箱和QQ邮箱有效,但是遇到了坑
library(mailR)
#163邮箱
send.mail(
from = "zycle@163.com",
to = "534545697@qq.com",
subject = "test for mail",
encoding = 'utf-8',
body = "this is a new shit!",
html = TRUE,
smtp = list(
host.name = "smtp.163.com",
port = 465,
user.name = "zycle@163.com",
passwd = "163邮箱的授权码", #这个授权码得用你自己的
ssl = TRUE,
tls =TRUE
),
authenticate = TRUE,
send = TRUE
)
#QQ邮箱
send.mail(
from = "534545697@qq.com",
to = "534545697@qq.com",
subject = "test for mail",
encoding = 'utf-8',
body = "this is a new shit",
html = TRUE,
smtp = list(
host.name = "smtp.qq.com",
port = 465,
user.name = "534545697@qq.com",
passwd = "QQ邮箱的授权码", #这个授权码得用你自己的
ssl = TRUE,
tls =TRUE
),
authenticate = TRUE,
send = TRUE
)
坑:
1、passwd也许应该填入一个叫授权码的东西,而不是密码;
2、from的邮箱必须跟smtp中的host.name同类:比如from="XXX@163.com“,host.name=”smtp.163.com“,同时163邮箱的端口号为465/994,详参http://help.163.com/09/1223/14/5R7P3QI100753VB8.html;
3、encoding的可选项没有GBK格式,Supported encodings include iso-8859-1, utf-8, us-ascii, and koi8-r only.