Error when trying to send email using gmail from buildbot docker image - buildbot

I am trying to the buildbot/buildbot-master:latest docker image for my CI environment als it works like a charm except when trying to send emails.
I use the following email configuration:
from emailLookup import EmailLookup
mn = reporters.MailNotifier(
fromaddr='x#x.c',
sendToInterestedUsers=True,
extraRecipients=[],
relayhost='smtp.gmail.com',
smtpPort=587,
useTls=True,
smtpUser=private.auth_username,
smtpPassword=private.auth_password,
lookup=EmailLookup(),
generators=[generator],
)
c['services'].append(mn)
and get the following error message:
2022-03-11 14:04:03+0000 [ESMTPSender,client] Got exception when handling reporter events
Traceback (most recent call last):
  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1750, in gotResult
    current_context.run(_inlineCallbacks, r, gen, status)
  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1656, in _inlineCallbacks
    result = current_context.run(
  File "/buildbot_venv/lib/python3.9/site-packages/twisted/python/failure.py", line 489, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/reporters/base.py", line 95, in _got_event
    log.err(e, 'Got exception when handling reporter events')
--- <exception caught here> ---
  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/reporters/base.py", line 93, in _got_event
    yield self.sendMessage(reports)
twisted.mail._except.TLSRequiredError: 502 Server does not support secure communication via TLS / SSL
<<< 250-smtp.gmail.com at your service, [62.99.227.122]
<<< 250-SIZE 35882577
<<< 250-8BITMIME
<<< 250-STARTTLS
<<< 250-ENHANCEDSTATUSCODES
<<< 250-PIPELINING
<<< 250-CHUNKING
<<< 250 SMTPUTF8
Any help is appreciated.

Related

Jenkins ${BUILD_LOG, maxLines=50, escapeHtml=false} not woking

I am using the below code to override the BUILD_LOG functionality but i am not getting the complete console log.
Code :
emailext body: '''$PROJECT_NAME - Build # $BUILD_NUMBER - FAILURE:
Check console output at $BUILD_URL to view the results. ${BUILD_LOG, maxLines=50, escapeHtml=false}''', replyTo: 'noreply#bwpm.dumpmail', subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - FAILURE!', to: 'santhuhappy24#gmail.com'
Jenkins version i am using : Jenkins 2.79
Regards,
Santhohs
You are limiting the Build log to give only the last 50 lines. So instead of that please use a large number so that it will give you total log of the console.
${BUILD_LOG, maxLines=999999, escapeHtml=false}
I haven't seen getting full log using $BUILD_LOG it only give 250 lines which is default. I have tested using that number. Hope this helps for you too.

Sending Email in Sugarcrm takes long time

When I am trying to send an email with the attachment it gives the below error. We are using SugarCRM Community Edition 6.5 hosted on Local Server. Using Gmail.
Warning: mime_content_type() [function.mime-content-type]: File or
path not found
'cache/modules/Emails/1/6bbf0a1c-c58b-a96e-6759-576ecd00f639' in
C:\xampp\htdocs\SugarCrm\modules\Emails\Email.php on line 335
Warning: mime_content_type() [function.mime-content-type]: File or path not found
'cache/modules/Emails/1/6bbf0a1c-c58b-a96e-6759-576ecd00f639' in
C:\xampp\htdocs\SugarCrm\modules\Emails\Email.php on line 335
{"composeLayoutId":"composeLayout0"}
Lines at 335 are
function sendEmailTest($mailserver_url, $port, $ssltls, $smtp_auth_req, $smtp_username, $smtppassword, $fromaddress, $toaddress, $mail_sendtype = 'smtp', $fromname = '') {
global $current_user,$app_strings;
Thanks
These are only warnings.
Before sending email please try to verify the Email Settings and also send test email from Email Settings page.

IBM Bluemix API key error with Python

I am trying to use Python to program watson_developer_cloud and I am getting an API key error. My code is really simple:
import json
from watson_developer_cloud import VisualRecognitionV3 as VisualRecognition
visual_recognition = VisualRecognition('2016-05-20', api_key='<myAPIkey>')
test_url = 'https://www.ibm.com/ibm/ginni/images/ginni_bio_780x981_v4_03162016.jpg'
print(json.dumps(visual_recognition.classify(images_url=test_url)))
But for some reason when I run it, I get a SSL error:
requests.exceptions.SSLError: hostname 'gateway-a.watsonplatform.net' doesn't match either of 'access.alchemyapi.com', 'www.access.alchemyapi.com'
I know the API key (omitted above) works because when I use CURL or NodeJS it works just fine.
I am really stumped. Could someone please help?
Figured it out. It turns out you require python>=2.7.8 because of server name identification (SNI). My version of python is 2.7.3, and it does not support that and therefore I am getting the error seen above.
So this is why CURL and other attempts to use the API key work, whereas my python was generating a SSLError. Happy upgrading!
Quick Hack:
Change the file - watson_developer_cloud_service.py:243 as below:
diff watson_developer_cloud_service.py watson_developer_cloud/watson_developer_cloud_service.py
243c243
< params=params, data=data, files=files, verify=False, **kwargs)
---
> params=params, data=data, files=files, **kwargs)
after that -
rm -f /usr/lib/python2.7/site-packages/watson_developer_cloud-0.14.0-py2.7.egg
followed by ..
python setup.py install

