[R] Sending Email with Attachment

rex rex at nosyntax.net
Mon Jun 10 05:27:17 CEST 2013


Bhupendrasinh Thakre <vickythakre at gmail.com> [2013-06-09 20:03]:
>
>library("sendmailR")
>
>from <- "abcd at outlook.com"
>to <-  <mailto:efgh at gmail.com> efgh at gmail.com
>subject <- "Run at"
>mailControl = list(smtpServer="blu-m.hotmail.com")
>attachment <- "type_1.pdf"
>attachmentName <- "target_score.pdf"
>attachmentObject <- mime_part(x= attachment,name= attachmentName)
>body <- "Email Body"
>bodywithAttachement <- list(body, attachmentObject)
>sendmail(from=from,to=to,subject=subject,msg=
>bodywithAttachement,control=mailControl)
>
>However it gives me following Error:
>
>Error:
>
>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) :
>  blu-m.hotmail.com:25 cannot be opened

It's an unsurprising result since telnet doesn't connect either:
  
telnet blu-m.hotmail.com 25
Trying 65.55.121.94...
telnet: Unable to connect to remote host: Connection timed out

Try port 443:

telnet blu-m.hotmail.com 443
Trying 65.55.121.94...
Connected to eas-blu.hot.glbdns.microsoft.com.
Escape character is '^]'.

But it's probably expecting TLS, and sendmailR doesn't support it.

>Please let me know if we have some solution for this.

If you want to use sendmailR, you need to find a mail server that
does not require TLS. This may mean running your own mail server. 

Or, you can call an external program that handles a TLS connection.

-rex
-- 
Proofread carefully to see if you any words out.



More information about the R-help mailing list