EngHamoud EngHamoud - 4 months ago 44
Linux Question

SMTP AUTH extension not supported by server in python 2.4

I've searched about my issue but i could't find any solution

this is my normal code in my VPS hosting which provide python 2.4

def mail(receiver,Message):
import smtplib
try:
s=smtplib.SMTP()
s.connect("smtp.gmail.com",465)
s.login("email@gmail.com", "password")
s.sendmail("email@gmail.com", receiver, Message)
except Exception,R:
return R


but unfortunately return this message! :
SMTP AUTH extension not supported by server.


in my computer which i've install python 2.7 i found the solution and it's work very good here is this code :

def mail(T,M):
import smtplib
try:
s=smtplib.SMTP_SSL()
s.connect("smtp.gmail.com",465)
s.login("your.log.result@gmail.com", "QweR1234")
s.sendmail("your.log.result@gmail.com", T, M)
except Exception,R:
print R


but in the VPS which installed python 2.4 doesn't have SMTP_SSL() and return this message
'module' object has no attribute 'SMTP_SSL'


also i've tried to upgrade my python in VPS but what happened is Damage the whole python that mean python not work at all

thank you for your time

Answer

Guys thanks i've found the solution and this is the solution =)

def mail(receiver,Message):
    import smtplib
    try:
        s=smtplib.SMTP()
        s.connect("smtp.gmail.com",465)
        s.ehlo()
        s.starttls()
        s.ehlo()
        s.login("email@gmail.com", "password")
        s.sendmail("email@gmail.com", receiver, Message)
    except Exception,R:
            return R