Display HTML page inside mail body with Email-ext plugin

I'm facing a little problem using Email-ext plugin on Jenkins.
I added the following line to inject my surefire html result to the email sent by the plugin :
${FILE,path="server/target/site/surefire-report.html"}
and I put contenant type as HTML (text/html)
I'm using Jenkins 1.651.1 and Email-ext plugin 2.42
I receive an e-mail in the end of my build with the following contenent
${FILE,path="server/target/site/surefire-report.html"}
It's like the plugin did not understand any thing.
Do you have an idea ?
any update on that ?
my project structure is like this :
workspace
master
commun
server/target/surefire-report/surefire-report.html
If you use a custom path this answer is for you
I had a complication trying to achieve this result because my path was dynamically changing and I had to use a variable inside a FILE variable. So when I tried any of the following
body: '${FILE,path=${report}}'
body: "${FILE,path=${report}}"
body: '''${FILE,path=${report}}'''
and many more, it didn't work. On the other hand I couldn't read the file with groovy because of Jenkins restrictions
My workaround was to read the html directly with groovy sh command like so
html_body = sh(script: "cat ${report}", returnStdout: true).trim()
and then just send the email
emailext replyTo: '$DEFAULT_REPLYTO',
subject: "subject",
to: EMAIL,
mimeType: 'text/html',
body: html_body
where ${report} was a path to html file like /var/jenkins/workspace_318/report.html
Please note that file path is relative to the workspace , if file resides in the root of your workspace , filename alone in the path will work , if it resides in a different location try somthing like this below :
${FILE,path="target/surefire-reports/emailable-report.html"}
I was also having the prob where the mail had the command with error coould not find file. Like mentioned above, the html file should be present exactly under the jenkins workspace folder. if not then give the relative path, even an extra "/" in front seems to throw error.
ex:
My file is in C:\CICDJenkins\ReadyAPIReport\summary.html
My jenkins workpace (im using custom workspace) is C:\CICDJenkins
what worked for me is:
${FILE, path="ReadyAPI_report/overview-summary.html"}

mutt: Error sending message, child exited 127 (Exec error.)

