Commit 8c310f62 authored by vanzhiganov's avatar vanzhiganov

Custom SMTP settings

parent 3fb15aeb
......@@ -22,6 +22,8 @@ _build/
# Just a local folder I use for testing
clones/
# IdeaIDE
.idea/
# Ignore the git repos in unit tests
tests/*.git
......
......@@ -22,8 +22,8 @@ SECRET_KEY = '<insert here your own key>'
DB_URL = 'sqlite:////var/tmp/pagure_dev.sqlite'
# url to datagrepper (optional):
#DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper'
#DATAGREPPER_CATEGORY = 'pagure'
# DATAGREPPER_URL = 'https://apps.fedoraproject.org/datagrepper'
# DATAGREPPER_CATEGORY = 'pagure'
# The FAS group in which the admin of pagure are
ADMIN_GROUP = 'sysadmin-main'
......@@ -150,9 +150,15 @@ GL_BINDIR = None
# Default SMTP server to use for sending emails
SMTP_SERVER = 'localhost'
SMTP_PORT = 25
SMTP_SSL = False
# Specify SMTP_USERNAME and SMTP_PASSWORD for enabling SMTP auth
SMTP_USERNAME = None
SMTP_PASSWORD = None
# Email used to sent emails
FROM_EMAIL = 'pagure@pagure.org'
DOMAIN_EMAIL_NOTIFICATIONS = 'pagure.org'
SALT_EMAIL = '<secret key to be changed>'
......
......@@ -184,12 +184,15 @@ def send_email(text, subject, to_mail,
else:
subject_tag = 'Pagure'
smtp = smtplib.SMTP(pagure.APP.config['SMTP_SERVER'])
if pagure.APP.config['SMTP_SSL']:
smtp = smtplib.SMTP_SSL(pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT'])
else:
smtp = smtplib.SMTP(pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT'])
for mailto in to_mail.split(','):
msg = MIMEText(text.encode('utf-8'), 'plain', 'utf-8')
msg['Subject'] = '[%s] %s' % (subject_tag, subject)
from_email = pagure.APP.config.get(
'FROM_EMAIL', 'pagure@fedoraproject.org')
from_email = pagure.APP.config.get('FROM_EMAIL', 'pagure@fedoraproject.org')
msg['From'] = from_email
if mail_id:
......@@ -212,6 +215,9 @@ def send_email(text, subject, to_mail,
mhash.hexdigest(),
pagure.APP.config['DOMAIN_EMAIL_NOTIFICATIONS'])
try:
if pagure.APP.config['SMTP_USERNAME'] and pagure.APP.config['SMTP_PASSWORD']:
smtp.login(pagure.APP.config['SMTP_USERNAME'], pagure.APP.config['SMTP_PASSWORD'])
smtp.sendmail(
from_email,
[mailto],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment