diff --git a/.gitignore b/.gitignore index 7716124..da43781 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/pagure/default_config.py b/pagure/default_config.py index 4ea4a16..675f5e2 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -22,8 +22,8 @@ SECRET_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 = '' diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index f201dd5..0ca8443 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -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],