2

I am attempting to use the SendMailR function, I have checked with our I.T. department that I am using the correct server and I have the right permissions to connect and they have sent emails via this server but not through R and I have also checked that the port should be 25.

The code:

# E-Mail #

library(sendmailR)

from <- "david@work.com"
to <- "adam@work.com"
subject <- "Send Mail R- Test"
body <- "TESTING TESTING TESTING"                     
mailControl=list(smtpServer="uksmtp.global.local")

sendmail(from=from,to=to,subject=subject,msg=body,control=mailControl)

I receive the below error:

function (host = "localhost", port, server = FALSE, blocking = FALSE, 
open = "a+", encoding = getOption("encoding"), timeout = getOption("timeout")) 
.Internal(socketConnection(host, port, server, blocking, open, 
encoding, timeout))
<bytecode: 0x00000000071beb18>
<environment: namespace:base>

So I figured its an error with or I needed to define a new socket connection, is this where the problem lies? Could anyone give me any pointers on where to go next with this to get it working?

Thanks in advance

Methexis
  • 2,739
  • 5
  • 24
  • 34

2 Answers2

0

Although this is not an answer to your question you might want to alternatively check out the mail package which offers an alternative way to sent mail via an external mail server and address:

require(mail)
sendmail("adam@work.com", "Send Mail R- Test", "TESTING TESTING TESTING")

Note that you can only sent 20 mails that way per day (to avoid spam).

Henrik
  • 14,202
  • 10
  • 68
  • 91
  • 1
    Thanks Henrik, although the limiting factor of 20 and the message going through what looks like the R e-mail servers means I would be unable to use it. Good to know though and many thanks! – Methexis Jun 03 '13 at 14:01
  • 1
    I think it is a private mail server of the maintainer of the package. You could have a look at how he does it, if you do not get `sendmailR` to work. My problem with it was that it doesn't support `https` or login. – Henrik Jun 03 '13 at 14:31
  • Eventually solved this it was a permissions error with the server here at work! Thanks Again – Methexis Jul 04 '13 at 14:23
0

You could give the new mailR package a shot that allows SMTP authorization: http://cran.r-project.org/web/packages/mailR

The following call should then work:

send.mail(from = "sender@gmail.com",
          to = "recipient@gmail.com",
          subject = "Subject of the email",
          body = "Body of the email",
          smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "recipient", passwd = "PASSWORD", ssl = TRUE, tls = TRUE),
          authenticate = TRUE,
          send = TRUE)

Just replace the key-value pairs in the parameter smtp and you should be set to go.

Rahul Premraj
  • 1,595
  • 14
  • 13