I am trying to send an email on failure to my own GMAIL account.
I followed up some other recommendations for configuring SMTP server
[smtp]
smtp_host = smtp.gmail.com
smtp_starttls = True
smtp_ssl = False
smtp_user = something#gmail
smtp_port = 587
smtp_password = 16_chars_long_app_password
smtp_mail_from = something#gmail
I changed my logs to DEBUG but I am not able to find where the problem is.
I have my dag args with
'email': ['something#gmail.com'],
'email_on_failure': True,
I force the tasks to be failed or the DAG to have status failed, so I don't know if it might be because I am forcing it to fail.
The solution was to add subject and content template files to airflow.cfg (https://airflow.apache.org/concepts.html#email-configuration):
[email]
email_backend = airflow.utils.email.send_email_smtp
subject_template = /path/to/my_subject_template_file
html_content_template = /path/to/my_html_content_template_file
Related
I am running into an issue with blastula email and SMTP Gmail.
When I run the following code on my local RStudio, it runs perfectly well and the email is sent.
library(blastula)
# To store my credentials with pwd in a file
create_smtp_creds_file(
file = "gmail_creds",
user = "myemail#gmail.com",
host = "smtp.gmail.com",
port = 465,
use_ssl = TRUE
)
email <- blastula::render_email("RMarkdown_Template.Rmd")
email %>%
smtp_send(
to = c("myother#email.com"),
from = c("Your Newsletter" = "myemail#gmail.com"),
subject = "Daily Newsletter",
credentials = creds_file("gmail_creds")
)
But when I run this exact same code on my RStudio on an ec2 instance, I get the following error message and the email is not sent:
Error in curl_fetch_memory(smtp_server, handle = h) : Login denied
FYI I activated the 'Less secure app' on the Gmail side.
Any idea where this problem come from?
I'm trying to send emails using R, which will eventually be deployed in a Shiny application. I've got an Office 365 account which is able to send email if I log into it but using the SMTP server I'm not getting any connection so far.
I've tried packages mailR & emayili but I'm not getting anywhere for some reason. I've used our local mail server before and that worked but that won't work for a shiny deployment.
According to Outlook I'm supposed to use:
Server name: smtp.office365.com
Port: 587
Encryption method: STARTTLS
But I can't seem to find a package that can do STARTTLS encryption. For other mail providers I see the advice to turn on "less secure apps" but that's not an option for us.
Example code :
library(mailR)
send.mail(from = "Me#companydomain.com",
to = c("you#companydomain.com"),
subject = "Test",
body = "TEST",
smtp = list(host.name = "smtp.office365.com",
port = 587,
user.name = "Me#companydomain.com",
passwd = "SuperSecretPassword",
tls = TRUE),
authenticate = TRUE,
send = TRUE,
debug = TRUE)
# Another option, with emayili:
library(emayili)
smtp <- server(host = "smtp.office365.com",
port = 587,
username = "Me#companydomain.com",
password = "SuperSecretPassword")
email <- envelope(from = "Me#companydomain.com",
to = "you#companydomain.com",
subject = "This is a plain text message!",
text = "Hello!")
smtp(email, verbose = TRUE)
I really hope someone figured out a package that can use STARTTLS or how to encrypt in that way using one of these packages!
Best Regards,
Bob
I'm trying to send emails through R's blastula package. My email program is Outlook/Office. This code
library(blastula)
smtp_send(
compose_email(body = "hello"),
to = "hello#hello.com",
from = "hello#hello.com",
credentials = creds(
user = "hello",
host = "smtp.office365.com",
port = 587,
use_ssl = F
))
gives
Error in curl_fetch_memory(smtp_server, handle = h) : MAIL failed: 451
I've done a bit of reading and it clearly has something to do with permissions being blocked, which I assume I can't change because I don't have admin privileges on my machine.
Is there anything I can do?
Thanks!
I am trying to connect (dotnet client) to RabbitMQ. I enabled the Peer verification option from the RabbitMQ config file.
_factory = new ConnectionFactory
{
HostName = Endpoint,
UserName = Username,
Password = Password,
Port = 5671,
VirtualHost = "/",
AutomaticRecoveryEnabled = true
};
sslOption = new SslOption
{
Version = SslProtocols.Tls12,
Enabled = true,
AcceptablePolicyErrors = System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors
| System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch,
ServerName = "", // ?
Certs = X509CertCollection
}
Below are my client certification details which I am passing through "X509CertCollection".
CertSubject: CN=myhostname, O=MyOrganizationName, C=US // myhostname is the name of my client host.
So, if I pass "myhostname" value into sslOption.ServerName, it works. If I pass some garbage value, it still works.
As per documentation of RabbitMQ, these two value should be match i.e. certCN value and serverName. What will be the value of sslOption.ServerName here and why?
My Bad. I found the reason. Posting as it might help someone.
Reason: As I set a policy "System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch".
I'm trying to send emails from R using sendmailR package using the following code, which unfortunately fails :
## Set mail contents
from <- sprintf('<sendmailR#%s>', Sys.info()[4])
to <- '<slackline#gmail.com>'
subject <- 'Feeding Plots'
body <- list('Latest feeding graph', mime_part(feeding.plot,
name = "feeding"))
## Set control parameters
control <- sendmail_options(verboseShow = TRUE,
smtpServer ="smtp.gmail.com",
smtpPort = 587,
smtpSTARTTLS = '',
blocking = FALSE)
sendmail(from,
to,
subject,
msg = body,
control = control,
headers)
<< 220 mx.google.com ESMTP xt1sm884721wjb.17 - gsmtp
>> HELO kimura
<< 250 mx.google.com at your service
>> MAIL FROM: <sendmailR#kimura>
<< 530 5.7.0 Must issue a STARTTLS command first. xt1sm884721wjb.17 - gsmtp
Error in wait_for(code) :
SMTP Error: 5.7.0 Must issue a STARTTLS command first. xt1sm884721wjb.17 - gsmtp
The sendmailR manual doesn't mention how to configures STARTTLS although it does indicate that additional arguments can be passed, which is why I have included the option smtpSTARTLS = '' based on whats mentioned in some other threads (here and here). I've tried playing with the argument for smtpSTARTTLS and setting it to TRUE but no joy.
Any pointers to documentation or solutions would be most welcome.
Thanks
As far as I understand it, sendmailR doesn't support any type of login to the SMTP server, hence, gmail is basically unusable. You can only use the package if you are within the right network and set up a server that is only reachable within the network I guess (i.e., one NOT using authentication).
The alternative is the mail package (in which you cannot use your own address).
The reference from the sendmailR documentation is:
SMTP AUTH is currently unsupported.
You could give the new mailR package a shot that allows SMTP authorization: http://cran.r-project.org/web/packages/mailR/index.html
The following call should then work:
send.mail(from = "slackline#gmail.com",
to = "slackline#gmail.com",
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "slackline", passwd = "PASSWORD", ssl = TRUE),
authenticate = TRUE,
send = TRUE)