astrobase.emailutils module¶
This is a small utility module to send email using an SMTP server that requires logins. The email settings are stored in a file called .emailsettings that should be located in the ~/.astrobase/ directory in your home directory. This file should have permissions 0600 (so only you can read/write to it), and should contain the following info in a single row, separated by the | character:
<email user>|<email password>|<email server>
Example:
exampleuser@email.com|correcthorsebatterystaple|mail.example.com
NOTE: This assumes the email server uses STARTTLS encryption and listens on SMTP port 587. Most email servers support this.
-
astrobase.emailutils.
send_email
(sender, subject, content, email_recipient_list, email_address_list, email_user=None, email_pass=None, email_server=None)[source]¶ This sends an email to addresses, informing them about events.
The email account settings are retrieved from the settings file as described above.
Parameters: - sender (str) – The name of the sender to use in the email header.
- subject (str) – Subject of the email.
- content (str) – Content of the email.
- list (email_recipient) – This is a list of email recipient names of the form: [‘Example Person 1’, ‘Example Person 1’, …]
- list – This is a list of email recipient addresses of the form: [‘example1@example.com’, ‘example2@example.org’, …]
- email_user (str) – The username of the email server account that will send the emails. If this is None, the value of EMAIL_USER from the ~/.astrobase/.emailsettings file will be used. If that is None as well, this function won’t work.
- email_pass (str) – The password of the email server account that will send the emails. If this is None, the value of EMAIL_PASS from the ~/.astrobase/.emailsettings file will be used. If that is None as well, this function won’t work.
- email_server (str) – The address of the email server that will send the emails. If this is None, the value of EMAIL_USER from the ~/.astrobase/.emailsettings file will be used. If that is None as well, this function won’t work.
Returns: True if email sending succeeded. False if email sending failed.
Return type: bool