rstudio / blastula

Easily send great-looking HTML email messages from R
https://pkgs.rstudio.com/blastula
Other
547 stars 85 forks source link

Problem to send email - Weird server reply #272

Closed henrique1008 closed 3 years ago

henrique1008 commented 3 years ago

Good Morning

Today some emails I have scheduled on Apache Airflow failed, and I'm analyzing the causes but I don't understand.

I use outlook as a provider

sending by smtp_send

I'm getting a weird error message, which is below.

Error in curl_fetch_memory(smtp_server, handle = h) : Weird server reply

The problem is with a Linux server on Azure with Ubuntu 18.04 as O.S.

My local Windows computer is working properly. I also tested it on a local Ubuntu 20.04 and the upload worked.

Would they have an indication of where to look for this error message?

mchambleegh commented 3 years ago

I am getting same error (started this morning) on one of my Azure VMs but it does not occur on a different Azure VM when testing with same script (smtp_send). The VMs are pretty similiar and cannot figure it out.

I opened a technical support request with Azure yesterday (9/16) to see if they can help.

henrique1008 commented 3 years ago

Hi machambleegh

If you receive any response from Microsoft on the topic, could you share here please ?

This week I'm going to do some tests with other shipping packages, and some more tests with blastula to see if I can work around here, in case I find something relevant, I'll share it here too

mchambleegh commented 3 years ago

Hi Henrique, Here was my latest response from Microsoft:

I was reviewing the case with my team, and we suggest the following:

So I ran the Telnet test they suggested and it was successful in verifying server access; so that did not help identify the problem. I have not engaged the Office 365 support yet.

I also can run successfully on my local with windows but it does not run on my azure VMs or a remote server (all running Ubuntu 18.04). When the problem first occurred, it was still working on a different VM I use for work with R Studio but by the next day, that VM also started experiencing the same error (Weird server reply). This is beyond frustrating and feeling pretty helpless.

I will let you know if I make any progress. Thanks for reaching out.

henrique1008 commented 3 years ago

Hi machambleegh

I decided to do some tests with Python on the same server, sending email via smtp too

And the code was successful, which indicates that the problem is really related to R

To be sure if the problem was really related to R, I tried to send an email using the emayili package, and I was unsuccessful, having the same problem as blastula

The Python code I used to send the email was

import smtplib

mailserver = smtplib.SMTP('smtp.office365.com',587)
mailserver.ehlo()
mailserver.starttls()
mailserver.login('myemail@provider.com', 'my_secret')
#Adding a newline before the body text fixes the missing message body
mailserver.sendmail('myemail@provider.com','mydestination@provider.com','\npython email')
mailserver.quit()

So there is no doubt that the problem is with R regarding the sending, because on the same server that R has sending problems, Python is successful, removing the doubt that the problem was with Azure servers

Now I believe that the way is to reproduce the procedure that python performs in R, and make it blastulate, as well as other email packages in R, to be successful in Azure

I have a suspicion that the problem is with STARTTLS, but I can't find out for sure

henrique1008 commented 3 years ago

Today (09/21/2021) there were some updates to the libcurl packages for linux on Azure, and after these updates to the operating system, everything went back to working normally.

bests

mchambleegh commented 3 years ago

Hi Henrique, thanks for the information. I was wanting to know if you just needed to restart the VM and then install latest version of the R package ‘curl’, or is there additional install apt required? Thanks

henrique1008 commented 3 years ago

What solved was today when running the command

sudo apt update && and sudo apt upgrade

This made the libcurl of linux itself to be updated, with some modifications that microsoft made in Ubuntu from Azure

The R package I didn't change, but I already had the latest version installed.

After the libcurl linux library was updated on my Ubuntu, everything started working again.

mchambleegh commented 3 years ago

That worked for me. Thanks Henrique, appreciate all your help.

henrique1008 commented 3 years ago

You're welcome. I'm glad it worked for you. Bests