tecronin
Junior Member
Posts: 91
Raspberry Pi: Yes
|
Post by tecronin on Mar 24, 2021 17:28:26 GMT -8
in sendemail.py the smtp server is tied to gmail
# open up a line with the server s = smtplib.SMTP("smtp.gmail.com", 587)
I'm trying to use my cable acct (spectrum) in the configs since i don't use it for my normal email.
i get the following error:
Traceback (most recent call last): File "/home/pi/SDL_Pi_SkyWeather2/sendemail.py", line 51, in sendEmail s.login(config.mailUser, config.mailPassword) File "/usr/lib/python3.7/smtplib.py", line 730, in login raise last_exception File "/usr/lib/python3.7/smtplib.py", line 721, in login initial_response_ok=initial_response_ok) File "/usr/lib/python3.7/smtplib.py", line 642, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 support.google.com/mail/?p=BadCredentials t16sm6553263pfc.204 - gsmtp')
i figure i've got to change to code, is this being addressed already?
|
|
|
Post by doxidad on Mar 25, 2021 2:57:11 GMT -8
I have a suggestion for this. I have, in SkyWeather (not SkyWeather2), put a entry into the conflocal file for the SMTP server and then modified the source in sendemail.py to use it. This could easily be added to the SkyWeatherConfigure.py program to generate the proper entry in the JSON file so it can be looked up and used in the sendemailcode - the default could be gmail and could overridden by whomever.
I have not done this yet in SkyWeather2 but have hard coded it in sendemail
Not all of use gmail.
|
|
tecronin
Junior Member
Posts: 91
Raspberry Pi: Yes
|
Post by tecronin on Mar 25, 2021 10:50:33 GMT -8
thanks
my plan is to add it to the config app as well if not already being addressed
|
|
|
Post by mikethechap on May 29, 2021 20:24:08 GMT -8
So, what is the final answer for SkyWeather2 on this issue? I'm dealing with it right now.
Traceback (most recent call last): File "/home/pi/SDL_Pi_Skyweather2/sendemail.py", line 51, in sendEmail s.login(config.mailUser, config.mailPassword) File "/usr/lib/python3.7/smtplib.py", line 730, in login raise last_exception File "/usr/lib/python3.7/smtplib.py", line 721, in login initial_response_ok=initial_response_ok) File "/usr/lib/python3.7/smtplib.py", line 642, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials y13sm6520552qkj.84 - gsmtp')
sendmail exception raised -----------------
|
|
|
Post by doxidad on May 30, 2021 4:12:57 GMT -8
This has not been addressed in the configuration. You must make the changes yourself.
The module sendemail.py expects to send email through your gmail account.
s = smtplib.SMTP("smtp.gmail.com", 587) You can modify the highlighted server connection from 'smtp.gmail..com' to your ISP's mail server.
my code looks like this:
#s = smtplib.SMTP("smtp.gmail.com", 587) <<< original gmail server commented out s = smtplib.SMTP("mail.xxxxxx.us", 587) <<< this is my private email server - name X'd out for privacy
You can check with your ISP for the correct server name and port used for connection.
587 is normal for mail submission but may be different.
|
|
dow4hurst
Full Member
SkyWeather2 Newbie
Posts: 117
|
Post by dow4hurst on May 30, 2021 22:02:27 GMT -8
You can use the ssmtp package to end up with a simpler interface. I'll post an example of ssmtp use for a secondary Gmail when I get a chance tomorrow. Dow
|
|
dow4hurst
Full Member
SkyWeather2 Newbie
Posts: 117
|
Post by dow4hurst on Jun 2, 2021 1:05:51 GMT -8
To install ssmtp is pretty straightforward.
pi@SwitchDocLabs:~ $ apt show ssmtp Package: ssmtp Version: 2.64-8 Priority: extra Section: mail Maintainer: Anibal Monsalve Salazar <anibal@debian.org> Installed-Size: 1,024 B Provides: mail-transport-agent Depends: libc6 (>= 2.11), libgnutls-openssl27 (>= 3.0-0), debconf | debconf-2.0 Conflicts: mail-transport-agent Replaces: mail-transport-agent Homepage: http://packages.qa.debian.org/s/ssmtp.html Download-Size: 54.2 kB APT-Sources: http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages Description: extremely simple MTA to get mail off the system to a mail hub A secure, effective and simple way of getting mail off a system to your mail hub. It contains no suid-binaries or other dangerous things - no mail spool to poke around in, and no daemons running in the background. Mail is simply forwarded to the configured mailhost. Extremely easy configuration. . WARNING: the above is all it does; it does not receive mail, expand aliases or manage a queue. That belongs on a mail hub with a system administrator. To install the package:
sudo apt install ssmtp Answer Y if you get asked to confirm the install.
/etc/ssmtp/ssmtp.conf with info pertinent to Gmail. This is readable only by root, so "sudo vi -C /etc/ssmtp/ssmtp.conf" is how you edit it.
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=postmaster
# The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=smtp.gmail.com:587
# Where will the mail seem to come from? rewriteDomain=gmail.com
# The full hostname hostname=foobar
# Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES
AuthUser=pi@gmail.com AuthPass=xyzyxyzyxyzyx UseSTARTTLS=YES You would put your hostname, AuthUser (just the email address), and AuthPass (just the gmail password) in place of what I put.
Then the /etc/ssmtp/revaliases also requires a bit of info.
# sSMTP aliases # # Format: local_account:outgoing_address:mailhub # # Example: root:your_login@your.domain:mailhub.your.domain[:port] # where [:port] is an optional port number that defaults to 25. root:pi@gmail.com:smtp.gmail.com:587 I know the above configuration works for a gmail account I setup that receives admin messages from different systems. IIRC, I had to work through Gmail's option to create an app password for the account that doesn't require 2-step authentication to make the password work. Dow
|
|
|
Post by SDL on Jun 5, 2021 7:09:32 GMT -8
Dow,
Well put!
BP
|
|