Sending Emails With GitLab not working correctly - email

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.

Related

Email on failure is not sent sendgrid/cloud composer

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.

Gerrit not sending emails

I have set up a Gerrit server and trying to make it send emails (for all events). But for some reason Gerrit doesn't send any emails. error_logs shows absolutely no data, that means it is not even trying to send emails.
Here is relevant part of my project.config for All-Projects:
[notify "demo"]
email = me#company.com
type = all
Here is my gerrit.config:
[gerrit]
basePath = git
canonicalWebUrl = http://hostname:8443/
[database]
type = h2
database = db/ReviewDB
connectionPool = true
poolLimit = 128
[index]
type = LUCENE
[auth]
type = LDAP
[ldap]
poolDebug = all
server = ldap://nod.company.com
accountBase = cn=users,dc=company,dc=com
accountEmailAddress = mail
referral = follow
[sendemail]
smtpServer = relay.company.com
smtpServerPort = 25
smtpUser = my_username
[container]
user = gerrit2
javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
heapLimit = 2g
[sshd]
listenAddress = *:29419
maxConnectionPerUser = 256
[automerge]
botEmail = me#company.com
[download]
scheme = ssh
[httpd]
listenUrl = http://*:8443/
maxThreads = 128
[cache]
directory = cache
[gitweb]
cgi = /usr/share/gitweb/gitweb.cgi
Environment: Ubuntu 14.04 and Gerrit 2.11.6.
I have tried to send emails from command line on this server and that works just fine.
All of my individual projects on Gerrit inherit access rights from All-Projects. I even tried adding the email section to each individual project but that didn't help either.
My colleague, who has his own Gerrit server that is able to send emails, looked into my issue and couldn't figure out what's wrong with my server. We both have same Linux version, Gerrit version, gerrit.config and project.config.
Ok, found the issues and fixed them. I had two issues, sharing for user reference.
I installed sendmail utility when logged in as a user other than smtpUser account mentioned in gerrit.config. After that I forgot to add the sendmail utility to /opt and hence the smtpUser's account from gerrit.config was not able to access the sendmail utility. Once I shared the sendmail utility with all user accounts, gerrit started sending emails.
To summarize, make sure the user account mentioned under smtpUser has sendmail available to it. Thanks everyone for your time.
gerrit wont send the email ONLY to the user that is also the smtpUser in gerrit.config. I was testing it by sending emails to only me, and hence it didnt work. I had to change to project config to add an email address other than my own email account.
I dont know if this is a gerrit bug or a gerrit feature. If a feature then not sure what is the use case for this !!
I hope this info helps other guys out there.
I had this problem after a recent Gerrit update (from 2.15 -> 3.2).
I checked the postfix logs in /var/log/maillog and they clearly showed that after the machine was rebooted following the Gerrit update no more mails arrived here.
Looking further into <gerrit-path>/logs/error_log (I had to look in rollated files) showed me that there seemed to be a problem with our mail template and also gave me the path to the offending file.
We previously used a custom mail template from https://gist.github.com/orgads/d8a61a1c10efeb7a4fafbcb6374167c3, the format of which seems to no longer be valid. I replaced this with the .soy.example file provided by Gerrit which fixed the issue.
For me, since I was trying to test emails by getting them to send to my own email, I had to go to settings (Gerrit 2.15.17 BTW), then preferences, under email notifications, select "every comment" in the dropdown menu.

Recover email sended through exim?

lost some important data from my server and I know that data was sended via email. I have root access and I need to recover those emails.
I looked into exim logs and I have the email ID, but when I use a command like:
root#server [/var/spool/exim/msglog]# exim -Mvh 1ZfRwk-003bDf-JB
Failed to open input file for 1ZfRwk-003bDf-JB-H: No such file or directory.
Logs looks like:
2015-09-25 08:17:50 1ZfRwk-003bDf-JB <= info#myserver.com U=username P=local S=7453 id=20150925121750.117390002 ...... etc
I am running WHM under centOS
Is possible recover sended mails?
Any help would be appreciated.
No, You can not recover any mail which was send from your server. You can check your 1ZfRwk-003bDf-JB mail logs with the following command so that you can find out full logs of that mail.
grep 1ZfRwk-003bDf-JB /var/log/exim_mainlog

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.

Hudson email extension fails with "No authentication mechansims supported by both server and client"

After upgrading Hudson from 2 to 3 and running it in Tomcat its email extension no longer sends emails and fails with the error (even with a typo in the word "mechansims":))
ERROR: No authentication mechansims supported by both server and client
javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:756)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
at javax.mail.Service.connect(Service.java:317)
at hudson.tasks.Mailer$DescriptorImpl.send(Mailer.java:505)
at hudson.tasks.Mailer$DescriptorImpl.send(Mailer.java:476)
at hudson.tasks.MailSender.execute(MailSender.java:91)
at hudson.tasks.Mailer.perform(Mailer.java:112)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:34)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:646)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:624)
at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:600)
at hudson.model.Build$RunnerImpl.post2(Build.java:163)
at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:566)
at hudson.model.Run.run(Run.java:1414)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:40)
at hudson.model.ResourceController.execute(ResourceController.java:81)
at hudson.model.Executor.run(Executor.java:137)
Is it a bug of the plugin, or maybe someone knows where the problem might be? I tried adding SMTP Authentication credentials in the main Hudson configuration page removing it - it didn't help.
I believe this could be a bug in Hudson 3 core. It might be related to http://www.eclipse.org/forums/index.php/t/356988/. Could you downgrade the javax.mail jar in the hudson.war from 1.4.4 to 1.4 to see if that resolves the issue?
Thanks,
Steve.
See if it doesn't have to do with TLS encryption, modify the java arguments that start Hudson to include: -Dmail.smtp.starttls.enable=true