Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29745

How to bypass SMTP timeout due to network?

$
0
0

I am trying to send an email using a python program which i have attached with this.In this i am using smtp server, the code is working fine when i try with my mobile data connection but fails when i try in my college wifi network.Even I have tried all the following port numbers 25,465,587,2525 & 2526 , but still its not working.So suggest a way to send email in such a network or some other related sources in python or C++.

# Python 3

import smtplib

port_number = 587 # 25

def send_Mail(src,des,password,message):
    global port_number
   try:
     print("Start")
     server = smtplib.SMTP('smtp.gmail.com',port_number) # Failing in this line
     print("Connection Established")
     server.ehlo()
     print("Extended hello done")
     server.starttls()
     print("tls Handshake completed")
     server.login(src,password)
     print("Logged in")
     server.sendmail(src,des,message)
     print("Mail sent")
     server.quit()
     print("Success!")
   except:
     pass

mail_of_sender = "example@example.com"
recipient_mail_id = "test@example.com"
password = "testingpassword"
message = "Testing"
send_Mail(mail_of_sender,recipient_mail_id,password,message)


Viewing all articles
Browse latest Browse all 29745

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>