Post Commit Hook with Email Notification Error SVN - email

I am configuring my SVN server to send an email when some one commit code to the repository. After some googling I am using bellow codes for post-commit. I would like to use gmail SMTP as a mail server. But I am ending up with error..
"post-commit hook failed (exit code 255) with no output."
My Configuration Files:
post-commit
REPOS="$1"
REV="$2"
/SVNData/testrepo/hooks/mailer.py commit "$REPOS" \
"$REV" /SVNData/testrepo/hooks/mailer.conf
mailer.py Additional Config
def finish(self):
server = smtplib.SMTP(self.cfg.general.smtp_hostname)
if self.cfg.is_set('general.smtp_use_ssl') and self.cfg.general.smtp_use_ssl.lower() == "true":
server.ehlo()
server.starttls()
server.ehlo()
if self.cfg.is_set('general.smtp_username'):
server.login(self.cfg.general.smtp_username,
self.cfg.general.smtp_password)
server.sendmail(self.from_addr, self.to_addrs, self.buffer.getvalue())
server.quit()
mailer.conf
[general]
smtp_hostname = smtp.gmail.com:587
smtp_username = mysvnemail.test2015#gmail.com
smtp_password = MyPassword+12345
smtp_use_ssl = true
smtp_use_tls = 1
from_addr = svnadmin#myoffice.net
to_addr = myemail#myoffice.com
reply_to = info#myoffice.net
When I commit a file from SVN client I am not getting any email and I am getting the error as..
post-commit hook failed (exit code 255) with no output.

Related

SMTP email integration in cloud composer

