I have a Python file with a code to send e-mail from there, and I’ll need to use it for sending from a server with Mailcow installed, as configured below:
import smtplib
import email.message
smtp_server = ‘smtp_server’
smtp_port = 587
smtp_username = ‘username@domain.com’
smtp_password = ‘password’
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(smtp_username, smtp_password)
msg = email.message.EmailMessage()
msg.set_content(‘Mail content’)
msg[‘Subject’] = ‘Mail subject’
msg[‘From’] = ‘username@domain.com’
msg[‘To’] = ‘testtest@gmail.com’
server.send_message(msg)
server.quit()
I tried to use my password, tried to use 465 port (for SSL usage), but nothing happened. Any clue?