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

sendmail cont connect to smtp.gmail.com #14404

Closed
14 tasks
mrpatate76 opened this issue Jan 12, 2022 · 43 comments · Fixed by #14429
Closed
14 tasks

sendmail cont connect to smtp.gmail.com #14404

mrpatate76 opened this issue Jan 12, 2022 · 43 comments · Fixed by #14429
Labels
troubleshooting Type - Troubleshooting

Comments

@mrpatate76
Copy link

mrpatate76 commented Jan 12, 2022

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

Hello, i try to send an email on high température into a script

all that is in my sonoff zigbee bridge, flashed with tasmota of course

so far, manage to print on high température and link it to a bulb, to be sure that i am going to the right place in the code

19:24:08.916 CMD: sendmail [::::*:mrpatate76@gmail.com:test sendmail] juste un test
19:24:08.918 mailsize: 44
19:24:08.919 smtp.gmail.com - 465 - mrpatate76@gmail.com - password
19:24:08.920 mrpatate76@gmail.com - mrpatate76@gmail.com - test sendmail - juste un test
19:24:08.921 Connecting: smtp.gmail.com on port 465
19:24:09.021 Connection failed
19:24:09.024 RSL: RESULT = {"Sendmail":"Wrong parameters"}

i test my password to be sure it is working ( in app paswaord) and it is ok, so i guess it is something in code or related to authentification on gmail side

i compile using tasmotiser including this
#ifndef USE_SCRIPT
#define USE_SCRIPT // adds about 17k flash size, variable ram size
#endif
#ifdef USE_RULES
#undef USE_RULES
#endif

#define DEBUG_EMAIL_PORT Serial
#define USE_BUTTON_EVENT
#define SCRIPT_POWER_SECTION
#define USE_SENDMAIL
#define USE_SCRIPT_WEB_DISPLAY
#define SUPPORT_MQTT_EVENT
#define SUPPORT_IF_STATEMENT
#define USE_SCRIPT_SUB_COMMAND

#define EMAIL_USER "mrpatate76@gmail.com"
#define EMAIL_PASSWORD "password"
#define EMAIL_FROM "mrpatate76@gmail.com"
#define EMAIL_SERVER "smtp.gmail.com"
#define EMAIL_PORT 465
#define MAIL_TIMEOUT 2000

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • Searched the problem in discussions
  • Searched the problem in the docs
  • Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): _____
  • Tasmota binary firmware version number used: _____
    • Pre-compiled
    • Self-compiled
  • Flashing tools used: _____
  • Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:

  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:

  • Provide the output of this command: Status 0:
  STATUS 0 output here:

  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:

TO REPRODUCE

Steps to reproduce the behavior:

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

@close-issue-app close-issue-app bot added the template missing/incomplete Action - Template Missing or incomplete (issue will be closed) label Jan 12, 2022
@barbudor
Copy link
Contributor

test my password to be sure it is working ( in app paswaord) and it is ok,

Are you using your Google account password ?
This will not work
You must create an "application specific password"
https://support.google.com/mail/answer/185833

@barbudor
Copy link
Contributor

And you need to set the EMAIL_FROM with < and >

    #define USE_SENDMAIL
    #define EMAIL_USER "username"
    #define EMAIL_PASSWORD "xxxxxxxxxx"
    #define EMAIL_FROM "<username@gmail.com>"
    #define EMAIL_SERVER "smtp.gmail.com"
    #define EMAIL_PORT 465

@mrpatate76
Copy link
Author

i use

sendmail [smtp.gmail.com:25:mrpatate76@gmail.com:16caracter password for in app:mrpatate76@gmail.com:mrpatate76@gmail.com:alarme temperature frigo] Important, Verifier le frigo, la temperature est elevee

always same result :

21:05:53.518 CMD: sendmail [smtp.gmail.com:25:mrpatate76@gmail.com:password:mrpatate76@gmail.com:mrpatate76@gmail.com:alarme temperature frigo] Important, Verifier le frigo, la temperature est elevee
21:05:53.521 mailsize: 126
21:05:53.522 smtp.gmail.com - 25 - mrpatate76@gmail.com - password
21:05:53.523 mrpatate76@gmail.com - mrpatate76@gmail.com - alarme temperature frigo - Important, Verifier le frigo, la temperature est elevee
21:05:53.524 Connecting: smtp.gmail.com on port 25
21:05:55.581 Connection failed
21:05:55.584 RSL: RESULT = {"Sendmail":"Wrong parameters"}

@mrpatate76
Copy link
Author

