Copyright (C) 2012-2020 Rudolf Cardinal (firstname.lastname@example.org).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
Email functions/log class.
Class representing an e-mail sent from CamCOPS.
This is abstract, in that it doesn’t care about the purpose of the e-mail. It’s cross-referenced from classes that use it, such as
__init__(from_addr='', date=None, sender='', reply_to='', to='', cc='', bcc='', subject='', body='', content_type='text/plain', charset='utf8', attachment_filenames=None, attachments_binary=None, save_msg_string=False)¶
from_addr – name of the sender for the “From:” field
date – e-mail date in RFC 2822 format, or
sender – name of the sender for the “Sender:” field
reply_to – name of the sender for the “Reply-To:” field
to – e-mail address(es) of the recipients for “To:” field, as a CSV list
cc – e-mail address(es) of the recipients for “Cc:” field, as a CSV list
bcc – e-mail address(es) of the recipients for “Bcc:” field, as a CSV list
subject – e-mail subject
body – e-mail body
content_type – MIME type for body content, default
charset – character set for body; default
attachment_filenames – filenames of attachments to add
attachments_binary – binary attachments to add, as a list of
save_msg_string – save the encoded message string? (May take significant space in the database).
init_on_load() → None¶
Called when SQLAlchemy recreates an object; see https://docs.sqlalchemy.org/en/latest/orm/constructors.html.
send(host: str, username: str, password: str, port: int = None, use_tls: bool = True) → bool¶
Sends message and returns success.