Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of puffotter.
6puffotter is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11puffotter is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with puffotter. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20import smtplib
21from email.mime.text import MIMEText
22from email.mime.multipart import MIMEMultipart
25def send_email(
26 address: str,
27 title: str,
28 message: str,
29 smtp_server: str,
30 smtp_address: str,
31 smtp_password: str,
32 smtp_port: int = 587,
33):
34 """
35 Sends an HTML email message using SMTP
36 :param address: The address to send to
37 :param title: The email's title
38 :param message: The message to send
39 :param smtp_server: The SMTP server to use
40 :param smtp_address: The SMTP address to use
41 :param smtp_password: The SMTP password to use
42 :param smtp_port: The SMTP port to use
43 :return: None
44 """
45 connection = smtplib.SMTP(smtp_server, smtp_port)
46 connection.ehlo()
47 connection.starttls()
48 connection.ehlo()
49 connection.login(smtp_address, smtp_password)
51 msg = MIMEMultipart("alternative")
52 msg["subject"] = title
53 msg["From"] = smtp_address
54 msg["To"] = address
55 msg.attach(MIMEText(message, "html"))
57 connection.sendmail(smtp_address, address, msg.as_string())
58 connection.quit()