i think it is a authentification or Secured Connection matter from gmail server

@mrpatate76
Copy link
Author

still the same with or without the <>

21:10:56.987 CMD: sendmail [smtp.gmail.com:465:mrpatate76@gmail.com:password:mrpatate76@gmail.com:mrpatate76@gmail.com:alarme temperature frigo] Important, Verifier le frigo, la temperature est elevee
21:10:56.990 mailsize: 127
21:10:56.991 smtp.gmail.com - 465 - mrpatate76@gmail.com - password
21:10:56.992 mrpatate76@gmail.com - mrpatate76@gmail.com - alarme temperature frigo - Important, Verifier le frigo, la temperature est elevee
21:10:56.993 Connecting: smtp.gmail.com on port 465
21:10:57.079 Connection failed
21:10:57.082 RSL: RESULT = {"Sendmail":"Wrong parameters"}

@barbudor
Copy link
Contributor

Did you followed the instruction for application specific password ?

It will NOT work with your Google Account password

@mrpatate76
Copy link
Author

yes got the 16 letters for application specific password. try it on my phone and worked, but same one in tasmota get wrong parameter, and send nothing since not activity is shown on my google account page

@barbudor
Copy link
Contributor

Don't send to yourself, I think gmail is not supporting that
I'm recompiling a version with sendmail to test again as I haven't used that for months

@mrpatate76
Copy link
Author

oh, good to know, i will try to send it to my other email, juste to see if it work.

dont look like it change anything, let me know if you got it to work on your side

thanks for the help

@barbudor
Copy link
Contributor

Can't get it to work, neither with gmail nor my local smtp server
Looks like something might be broken
will need more investigation

Alternatively an easy way to send an simple email is to use a WebHook with IFTTT or Integromat or Zappier that you can call from Tasmota using WebQuery command
You can also use Discord with a WebHook too

@mrpatate76
Copy link
Author

hello,
I set-up for WebQuery
i compile adding
#define USE_WEBSEND_RESPONSE
on ifttt, i manage to get it working for webhook, and my email, i can trigger online using
https://maker.ifttt.com/trigger/alarme/with/key/d1kz82kwUI0Tr8SThMsx1X
and this work, since i get email

but in tasmota console, when i try to do the WebQuery unsing:

WebQuery Https://maker.ifttt.com/trigger/alarme/with/key/d1kz82kwUI0Tr8SThMsx1X GET
i received : Host not found. As you can see below:

is there anything else that need to be compile to get it working?

thanks again for your help

17:12:02.846 CMD: WebQuery Https://maker.ifttt.com/trigger/alarme/with/key/d1kz82kwUI0Tr8SThMsx1X GET
17:12:02.848 SRC: WebConsole from 10.0.0.157
17:12:02.849 CMD: Grp 0, Cmnd 'WEBQUERY', Idx 1, Len 74, Data 'Https://maker.ifttt.com/trigger/alarme/with/key/d1kz82kwUI0Tr8SThMsx1X GET'
17:12:02.852 RSL: RESULT = {"WebQuery":"Host not found"}

@mrpatate76
Copy link
Author

got two alarm mail from ifttt

@ascillato2 ascillato2 added troubleshooting Type - Troubleshooting and removed template missing/incomplete Action - Template Missing or incomplete (issue will be closed) labels Jan 13, 2022
@ascillato2 ascillato2 reopened this Jan 13, 2022
Repository owner deleted a comment from close-issue-app bot Jan 13, 2022
@barbudor
Copy link
Contributor

barbudor commented Jan 13, 2022

You just got mail another mail :)
I suggest you delete you IFTTT action and recreate it with another token if you don't want to receive alerts from jokers of my kind or worst

17:58:50.347 CMD: webquery https://maker.ifttt.com/trigger/alarme/with/key/*****************   GET
17:58:50.349 SRC: WebConsole from 192.168.168.53
17:58:50.352 CMD: Grp 0, Cmnd 'WEBQUERY', Idx 1, Len 74, Data 'https://maker.ifttt.com/trigger/alarme/with/key/****************  GET'
17:58:50.392 MQT: stat/nodemcu/WEBQUERY = {"WebQuery":"Done"}

@gemu2015
Copy link
Contributor

ok tested email on esp32 and esp8266. (both use very different approaches)

esp32 works without any problems.
keep in mind that emails must not be enclosed in sharp brackets here while in esp8266 it has to be

esp8266 indeed does no longer connect to gmail in the latest dev version. however at least in an older version (9.4) it works well. so it cannot be due to change at gmail.
since nothing has changed within email driver itself some changes in light_bear_ssl or core must cause this failure.
will take some time to evaluate this issue.

