Using Python package Redmail and Unique SMTP port to send emails via Outlook

116 views Asked by At

I am using the RedMail package and am attempting to send out an email from a python script I have that takes a CSV, filters it, and emails it out. Redmail has an Outlook feature that allows me to send this file automatically with my personal Outlook email. However, I am trying to have the automated email sender be not my personal email but rather a different email ([email protected]), which has a different SMTP port. My script executes without errors, the resulting file is created, but it is not emailed. Any help would be appreciated.

A snippet of my code is below. As can be seen, the host server is mail.smtp2go.com, while outlook's SMTP server is normally [email protected]. Not sure if there is a way to send this email automatically via Outlook if my SMTP host is different. Again, when I run this, the desired file ('File.xlsx') is produced, the email is just not sent. Any input would be greatly appreciated.

email = EmailSender(
    host = 'mail.smtp2go.com',
    port = 587,
    username = '[email protected]',
    password = 'password1',
    use_starttls=False
)

email.send(
    subject="Test Email",
    receivers=['[email protected]'],
    text="This is a test of an automated email from the no-reply domain.",
    attachments={
        'File.xlsx': Path(finalpath)
    }
)
0

There are 0 answers