I have to send a mail with an attachment from a shell script.
I am trying to do it using mutt as shown here: How do I send a file as an email attachment using Linux command line?
Command:
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient#domain.com
Error:
Error sending message, child exited 127 (Exec error.). Could not send
the message.
I was having the same issue on Ubuntu 18.04 and just like #jono, I only had installed mutt. Installing
sudo apt-get install sendmail
After that, sending mail with the test method or straight through the mutt CLI worked perfectly.
I have encountered this same error today.
I found I only had mutt installed, but once I installed sendmail this error went away. However I then got blocked locally.
So I uninstalled sendmail, and installed postfix this worked..
Now receiving email with attached pdf.
This was on RHEL 7.4 in an enterprise environment. Unsure if results will differ on other versions or environments.
I had this error and had to simply add below to my .muttrc. I'm using Gmail if that matters. This way I'm using someone elses server to send and don't have to install extra junk.
set smtp_pass="secrets"
set smtp_url = "smtps://username#gmail.com#smtp.gmail.com:465/"
set the password generated from this link into this file:
# file: ~/.muttrc
set from="first_name.last_name#gmail.com"
set realname="first_name last_name"
set imap_user="first_name.last_name#gmail.com"
#
# v1.0.1
# check the following google help page:
# http://support.google.com/accounts/bin/answer.py?answer=185833
# that is set here your google application password
set imap_pass="SecretPass!"
#nopeset imap_authenticators="gssapi"
set imap_authenticators="gssapi:cram-md5:login"
set certificate_file="~/.mutt/certificates"
#
# These two lines appear to be needed on some Linux distros, like Arch Linux
#
##REMOTE GMAIL FOLDERS
set folder="imaps://imap.gmail.com:993"
set record="+[Gmail]/Sent Mail"
set spoolfile="imaps://imap.gmail.com:993/INBOX"
set postponed="+[Gmail]/Drafts"
set trash="+[Google Mail]/Trash"
#
###SMTP Settings to sent email
set smtp_url="smtp://first_name.last_name#smtp.gmail.com:587"
#
# v1.0.1
# check the following google help page:
# http://support.google.com/accounts/bin/answer.py?answer=185833
# that is set here your google application password
set smtp_pass="SecretPass!"
#
###LOCAL FOLDERS FOR CACHED HEADERS AND CERTIFICATES
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file =~/.mutt/certificates
#
###SECURING
set move=no #Stop asking to "move read messages to mbox"!
set imap_keepalive=900
#
###Sort by newest conversation first.
set sort=reverse-threads
set sort_aux=last-date-received
#
###Set editor to create new email
set editor='vim'
set ssl_starttls=yes
set ssl_force_tls=yes
Fix for GMail Account Configuration
The following post worked for me: https://www.codyhiar.com/blog/getting-mutt-setup-with-gmail-using-2-factor-auth-on-ubuntu-14-04/
But it was not very clear. The contents of ~/.muttrc that worked for me are as follows (My account has 2-Step verification enabled and I had to generate app password as described in the post):
set imap_user = "<username>#gmail.com"
set imap_pass = "<16-character-app-password>"
set sendmail="/usr/sbin/ssmtp"
set folder="imaps://imap.gmail.com:993"
set spoolfile="imaps://imap.gmail.com/INBOX"
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set from = "<username>#gmail.com"
set realname = "<name-used-in-the-gmail-account>"
set smtp_url = "smtp://<username>#smtp.gmail.com:587/"
set smtp_pass="<16-character-app-password>"
set move = no
set imap_keepalive = 900
# Gmail-style keyboard shortcuts
macro index,pager ga "<change-folder>=[Gmail]/All<tab><enter>" "Go to all mail"
macro index,pager gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index,pager gs "<change-folder>=[Gmail]/Starred<enter>" "Go to starred messages"
macro index,pager gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"
macro index,pager e "<enter-command>unset trash\n <delete-message>" "Gmail archive message" # different from Gmail, but wanted to keep "y" to show folders.
Replace the following:
<username>: Your gmail username
<16-character-app-password>: You have to generate this
<name-used-in-the-gmail-account>: Your name as per gmail account
Note: Don't change <change-folder>