From e05e60eb8a141472d4742715b0acbd9cee6ba2d0 Mon Sep 17 00:00:00 2001 From: androiddrew Date: Thu, 25 Jan 2018 15:48:06 -0500 Subject: [PATCH] Added documentation on sending messages --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a920c9..3ada873 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ app = App( routes=routes, components=components ) - ``` ### Sending Messages @@ -51,9 +50,37 @@ from apistar_mail import Mail, Message def send_a_message(mail:Mail): msg = Message('Hello', sender='drew@example.com' - recipients=[you@example.com]) + recipients=['you@example.com']) mail.send(msg) return ``` +Your message recipients can be set in bulk or individually: + +``` +msg.recipients = ['you@example.com', 'me@example.com'] +msg.add_recipient('otherperson@example.com') +``` + +If you have set MAIL_DEFAULT_SENDER you don’t need to set the message sender explicitly, as it will use this configuration value by default: + +``` +msg = Message('Hello', + recipients=['you@example.com']) +``` +The sender can also be passed as a two element tuple containing a name and email address which will be split like so: + +``` +msg = Message('Hello', + sender=('Me', 'me@example.com')) + +assert msg.sender == 'Me ' +``` + +A Message can contain a body and/or HTML: + +``` +msg.body = 'message body' +msg.html = 'Hello apistar_mail!' +``` \ No newline at end of file