设为首页收藏本站获取积分奖励

R语言中文网

 找回密码
 立即注册
查看: 2754|回复: 2

[问题求助] R语言发邮件

[复制链接]
发表于 2017-10-12 09:49:10 | 显示全部楼层 |阅读模式
如题,本人参考以下网站,尝试使用R语言发送邮件
  • http://blog.csdn.net/small_farmer/article/details/52713795

[color=rgb(51, 102, 153) !important]复制代码


代码如下:
  • library(mailR)
  • #body正文
  • body = "this is a test"
  • #收件人
  • recipients <- c("***@163.com", "***@qq.com")
  • #发件人
  • sender = "***@163.com"
  • #主题
  • title = "this is a title"
  • #填上邮箱密码code,如body是html,设置body=html参数,那么发出来的正文就是html格式的了
  • sendmail(
  •   from = sender,
  •   to = recipients,
  •   subject = title,
  •   body = html,
  •   encoding = "utf-8",
  •   html = TRUE,
  •   smtp = list(
  •     host.name = "smtp.163.com",
  •     port = 465,
  •     user.name = ***,
  •     passwd = "***",
  •     ssl = TRUE
  •   ),
  •   authenticate = TRUE,
  •   send = TRUE
  • )

[color=rgb(51, 102, 153) !important]复制代码


出现了如下错误:
  • Error in socketConnection(host = server, port = port, blocking = TRUE) :
  •   cannot open the connection
  • In addition: Warning message:
  • In socketConnection(host = server, port = port, blocking = TRUE) :
  •   localhost:25 cannot be opened

[color=rgb(51, 102, 153) !important]复制代码


亲爱的坛友们,这是怎么回事?怎么解决
请赐教
谢谢
回复

使用道具 举报

发表于 2017-10-13 08:29:29 | 显示全部楼层
11.sendmail(           #mailR包中,发送函数是send.mail而不是sendmail。当然可能版本不同,写法不一样。
12.  from = sender,
13.  to = recipients,
14.  subject = title,
15.  body = html,        #写成body=body,后面那个body是你前面定义的那个变量,建议自己定义的变
                                #量不要和函数中的参数变量同名;
16.  encoding = "utf-8",
17.  html = TRUE,
18.  smtp = list(
19.    host.name = "smtp.163.com",
20.    port = 465,                 #我的邮箱属性中SMTP的port号为25,建议你到自己的邮箱属性中确认一下实际端口号是多少?
21.    user.name = ***,
22.    passwd = "***",
23.    ssl = TRUE             #确认一下你的邮件服务器属性设置中,是否勾选了SSL,否则建议SSL属性设置为FALSE.
24.  ),
25.  authenticate = TRUE,
26.  send = TRUE
27.)

上述建议供参考。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|R语言中文网    

GMT+8, 2024-5-20 11:37 , Processed in 0.040987 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表