A
A
Alexander Bondarenko2021-12-14 16:53:41
Python
Alexander Bondarenko, 2021-12-14 16:53:41

Can I send emails from my local smtp?

I have a local smtp server on aiosmtpd, how can I make it send emails to other servers like gmail? How can I do this and where to look, tell me the documentation.

import asyncio
import logging

from aiosmtpd.controller import Controller
from aiosmtpd.handlers import Sink
from smtplib import SMTP


async def amain(loop):
    cont = Controller(Sink(), hostname='127.0.0.1', port=8025)
    cont.start()


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    loop = asyncio.get_event_loop()
    loop.create_task(amain(loop=loop))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass


client
import smtplib

s = smtplib.SMTP('127.0.0.1', 8025)
try:
    s.set_debuglevel(True)
    s.sendmail('[email protected]', ['[email protected]'], """\
    Date:17/05/2017,2:18
    From: [email protected]
    To: [email protected]
    Subject: A test
    testing
    """)
    s.quit()
except smtplib.SMTPException:
    print("Error: unable to send email")
    import traceback
    traceback.print_exc()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2021-12-14
@bond_1013

https://www.mail-tester.com/
https://www.mailgenius.com/
well, pr, go, did you cover port 25?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question