Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPS-14392 Replace Mailer Package and Upgrade Alpine #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
#########

2.7.0 (trajkovskaelena591)
---------------

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the - character length should match your full username.


* Replace deprecated mailer package
* Upgrade Alpine

2.6.1 (mgundel)
---------------

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.12
FROM alpine:3.18
LABEL Maintainer="Michael Stella <[email protected]>"

ARG PIP_EXTRA_INDEX_URL
Expand Down
23 changes: 16 additions & 7 deletions rssalertbot/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import re
import html2text
import pendulum
from mailer import Mailer, Message
import smtplib
import email
from email.message import EmailMessage
from email.mime.text import MIMEText

import rssalertbot
from .util import guess_level, strip_html
Expand Down Expand Up @@ -42,12 +45,18 @@ def alert_email(feed, cfg, entry):
description = strip_html(entry.description)

try:
smtp = Mailer(host=cfg['server'])
message = Message(charset="utf-8", From=cfg['from'], To=cfg['to'],
Subject = f"{feed.group['name']} Alert: ({feed.name}) {entry.title}")
message.Body = f"Feed: {feed.name}\nDate: {entry.datestring}\n\n{description}"
message.header('X-Mailer', 'rssalertbot')
smtp.send(message)
message = EmailMessage()
message["From"] = cfg['from']
message["To"] = cfg['to']
message["Subject"] = f"{feed.group['name']} Alert: ({feed.name}) {entry.title}"

plainpart = MIMEText(f"Feed: {feed.name}\nDate: {entry.datestring}\n\n{description}", "plain")
plainpart.add_header('X-Mailer', 'rssalertbot')

message.attach(plainpart, "utf-8")

smtp = smtplib.SMTP(cfg['server'])
smtp.send_message(message)

except Exception:
logger.exception("[%s] Error sending mail", feed.name)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
install_requires = [
'aiohttp',
'feedparser~=6.0.0',
'mailer',
'email',
'pendulum~=2.0',
'html2text',
'python-box~=4.2',
Expand Down