Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable STARTTLS missing #115

Open
dado991 opened this issue Apr 24, 2021 · 4 comments
Open

Option to disable STARTTLS missing #115

dado991 opened this issue Apr 24, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@dado991
Copy link

dado991 commented Apr 24, 2021

Hi,
i'm using a local SMTP Relay without encryption and user login.

Reporting...
    Formating report...
    Sending report by email...
Traceback (most recent call last):
  File "/home/pi/pialert/back/pialert.py", line 1488, in <module>
    sys.exit(main())
  File "/home/pi/pialert/back/pialert.py", line 94, in main
    email_reporting()
  File "/home/pi/pialert/back/pialert.py", line 1324, in email_reporting
    send_email (mail_text, mail_html)
  File "/home/pi/pialert/back/pialert.py", line 1416, in send_email
    smtp_connection.starttls()
  File "/usr/lib/python3.7/smtplib.py", line 752, in starttls
    "STARTTLS extension not supported by server.")
smtplib.SMTPNotSupportedError: STARTTLS extension not supported by server.

Is there a way to disable login and STARTTLS encryption for SMTP configuration?

Thank You!

@dado991 dado991 changed the title Option to disable STARTTLS Option to disable STARTTLS missing Apr 24, 2021
@dado991
Copy link
Author

dado991 commented Apr 24, 2021

If it can be useful, commenting out these lines inside back\pialert.py the emails arrive correctly.
It would be wonderful to be able to set this behavior in the configuration file

def send_email (pText, pHTML):
    # Compose email
    msg = MIMEMultipart('alternative')
    msg['Subject'] = 'Pi.Alert Report'
    msg['From'] = REPORT_FROM
    msg['To'] = REPORT_TO
    msg.attach (MIMEText (pText, 'plain'))
    msg.attach (MIMEText (pHTML, 'html'))

    # Send mail
    smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT)
#    smtp_connection.ehlo()
#    smtp_connection.starttls()
    smtp_connection.ehlo()
#    smtp_connection.login (SMTP_USER, SMTP_PASS)
    smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string())
    smtp_connection.quit()

@pucherot pucherot self-assigned this Apr 24, 2021
@pucherot pucherot added the enhancement New feature or request label Apr 24, 2021
@pucherot
Copy link
Owner

Thank you
I'll include a new option in the configuration file.

@dado991
Copy link
Author

dado991 commented Apr 24, 2021

You are welcome 😁

@Thijn
Copy link

Thijn commented May 5, 2021

While you're at it, could you also enable the option to not specify user and password?
I have a SMTP server running on the host I'm running Pi.Alert on, so it can relay mail without authentication.

This worked for me, keeping SMTP_USER and SMTP_PASS as empty strings in my config:

    # Send mail
    smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT)
    smtp_connection.ehlo()
    smtp_connection.starttls()
    smtp_connection.ehlo()

    if SMTP_USER != "" :
        smtp_connection.login (SMTP_USER, SMTP_PASS)

    smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string())
    smtp_connection.quit()```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants