Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send email using SMTP SSL/Port 465

I need to send email using SMTP SSL/Port 465 with my bluehost email.
I can't find working code in google i try more than 5 codes. So, please any have working code for sending email using SMTP SSL/port 465 ?

like image 791
Mahmoud Avatar asked Jul 10 '14 08:07

Mahmoud


People also ask

How do I enable SMTP on port 465?

How to enable SMTPS. To enable SMTPS, you should configure Postfix to listen on port 465 first, then open port 465 in iptables. Restart Postfix service to enable SMTPS. WARNING: Please make sure you have Amavisd listening on port 10026 (and 10024, 9998).

Does port 465 use SSL?

Port 465 requires negotiation of TLS/SSL at connection setup and port 587 uses STARTTLS if one chooses to negotiate TLS.

What port is 465 used for?

Instead, the Internet Assigned Numbers Authority (IANA), who maintains much of the core internet infrastructure, registered port 465 for SMTPS. The purpose was to establish a port for SMTP to operate using Secure Sockets Layer (SSL). SSL is commonly used for encrypting communications over the internet.

Does Gmail use port 465?

The outgoing SMTP server, smtp.gmail.com , requires TLS. Use port 465 , or port 587 if your client begins with plain text before issuing the STARTTLS command.


1 Answers

Jut to clarify the solution from dave here is how i got mine to work with my SSL server (i'm not using gmail but still same). Mine emails if a specific file is not there (for internal purposes, that is a bad thing)

import smtplib
import os.path

from email.mime.text import MIMEText

if (os.path.isfile("filename")):
    print "file exists, all went well"
else:
    print "file not exists, emailing"

    msg = MIMEText("WARNING, FILE DOES NOT EXISTS, THAT MEANS UPDATES MAY DID NOT HAVE BEEN RUN")

    msg['Subject'] = "WARNING WARNING ON FIRE FIRE FIRE!"

    #put your host and port here 
    s = smtplib.SMTP_SSL('host:port')
    s.login('email','serverpassword')
    s.sendmail('from','to', msg.as_string())
    s.quit()
print "done"
like image 71
nclaflin Avatar answered Nov 09 '22 23:11

nclaflin