Skip to content

Commit

Permalink
Adding support for outgoing SMTP port.
Browse files Browse the repository at this point in the history
  • Loading branch information
morphex committed Nov 29, 2018
1 parent 9a99a2c commit 703318f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions surveil.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ def test_dependencies():

if len(sys.argv) != 5:
print("Run as: ./%s %s %s %s %s" % (sys.argv[0], 'email@example.com', 'smtp.outgoing.example.com', 'smtp user' 'smtp password'))
print("Use smtp.outgoing.example.com:587 for SMTP port 587, default is 25")
sys.exit(1)

smtp_host = sys.argv[2]
try:
smtp_host, smtp_port = sys.argv[2].split(':')
except IndexError:
smtp_host = sys.argv[2]
smtp_port = 25
smtp_user = sys.argv[3]
smtp_password = sys.argv[4]

Expand All @@ -80,7 +85,7 @@ def message_subject(subject="Surveillance video, surveil started"):
host = MX[1]
try:
connection = smtplib.SMTP()
connection.connect(host)
connection.connect(host, port=smtp_port)
try:
connection.starttls()
except smtplib.SMTPNotSupportedError:
Expand Down Expand Up @@ -143,7 +148,7 @@ def message_video(directory):
host = MX[1]
try:
connection = smtplib.SMTP()
connection.connect(host)
connection.connect(host, port=smtp_port)
try:
connection.starttls()
except smtplib.SMTPNotSupportedError:
Expand Down

0 comments on commit 703318f

Please sign in to comment.