[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]:
>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)
>However it gives me following 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
telnet: Unable to connect to remote host: Connection timed out

Try port 443:

telnet blu-m.hotmail.com 443
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.

Proofread carefully to see if you any words out.

More information about the R-help mailing list