[Python] Unable to send mail from Godaddy registered email server using Python

Discussão em 'Python' iniciado por Stack, Julho 27, 2025.

  1. Stack

    Stack Membro Participativo

    We have a Godaddy account where we have registered our domain and configured an email address for sending and receiving mails. We are trying those credentials to send mail programatically using Python. This is the code we are trying:

    import smtplib
    from email.mime.multipart import MIMEMultipart
    from email.mime.text import MIMEText

    msg = MIMEMultipart()
    msg.set_unixfrom('author')
    msg['From'] = 'info@mydomain.com'
    msg['To'] = 'myfoo@gmail.com'
    msg['Subject'] = 'simple email in python'
    message = 'here is the email'
    msg.attach(MIMEText(message))

    mailserver = smtplib.SMTP_SSL('smtpout.secureserver.net', 465)
    mailserver.ehlo()
    mailserver.login('info@mydomain.com', 'abc123')

    mailserver.sendmail('info@mydomain.com','myfoo@gmail.com',msg.as_string())

    mailserver.quit()


    However, we are getting this error consistently:

    Exception has occurred: SMTPServerDisconnected
    Connection unexpectedly closed
    File "/Users/nedstark/Desktop/code/foo.py", line 48, in <module>
    mailserver.login('info@mydomain.com', 'abc123')
    smtplib.SMTPServerDisconnected: Connection unexpectedly closed


    Any idea how to fix this, or whether there is anything in Godaddy account that we need to configure?

    Continue reading...

Compartilhe esta Página