Problem sending mail from R using mailR package

Hi,
I am trying to schedule sending an attachment mail through mailR package using office365.
Below is code snippet..

send.mail(from = from,
            to = to,
            subject = subject,
            body = body,
            smtp = list(host.name = "https://outlook.office365.com/EWS/Exchange.asmx", port = 443,
                        user.name = "user@company.com", passwd = "password", tls = TRUE),
            authenticate = FALSE,
            attach.files = c("./file.csv"),
            file.names = c("file.csv"),
            file.descriptions = c("Description"))

I am getting below error.

org.apache.commons.mail.EmailException: Sending the email to the following server failed : https://outlook.office365.com/EWS/Exchange.asmx:443
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
	at org.apache.commons.mail.Email.send(Email.java:1437)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lNULL
ang.reflect.Method.invoke(Method.java:498)
	at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: https://outlook.office365.com/EWS/Exchange.asmx, 443; timeout 60000;
  nested exception is:
	java.net.UnknownHostException: https://outlook.office365.com/EWS/Exchange.asmx
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2053)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
	at javax.mail.Service.connect(Service.java:364)
	at javax.mail.Service.connect(Service.java:245)
	at javax.mail.Service.connect(Service.java:194)
	at javax.mail.Transport.send0(Transport.java:253)
	at javax.mail.Transport.send(Transport.java:124)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
	... 6 more
Caused by: java.net.UnknownHostException: https://outlook.office365.com/EWS/Exchange.asmx
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:310)
	at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2019)
	... 13 more
Error: EmailException (Java): Sending the email to the following server failed : https://outlook.office365.com/EWS/Exchange.asmx:443

The host name is provided as present in server tab in account section of outlook
Can someone suggest way forward please?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.