[Python] Sending mail with python and roundcube

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to send mail with python using my rouncube webmail but when i run it outputs this error TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

    I checked in my mail and my port is "290" which have provided but when i run the function the mail doesn't send. I know how to send with gmail by turning on less secure app access but don't know how to work around to send with my webmail.

    I need your suggestion to work around it.

    from smtplib import SMTP_SSL as SMTP
    import logging, logging.handlers, sys
    from email.mime.text import MIMEText



    def send_message():
    text = '''
    Hello,

    Trying to send mail from my webmail in python 3.

    Sincerely,

    My name
    '''

    message = MIMEText(text, 'plain')
    message['Subject'] = "Email Subject"
    my_email = 'joe@mycompany.com'

    # Email that you want to send a message
    message['To'] = my_email

    # You need to change here, depending on the email that you use.
    # For example, Gmail and Yahoo have different smtp. You need to know what it is.
    connection = SMTP('smtp.roundcube.com', 290)
    connection.set_debuglevel(True)

    # Attention: You can't put for example: 'your_address@email.com'.
    # You need to put only the address. In this case, 'your_address'.
    connection.login('fred.kings', 'fredsw321a')

    try:
    # sendemail(<from address>, <to address>, <message>)
    connection.sendmail(my_email, my_email, message.as_string())
    finally:
    connection.close()



    send_message()

    Continue reading...

Compartilhe esta Página