Email on failure is not sent sendgrid/cloud composer - sendgrid

I've been using sendgrid to alert people on task failure in cloud composer. But email not been arriving to my email list even after failure also. Please find below default argument list
default_dag_args = {
"start_date": "2019-02-25",
# Email whenever an Operator in the DAG fails.
"email":[email_list]
'email_on_failure': True,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
'project_id': PROJECT_ID
}
And i've add environment variable also SENDGRID_MAIL_FROM and SENDGRID_API_KEY. But still on failure i'm not receiving any alert mail.

If you have not yet, I'd strongly recommend double-checking the instructions for setting up SendGrid with Cloud Composer. Make sure of a few things:
You set up the environment variable through the mechanism (editing the environment) as the guide says
Try sending a test DAG, as the guide says
If that continues to fail, I'd then start suspecting a firewall rule (if you have edited them) may be causing the issue. Be careful if you are adjusting firewall rules.

I was experiencing the same problem, the DAG's task log was just displaying this error:
python_http_client.exceptions.ForbiddenError: HTTP Error 403: Forbidden
I fixed it by setting SENDGRID_MAIL_FROM to an email address (mine) that was verified in SendGrid. Before I was using a non verified address, such as noreply#mycompany.com.
Follow these docs to add a sender and - if needed - verify it via the verification link in the email you'll receive.

Related

Jenkins email plugin doesn't send email to user who broke the build

