Skip to content

Send email #46

@Benjamin-Loison

Description

@Benjamin-Loison

The Stack Overflow answer 6270987

Python script:
# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.mime.text import MIMEText

msg = MIMEText('My body')

msg['Subject'] = 'My subject'
FROM = 'algorithm@lemnoslife.com'
msg['From'] = FROM
TO = 'benjamin.loison@CENSORED.fr'
msg['To'] = TO

# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('localhost')
s.sendmail(FROM, [TO], msg.as_string())
s.quit()
On my Linux Mint 22 Cinnamon Framework 13 gives the output:
Traceback (most recent call last):
  File "<tmp 11>", line 16, in <module>
    s = smtplib.SMTP('localhost')
  File "/usr/lib/python3.12/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.12/smtplib.py", line 341, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.12/smtplib.py", line 312, in _get_socket
    return socket.create_connection((host, port), timeout,
  File "/usr/lib/python3.12/socket.py", line 852, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.12/socket.py", line 837, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

On LemnosLife VPS no error or output is raised but do not receive an email on my personal email in a few minutes, even in spam.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions