Package: concrete-mailer
READMECode QualityDescriptionconcrete-maileris a python package for sending rich e-mails.It automatically embeds the linked image in email inline attachments.It avoids emails to end up in SPAM (applying best practices, with no guarantee)It automatically converts rich e-mails in plain-text format for receivers who have not enabled HTML formatIt allows sending e-mails with attachementsIt inlines CSS (no header in HTML e-mails)⚠warningIt requires an SMTP server.Setup the environmentpipinstallconcrete-mailerUser Guideconcrete-mailercan be used in two ways:1- Email Client (client.py)fromconcrete_mailer.clientimportEmailSenderClientimportos#:  Define the smtp connexion variables in:#:  SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_HOST_USER, SMTP_HOST_PASSWORDclient=EmailSenderClient(email_host=os.getenv('SMTP_HOST_NAME'),#: smtp hostnameemail_port=os.getenv('SMTP_HOST_PORT'),#: smtp host portemail_host_user=os.getenv('SMTP_HOST_USER'),#: smtp host usernameemail_host_password=os.getenv('SMTP_HOST_PASSWORD'),#: smtp host passworduse_tls=os.getenv('SMTP_USE_TLS')=='1',#: smtp use tls)forname,emailin(('John','john@mail.ext'),('Jane','jane@mail.ext')):client.send(context={'name':name},template='''<h1>Concrete Mailer</h1><p>Hello {{name}}. Welcome to README</p><img src="/path/to/image1.jpg">''',title='README',dests=[email,'cc@netsach.org'],sender_name='Netsach',sender_email='sender@netsach.org',reply_to='contact@netsach.org',attachments=['/path/to/file.zip','/path/to/image2.png'],)sendmethod returns:Trueif the email is successfully sent.Falseif a problem has occured.2- Email preparers (preparer.py)fromconcrete_mailer.preparersimportprepare_emailimportos#:  Define the smtp connexion variables in:#:  SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_HOST_USER, SMTP_HOST_PASSWORDforname,emailin(('John','john@mail.ext'),('Jane','jane@mail.ext')):email=prepare_email(context={'name':name},html='''<h1>Concrete Mailer</h1><p>Hello {{name}}. Welcome to README</p><img src="/path/to/image1.jpg">''',title='README',css='',#: extra csssender='Netsach <sender@netsach.org>',reply_to='contact@netsach.org',recipients=[email,'cc@netsach.org'],attachments=['/path/to/file.zip','/path/to/image2.png'],email_host=os.getenv('SMTP_HOST_NAME'),#: smtp hostnameemail_port=os.getenv('SMTP_HOST_PORT'),#: smtp host portemail_host_user=os.getenv('SMTP_HOST_USER'),#: smtp host usernameemail_host_password=os.getenv('SMTP_HOST_PASSWORD'),#: smtp host passworduse_tls=os.getenv('SMTP_USE_TLS')=='1',#: smtp use tls)email.send()sendmethod returns:Trueif the email is successfully sent.Falseif a problem has occured.DebugPython standard package includes asmtpdmodule.According to theofficial documentationThis module offers several classes to implement SMTP (email) servers.One of thoses classes isDebuggingServer.Create a new debugging server. Arguments are as per SMTPServer. Messages will be discarded, and printed on stdout.If you want to test your emails, open a new console and invoke the following command:python3-msmtpd-n-cDebuggingServerlocalhost:1025and configure your environment :SMTP_HOST_NAME='localhost'SMTP_HOST_PORT='1025'SMTP_HOST_USER=''SMTP_HOST_PASSWORD=''SMTP_USE_TLS=''The email body will be displayed in console instead of being sent to destinations. Only local stmp connection will be established (dry-run)