I've setup Jenkins to send emails only to users who broke the build using email-ext plugin, but I'm getting this error:
Not sending mail to unregistered user user#example.com because your SCM claimed this was associated with a user ID ‘John Smith' which your security realm does not recognize; you may need changes in your SCM plugin
I don't really understand what this error means, is the problem in our SCM, or in the email plugin? The emails are taken from the commit history, should I register them somewhere so Jenkins will start working?
For reference, this is the code around the error message in the plugin's source code:
} catch (UsernameNotFoundException x) {
if (SEND_TO_UNKNOWN_USERS) {
listener.getLogger().printf("Warning: %s is not a recognized user, but sending mail anyway%n", userAddress);
} else {
listener.getLogger().printf("Not sending mail to unregistered user %s because your SCM"
........
How do I enable SEND_TO_UNKNOWN_USERS?
The error message is also mentioned in this bug report.
For version V2.61 or above this can be configured via a radio button.
Go to
Manage Jenkins -> Configure System -> Extended E-mail Notification
and tick the radio button for Allow sending to unregistered users
Edit: If this does not work, see https://stackoverflow.com/a/45353810/492336 for another solution.
OK, after some experiments this is what I found out:
Jenkins takes the email part of the committer (not the author). For example for a commit message that looks like that:
Author: John Smith <author1#example1.com> 2017-07-27 17:15:39
Committer: John Doe <committer1#example2.com> 2017-07-27 17:15:39
Parent: 9c3ff18dda8ca6f7b7ac4ebab4c76d3c85891a33 (commit)
Branch: master
Jenkins will take "committer1", and create a brand new user under People with User ID "committer1" and email "". Unless that user has a password however, it will be considered unregistered so you need to go to Configure for that user and add a password field to it:
So this is one way to fix the error, but you have to do it for every user and in a big team it can be tedious.
Put the line bellow in your jenkins startup script
-Dhudson.tasks.MailSender.SEND_TO_UNKNOWN_USERS=true
The newest Jenkins security directive only allow sending mail to registered user. The line above bypass this configuration.
Given jenkins takes the first part of the email address and creates a user, I made my team have their jenkins user name be the first part of their email address. This removed any overhead of having to maintain two separate users.

Unrecognised attribute 'enableSsl' in .NET v4.0

We've been running a new system in test for a while now and creating emails to a folder so they don't accidentally go out to clients. Now we've turned on live emailing we are getting issues with sending.
I'm using ActionMailer.NET and the code to create and send the email is below. I won't include the View:
EmailResult x = new EmailController().EmailWorkOrderForApprovalToClient(model);
System.Net.Mail.Attachment file = new System.Net.Mail.Attachment(FilePath);
x.Mail.Attachments.Add(file);
x.Deliver();
Which gives the error
The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.57 SMTP; Client was not
authenticated to send anonymous mail during MAIL FROM
The web.config looks like this:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="ClientServices#topupconsultants.com">
<specifiedPickupDirectory pickupDirectoryLocation="" />
<network defaultCredentials="false" host="smtp.office365.com" password="secret" port="587" userName="ClientServices#myco.com" />
</smtp>
</mailSettings>
My assumption is that enableSsl="true" needs to be added to the network line, but when I do that and try to go to the SMTP Email section of the site in IIS, I get the error:
Unrecognized attribute 'enableSsl'
I'm not that hot on IIS, but I've checked that the Application Pool and its .NET CLR version is 4.0.30319. I've also checked that .NET v4.5 is installed on the server.
This is baffling me, and I'm hoping I don't have to totally change my code to a method that allows me to specify SSL at that point.
Answering my own question here, and basically the answer is: "Don't believe the error message". In all the configurations I tried, I believed the error message when it told me that is was unacceptable. However, I tried it anyway, and it uses the enableSsl attribute when it sends, and this allows the connection to Office 365 to succeed.
Slightly irritating IIS bug that I'll forget about in a week, but right now is very annoying.
This is issue on IIS no need to worry about this error message
SmtpClient object enableSsl value get mapped
this silly issue is wasted my much time :D

Sending Emails With GitLab not working correctly

I'm trying to troubleshoot why GitLab Omnibus is not sending automated emails using Postfix, which is already installed and configured correctly (it's being used by other applications installed on the server as well).
When I make a change to an issue, while tailing the Gitlab logs, this is what I'm noticing:
==> /var/log/gitlab/sidekiq/current <==
2015-04-03_20:06:30.79386 2015-04-03T20:06:30.793Z 8126 TID-aq3vk Sidekiq::Extensions::DelayedMailer JID-460531f571f6756908805d66 INFO: start
2015-04-03_20:06:31.53363 sendmail: recipients with -t option not supported
==> /var/log/gitlab/gitlab-rails/production.log <==
Sent mail to user#company.com (48.3ms)
==> /var/log/gitlab/sidekiq/current <==
2015-04-03_20:06:31.57039 2015-04-03T20:06:31.570Z 8126 TID-aq3vk Sidekiq::Extensions::DelayedMailer JID-460531f571f6756908805d66 INFO: done: 0.776 sec
I sanitized the email address, but it is sending to a correct address.
I'm guessing the issue is related to the " sendmail: recipients with -t option not supported"
However, I cannot find anybody else out there who has had this issue.
Thanks.
I fixed this issue by switching GitLab to SMTP by following the guide here: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md
It seems like SMTP is documented in greater detail.

How to send an email with Ansible

I'm trying to send an email using Ansible, but I can't understand how it works as I don't know how to provide user and password for such service (not specified in the documentation).
Both my machine and the email server are in the same network, but I need to be authenticated in order to send the email.
This is my yml file:
---
- name: Testing email
hosts: localhost
tasks:
- name: Send email
local_action: mail
host=mail.server.com
port=993
subject="Ansible test mail"
body="Testing email"
from=my#email
to="y#email
charset=utf8
And this is the related content of the hosts' file:
[localhost]
localhost ansible_connection=local
Any idea about how should I configure it? Thanks in advance.
Looking at the source code for the mail module ( https://github.com/ansible/ansible/blob/d1effecb2ef073e478c67a7ca39cf56708a66a48/library/notification/mail ) it doesn't look like it supports SMTP authentication.
It shouldn't be too hard to add support for it however. It would require adding the username and password parameters to the module, detecting if they've both been supplied, and if so, calling smtp.login() with those parameters.
In fact, it looks like there's two pull requests to do exactly that at the moment here
https://github.com/ansible/ansible/pull/7213
and here
https://github.com/ansible/ansible/pull/6667
So support will most likely be added in dev soon.

Amazon Simple Email Service - "From" email verification

I am signed up for AWS SES (with instance, S3 and my website running nicely). I also have rec'd approval for sending out email without receiver verification and "mass production" OK. The only thing I'm left with is having my 3 "from" email addresses verified. Started to download Perl, as was suggested to run email-verification scripts -- but got no where with the installation. Do have my credentials ready to use.
There is an AWS SES API to use for verification which I can't find... suspect that it has something to do with AWS's sdk which I could figure out how to install.
So my question: is there a simple, straight forward way to get my email addresses to Amazon for verification via a response email they send? Their documentation is somewhat confusing.
You have to go validate your email address through their web service (like the perl script is doing). You can also use their SDK's that they publish, which are wrappers around their web service. For example, if you have Visual Studio, you can use the AWS SDK for .NET (also available as a Nuget package: PM> Install-Package AWSSDKForNET) and set up a simple console application to do something like this:
using Amazon.SimpleEmail;
using Amazon.SimpleEmail.Model;
static class Program {
static void Main() {
var client = new AmazonSimpleEmailServiceClient("yourAccessKey", "yourSecretKey");
var request = new VerifyEmailAddressRequest { EmailAddress = "yourEmailAddress" };
client.VerifyEmailAddress(request);
}
}
They also have SDK's available in PHP and Java that work pretty much the same.
This is an old post but came up in a search.
You can now verify emails directly from the SES control panel (See screen shot)
AWS SES Panel