Email service

Can be used for the sending transactional email. Example of using:

from src.shared.services.email import service as email_service

email_service.send_email(user.email, get_config_var('COMPANY_NAME') + ': Confirm your registration', text_body, html_body, get_config_var('COMPANY_NAME'), get_config_var('MAIL_DEFAULT_SENDER'))

To use your own email service:

  1. Install flask-mail
  2. Add the following env variables: SECRET_KEY, MAIL_SERVER, MAIL_PORT, MAIL_USE_SSL, MAIL_USE_TLS, MAIL_PASSWORD

For example, for websites hosted with Namecheap hosting provider and using privateemail service, use the following settings:

MAIL_SERVER = 'mail.privateemail.com'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAIL_USE_TLS = False
MAIL_USERNAME = 'your_email'
MAIL_PASSWORD = 'your_email_password'
ADMIN_EMAIL = 'your_admin_email'
MAIL_DEFAULT_SENDER = 'your_email'

If you use Mailgun, the following settings work:

MAIL_SERVER = 'smtp.mailgun.org'
MAIL_PORT = 587
MAIL_USE_SSL = False
MAIL_USE_TLS = False
MAIL_USERNAME = 'your_email'
MAIL_PASSWORD = 'your_email_password'
ADMIN_EMAIL = 'your_admin_email'
MAIL_DEFAULT_SENDER = 'your_email'