I want to use SMTP email in GCP cloud composer. I have followed the GCP documentation and did the following -
Created a secret with my SMTP password (tested with secret name as airflow-variables-smtp-password & airflow-config-smtp-password)
Provided secret accessor role to my svc account
Modified email backend and all configs -
[email]
email_backend = airflow.utils.email.send_email_smtp
[smtp]
smtp_port = 587
smtp_user = ****
smtp_mail_from = ****
smtp_password_secret = smtp-password
smtp_host = smtp.office365.com
Changed secret backend -
[secrets]
backend = airflow.providers.google.cloud.secrets.secret_manager.CloudSecretManagerBackend
Below is my email dag which is subject to fail (tested with email operator as well) -
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
def print_hello():
pppp
return 'Hello Wolrd'
args = {
'owner': '***',
'depends_on_past': False,
'start_date': "2021-09-14",
'email_on_failure': True
}
with DAG(
dag_id='mail_testing',
default_args=args,
) as dag:
python_task = PythonOperator(
task_id='email_task',
python_callable=print_hello,
email_on_failure=True,
email= ['***'],
dag=dag
)
When running the dag, I am seeing it is looking for sendgrid to send the email.
[2021-09-29 17:42:20,958] {logging_mixin.py:104} WARNING - /opt/python3.8/lib/python3.8/site-packages/airflow/providers/sendgrid/utils/emailer.py:122 PendingDeprecationWarning: Fetching Sendgrid credentials from environment variables will be deprecated in a future release. Please set credentials using a connection instead.
[2021-09-29 17:42:21,081] {taskinstance.py:1503} ERROR - Task failed with exception
Traceback (most recent call last):
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1158, in _run_raw_task
self._prepare_and_execute_task_with_callbacks(context, task)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1333, in _prepare_and_execute_task_with_callbacks
result = self._execute_task(context, task_copy)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1363, in _execute_task
result = task_copy.execute(context=context)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/operators/email.py", line 79, in execute
send_email(
File "/opt/python3.8/lib/python3.8/site-packages/airflow/utils/email.py", line 55, in send_email
return backend(
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/sendgrid/utils/emailer.py", line 122, in send_email
_post_sendgrid_mail(mail.get(), conn_id)
File "/opt/python3.8/lib/python3.8/site-packages/airflow/providers/sendgrid/utils/emailer.py", line 141, in _post_sendgrid_mail
response = sendgrid_client.client.mail.send.post(request_body=mail_data)
File "/opt/python3.8/lib/python3.8/site-packages/python_http_client/client.py", line 277, in http_request
self._make_request(opener, request, timeout=timeout)
File "/opt/python3.8/lib/python3.8/site-packages/python_http_client/client.py", line 184, in _make_request
raise exc
python_http_client.exceptions.UnauthorizedError: HTTP Error 401: Unauthorized
[2021-09-29 17:42:21,084] {taskinstance.py:1546} INFO - Marking task as UP_FOR_RETRY.
What am I doing wrong? Is there anything I am missing!
PendingDeprecationWarning: Fetching Sendgrid credentials from environment variables will be deprecated in a future release. Please set credentials using a connection instead.
These docs describe configuring Sendgrid credentials in a connection. I would follow them, as they include steps for troubleshooting.
The other possibility is that it's an issue with your Sendgrid credentials. You can test your sendGrid credentials are valid by sending a test-email via a curl request.

How to HTTP POST in Lua without using Lua Socket

I am trying to send a HTTP POST command to an external server from a Lua scripted piece of hardware. In order to do so I have to create a tcpConnection and then do a tcpSend() command. I have confirmed the TCP Connection using wireshark and I have seen it send the HTTP GET command but I do not know how to send a post. I have tried to just change the GET to POST in the code but no avail.
debugConsole = -20
while true do
--Opening connection to remote host
debugConsole = tcpConnect("192.168.1.1", 80, 100)
print("TCP connect " .. debugConsole)
debugConsole = tcpSend("GET /api/v1/profiles/active_profiles.json?profile=5&expiry=1&duration=0&auth_token=2e608b72390a866f4bc7bbb6db63a1aa HTTP/1.1 \r\n\r\n")
print("TCP Send = " .. debugConsole)
--Printing response from remote host
print(responseSubstr(0, 500))
debugConsole = tcpClose()
print("TCP Close = " .. debugConsole)
debugConsole = httpRequest("http://192.168.1.1/api/v1/profiles/active_profiles.json?profile=5&expiry=1&duration=0&auth_token=2e608b72390a866f4bc7bbb6db63a1aa", 10)
print("HTTP Request = " .. debugConsole)
print(" ")
sleep (10000)
end

Serilog Email sink

I'm trying to send emails using Serilog.Sinks.Email NuGet package (v1.5.0.0) with the Mandrill SMTP service. The following code executes but does not send any emails. When I try and use the same credentials using the System.Net.Mail.SmtpClient, it works and send an email.
EmailConnectionInfo info = new EmailConnectionInfo()
{
EmailSubject = "Email subject",
FromEmail = "from#gmail.com",
MailServer = "smtp.mandrillapp.com",
NetworkCredentials = new NetworkCredential("mandrill_username", "mandrill_apikey"),
Port = 587,
ToEmail = "to#gmail.com"
};
Log.Logger = new LoggerConfiguration()
.WriteTo.Email(info)
.CreateLogger();
Log.Error("Houston we have a problem");
As you spotted, this was a bug in the latest build of the Email sink, which your graciously-provided pull request has fixed. Version 1.5.13 of the sink, now on NuGet, includes the fix.

SMTP settings work from localhost but on server it doesn't with PHPMailer

This is the issue what i am facing
Localhost
Test mail with SMTP settings work
New user creation mail using the above smtp settings work
Server
Test mail with SMTP settings work
New user creation mail using the above smtp settings doesn't work
I echoed the mail smtp settings in both the cases and they are exactly same. The error i am getting is
SMTP -> ERROR: Failed to connect to server: php_network_getaddresses:
getaddrinfo failed: Name or service not known (0)SMTP Connect()
failed.
Any suggestions would be helpful.
I further debug it. The behavior turns out to be wierd
if (isset($_POST['User']))
{
if (UserUtil::validateAndSaveUserData($model, $_POST))
{
$mailer = new UiMailer();
$mailer->setFrom('fromAddress', 'fromName');
$mailer->setTo('toaddress');
$mailer->setSubject('Test subject');
$mailer->setBody('Test Body');
$mailer->Mailer = 'smtp';
$mailer->Username = 'username';
$mailer->Password = 'password';
$mailer->Host = 'host';
$mailer->Port = 25;
$mailer->SMTPAuth = true;
$status = $mailer->send() ? true : false;
if($status == true)
{
print "Sucess";
}
else
{
print $mailer->ErrorInfo . "</br>";
print "Failuere";
}
exit;
}
}
If i comment the call if (UserUtil::validateAndSaveUserData($model, $_POST)), it works fine. In the function i am validating and saving models using Yii framework. I further debug the function. I have the following relation in the system
User has one person
User has one address
So in the above call, if i comment the address part which $model->address->attributes or $model->address->validate or $model->address->save(), it works fine. The save functionality for address works fine. There are no issues related to it.

How to pass SMTP username and password in Pylons config?

I'd like to configure a Pylons app, so that I get email on unhandled exceptions.
So far I can't find the way to pass username and password for SMTP connection.
production.ini file:
..
[DEFAULT]
email_to = my_email#gmail.com
smtp_server = smtp.webfaction.com
error_email_from = info#mydomain.com # this'd be a working email on webfaction
..
Please help.
If you want to access them in pylons.config then you want to put them in the [app:main] section of the configuration.
I've used turbomail, and then you can put them in [DEFAULT]. This is what my config looked like.
[DEFAULT]
mail.on = true
email_to = toaddress#domain.com
mail.manager = immediate
mail.transport = smtp
mail.provider = smtp
mail.smtp.server = smtp.domain.com
mail.smtp.username = username#domain.com
mail.smtp.password = passwordhere
error_email_from = paste#localhost