Skip to content

Commit e4d8656

Browse files
committed
fix for unauthenticated mailing (fix #38)
1 parent 982fedb commit e4d8656

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ansibleguy-webui/aw/execute/alert_plugin/plugin_email.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717

1818

1919
def _email_send(server: SMTP, user: USERS, stats: dict, execution: JobExecution, error_msgs: dict):
20-
server.login(user=config['mail_user'], password=config['mail_pass'])
20+
if is_set(config['mail_pass']):
21+
server.login(user=config['mail_user'], password=config['mail_pass'])
22+
2123
msg = MIMEMultipart('alternative')
2224
msg['Subject'] = f"Ansible WebUI - Job '{execution.job.name}' - {execution.status_name}"
23-
msg['From'] = config['mail_sender']
25+
msg['From'] = config['mail_sender'] if is_set(config['mail_sender']) else config['mail_user']
2426
msg['To'] = user.email
2527

2628
tmpl_html, tmpl_text = 'email/alert.html', 'email/alert.txt'
27-
if is_set(config['path_template']):
29+
if is_set(config['path_template']): # custom templates
2830
_tmpl_base = Path(config['path_template'])
2931
_tmpl_html = _tmpl_base / 'alert.html'
3032
_tmpl_text = _tmpl_base / 'alert.txt'

0 commit comments

Comments
 (0)