@gemu2015
Copy link
Contributor

it turns out that light_bear is the cause. taking the ssl lib from 9.4 into latest dev solves the problem.
@s-hadinger may be you can determine what causes failure in SMPT for ESP8266

@gemu2015
Copy link
Contributor

found the reason and fixed the issue. will do a pr later today

@gemu2015 gemu2015 mentioned this issue Jan 14, 2022
6 tasks
@s-hadinger
Copy link
Collaborator

Thanks @gemu2015 I'm curious what was the problem?

@gemu2015
Copy link
Contributor

simple esp8266 smtp needs insecure TLS. the new default was insecure set to false.
i simply introduced a set insecure call like in standard TLS.

@barbudor
Copy link
Contributor

Thanks @gemu2015

@mrpatate76
Copy link
Author

i tried to compile with development in tasmotizer, but I get Fail,

something related to sendmail, bear client not define:

i add only those custum parameters: #ifndef USE_SCRIPT
#define USE_SCRIPT // adds about 17k flash size, variable ram size
#endif

#define USE_SENDMAIL

part of the compile log:

Compiling .pio/build/firmware/lib50a/bearssl-esp8266/aead/eax.c.o
In file included from /tmp/Tasmota/tasmota/sendemail_ESP8266.ino:3:0:
tasmota/sendemail_ESP8266.h:20:5: error: 'WiFiClientSecure_light' in namespace 'BearSSL' does not name a type
BearSSL::WiFiClientSecure_light client;
^
In file included from /tmp/Tasmota/tasmota/sendemail_ESP8266.ino:3:0:
tasmota/sendemail_ESP8266.h: In destructor 'SendEmail::~SendEmail()':
tasmota/sendemail_ESP8266.h:29:18: error: 'client' was not declared in this scope
~SendEmail() {client->stop(); delete client;}
^
tasmota/sendemail_ESP8266.h:29:41: error: type '' argument given to 'delete', expected pointer
~SendEmail() {client->stop(); delete client;}
^
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino: In constructor 'SendEmail::SendEmail(const String&, int, const String&, const String&, int, int)':
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino:182:107: error: class 'SendEmail' does not have any field named 'client'
host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) {
^
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino:182:118: error: expected type-specifier
host(host), port(port), user(user), passwd(passwd), timeout(timeout), ssl(ssl), auth_used(auth_used), client(new BearSSL::WiFiClientSecure_light(1024,1024)) {
^
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino: In member function 'String SendEmail::readClient()':
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino:187:14: error: 'client' was not declared in this scope
String r = client->readStringUntil('\n');
^
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino: In member function 'bool SendEmail::send(const String&, const String&, const String&, const char
)':
/tmp/Tasmota/tasmota/sendemail_ESP8266.ino:205:3: error: 'client' was not declared in this scope
client->setTimeout(timeout);
^
Compiling .pio/build/firmware/lib50a/bearssl-esp8266/aead/gcm.c.o

@barbudor
Copy link
Contributor

Which tasmota are you compiling ? "tasmota.bin" ?
When customizing you must compile "tasmota" and not any variant (such as tasmota-sensors or other)

@mrpatate76
Copy link
Author

i use tasmotizer for sonoff zigbee bridge, and passing custum parameters

@mrpatate76
Copy link
Author

by the way, i manage to get an email using

=>WebSend [maker.ifttt.com] /trigger/alarme/with/key/d1kz82kwUI0Tr8SThMsx1X

@barbudor
Copy link
Contributor

Tasmotizer is a PC app to flash firmware. It's not a compiler.

Are you talking about TasmoCompiler ?

@mrpatate76
Copy link
Author

sorry you are right
tasmocompiler

ESP8266 with onOff Zigbee Bridge
option for
Light sensors
Temp/Hum sensors
Timers
Display Vcc
Web interface
Script

#ifndef USE_SCRIPT
#define USE_SCRIPT // adds about 17k flash size, variable ram size
#endif

custom parameters:
#define USE_WEBSEND_RESPONSE
#define SCRIPT_POWER_SECTION
#define USE_SENDMAIL

@Jason2866
Copy link
Collaborator

ALWAYS use Tasmota as base for self compile. Other env are specialized and restricted.

@gemu2015
Copy link
Contributor

@mrpatate76
i now also get this compile error (didn't have this before)
try enabling TLS together with USE_SENDMAIL
#define USE_TLS
#define USE_SENDMAIL

@Tino4
Copy link

Tino4 commented Jan 29, 2022

@gemu2015 , hi sir can you tell me sendmail is working at the moment ? I've tried almost everything and still not working.I have changed the 3 files and i added the rule #define TLS in config override file ,still not working when i type the command =>sendmail.... in the console , can you give me advice / info ? Thank you very much in advance.Grtz

@gemu2015
Copy link
Contributor

gemu2015 commented Jan 29, 2022

@Tino4

use the very last dev Version.
#define USE_SENDMAIL should be enough now

and try the full cmd in console (with your own credentials and email addresses)

=>sendmail [smtp.gmail.com:465:user:password:<from@gmail.com>:<to@gmail.com>:test]Hello world

@gemu2015
Copy link
Contributor

you must use the sharp clips on esp8266 (not on esp32)

@Tino4
Copy link

Tino4 commented Jan 29, 2022 via email

@Tino4
Copy link

Tino4 commented Jan 29, 2022

Thx guys its working now with the latest developer firmware and the command as follows :sendmail [smtp.gmail.com:465:user:passwd:from@gmail.com:to@gmail.com:test]Hello world ,i use the 8266 and need the sharp clips !!Many thx @ gemu and Theo !!!I'm so happy now :-) Grtz

@damiankuziora
Copy link

damiankuziora commented Feb 7, 2022

Hello
I am new to smart home. I am learning tasmota and I like it very much. Recently I learned to compile correctly. I need help setting up for sending to icloud mail. Of course, I have already tried with the application password but it does not work.

@gemu2015
Copy link
Contributor

gemu2015 commented Feb 8, 2022

the mail option in esp8266 is very limited. it does only work with a few mail servers and only with setting the email server to reduced security. (gmail is working, icloud does not)
the esp32 mailer supports all kinds of email servers, i assume also icloud will work.

@Tino4
Copy link

Tino4 commented Apr 16, 2022

Hi guys , i've still a problem with sendmail esp8266 , always the first time execution troubles with the sendmail command , second ,third .....time no problem at all.it seems that if the esp8266 is inactive for a while the problem occurs.I've disabled sleep ....no solution.I've tried last firmware version ...no solution.Anyone a suggestion?P.S. there is also a bug in the calculation of the ISL28022 , the ISL28022 uses a 5 milliohm resistor instead of an 100milliohm and the isl28022 calculation is based on a ina219 thus wrong current value , also the bus voltage calculation is wrong.Maybe someone can give me info or can help me with these.Best regards , Tino

@barbudor
Copy link
Contributor

Open a separate discussion for the ISL28022

@Tino4
Copy link

Tino4 commented Apr 16, 2022

Open a separate discussion for the ISL28022

okay , i'm sorry for that.Best Regards,Tino

@lalo-uy
Copy link
Contributor

lalo-uy commented Apr 16, 2022 via email

@barbudor
Copy link
Contributor

Where did you got this information ?
You need an application specific password for that but I can't find any info it will be ending.
https://support.google.com/mail/answer/185833?hl=en

@famdejongjohan
Copy link

Hi all,

trying to send email with ESP32-CAM image as atachment with the Tasmota script. Sending email through Gmail (16character app password procedure) works. But the ">m" section is not evaluated, also i have to fill in the values at the sendmail line, "*" are not parsed either ...

I use the tasmocompiler for my firmware and trying to find the missing part.

My defines are a stacked up set of includes found in a lot different solutions from the web (so it is a mesh ;-) )
#define USE_WEBCAM
#define USE_SCRIPT
#define UFSYS_SIZE 8192
#define USE_FEXTRACT
#define USE_SCRIPT_WEB_DISPLAY
#define USE_SCRIPT_JSON_EXPORT
#define USE_SENDMAIL //Not sure if this adds something foor ESP32 CAM
#define USE_ESP32MAIL
#define USE_TLS
#define DEBUG_EMAIL_PORT
#define SDCARD_DIR //Not essential I think
#define USE_SCRIPT_FATFS_EXT //Not essential I think
#define USE_SCRIPT_FATFS //Not essential I think
#define USE_UFILESYS
#define USE_SDCARD
#define SUPPORT_MQTT_EVENT //new

can anybody tell me the missing "define" ?

@famdejongjohan
Copy link

oh, oops this item is closed, I will open a new one.

@famdejongjohan
Copy link

Fixed the problem ...

  • the "*" body can not have a in front of it .. the >m section is now evaluated .. :-)))

@famdejongjohan
Copy link

"space" in front

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Type - Troubleshooting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants