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)