Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

SMTP does not seem to work with Gmail #304

Closed
openhab-bot opened this issue Nov 17, 2013 · 33 comments
Closed

SMTP does not seem to work with Gmail #304

openhab-bot opened this issue Nov 17, 2013 · 33 comments

Comments

@openhab-bot
Copy link
Collaborator

From [email protected] on May 16, 2013 22:35:55

What steps will reproduce the problem? 1. Configure openhab.cfg to use SMTP:

mail:hostname=smtp.gmail.com
mail:port=587
mail:username=youruser
mail:password=yourpassword
mail:from=[email protected]
mail:tls=true

  1. Create a rule in demos.rule to send a test mail:

rule "E-mail"
when
System started
then
sendMail("[email protected]","Test e-mail","Test e-mail")
end

  1. Launch OpenHAB

What is the expected output?

To get an e-mail

What do you see instead?

The rule is launched, but the mail fails to send.
I get a message saying "Send failure" What version of the product are you using? On what operating system? OpenHAB 1.2.0
Windows 7 Please provide any additional information below. I tried all possible combinations of ports 25, 587 and 465, with and without TLS. The failure message changes but it nevers sends the e-mail.

I doubled checked user and password.

I tried different gmail accounts with the same results.

I even tried with hotmail (smtp.live.com), with the same results...

I tried two different PCs with Windows 7.

I just don't know what else to try.
Please help.

Thanks in advance

Original issue: http://code.google.com/p/openhab/issues/detail?id=304

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 16, 2013 13:37:55

Title should be "SMTP does not seem to work with Gmail" instead of "SMPT does not seem to work with Gmail". My apologies...

@openhab-bot
Copy link
Collaborator Author

From teichsta on May 16, 2013 22:07:21

changed title

Summary: SMTP does not seem to work with Gmail (was: SMPT does not seem to work with Gmail)

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 17, 2013 09:48:03

My guess is that is something related with Apache.

The code in 'openhab.io.net.actions.Mail.java' seems OK.

I tried with a local server without authentication (port 25) and it did not work.
If I make a telnet (port 25) to this server, I am able to send the e-mail manually (by writing the commands in the console), so it seems to be a problem with 'org.apache.commons.mail.SimpleEmail' class.

In fact the exception is thrown at line 132 of 'openhab.io.net.actions.Mail.java', where the SimpleMail.send() method is invoked.

I use Java 1.7.0_21-b11.

Any thoughts?

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 20, 2013 06:22:42

It works for me with the same configuration

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 20, 2013 06:32:07

I think it may be related with Apache configuration or with some kind of environment variable, but I have no clue at all of which one...
I am almost sure is not a problem of the server.

Did this happen to anyone else?

@openhab-bot
Copy link
Collaborator Author

From kai.openhab on May 20, 2013 12:12:31

I am also successfully using the mail action since a long time (but not with gmail) and have no problems whatsoever with it...
Do you see any more information in the log than "Send failure", if you start in debug mode?

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 30, 2013 02:32:06

I also have gmail functional with the config above - BUT, I'm using Linux.

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 30, 2013 06:57:34

This is the result I get, in debug mode, when using

mail:hostname=smtp.gmail.com
mail:port=465
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true

15:49:26.963 DEBUG o.o.m.r.i.engine.RuleEngine[:277] - Executing startup rule 'SMTP'

Sending data EHLO Heimdall<<<<<<
Sending data QUIT<<<<<<
15:49:27.232 ERROR o.openhab.io.net.actions.Mail[:136] - Could not send e-mail to '[email protected]æ.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: javax.mail.MessagingException: java.net.SocketException: Software caused connection abort: socket write error
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendLine(SMTPTransport.java:1702)
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendQuit(SMTPTransport.java:1459)
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.close(SMTPTransport.java:732)
at javax.mail.Transport.send(Transport.java:144)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
15:49:27.235 INFO o.o.m.c.i.f.FolderObserver[:163] - Loaded file 'demo.rules'

mail:hostname=smtp.gmail.com
mail:port=587
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true

the result is:

15:52:48.450 DEBUG o.o.m.r.i.engine.RuleEngine[:277] - Executing startup rule 'SMTP'

Sending data EHLO Heimdall<<<<<<
Sending data QUIT<<<<<<
15:52:48.707 ERROR o.openhab.io.net.actions.Mail[:136] - Could not send e-mail to '[email protected]æ.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Server doesn't support required transport level secu
rity)
at javax.mail.Transport.send(Transport.java:163)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
Caused by: javax.mail.MessagingException: Server doesn't support required transport level security
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.sendHandshake(SMTPTransport.java:1840)
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:393)
at javax.mail.Service.connect(Service.java:265)
at javax.mail.Service.connect(Service.java:85)
at javax.mail.Service.connect(Service.java:70)
at javax.mail.Transport.send(Transport.java:94)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
15:52:48.711 INFO o.o.m.c.i.f.FolderObserver[:163] - Loaded file 'demo.rules'

And with:

mail:hostname=smtp.gmail.com
mail:port=25
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=false

the result is:

15:55:13.565 DEBUG o.o.m.r.i.engine.RuleEngine[:277] - Executing startup rule 'SMTP'

Sending data EHLO Heimdall<<<<<<
Sending data AUTH LOGIN<<<<<<
Sending data c2VyY2FzeXI=<<<<<<
Sending data c2N5ODA1MXljcw==<<<<<<
Sending data QUIT<<<<<<
15:55:13.839 ERROR o.openhab.io.net.actions.Mail[:136] - Could not send e-mail to '[email protected]æ.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase...

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 30, 2013 06:57:34

....interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: Error authenticating with server)
at javax.mail.Transport.send(Transport.java:163)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
Caused by: javax.mail.AuthenticationFailedException: Error authenticating with server
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:402)
at javax.mail.Service.connect(Service.java:265)
at javax.mail.Service.connect(Service.java:85)
at javax.mail.Service.connect(Service.java:70)
at javax.mail.Transport.send(Transport.java:94)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:132)
at org.openhab.io.net.actions.Mail.sendMail(Mail.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:55:13.843 INFO o.o.m.c.i.f.FolderObserver[:163] - Loaded file 'demo.rules'

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 30, 2013 08:44:58

What about
mail:popbeforesmtp=true

@openhab-bot
Copy link
Collaborator Author

From [email protected] on May 30, 2013 08:56:06

I tried that also, but it does not work...

This is what I get with

mail:hostname=smtp.gmail.com
mail:port=587
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true
mail:popbeforesmtp=true

17:51:32.328 ERROR o.openhab.io.net.actions.Mail[:136] - Could not send e-mail to '[email protected]æ.
org.apache.commons.mail.EmailException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1203)
Caused by: javax.mail.MessagingException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:141)
Caused by: java.lang.IllegalArgumentException: port out of range:-1
at java.net.InetSocketAddress.checkPort(Unknown Source)
17:51:32.330 INFO o.o.m.c.i.f.FolderObserver[:163] - Loaded file 'demo.rules'

This is what I get with

mail:hostname=smtp.gmail.com
mail:port=465
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true
mail:popbeforesmtp=true

17:53:34.637 ERROR o.openhab.io.net.actions.Mail[:136] - Could not send e-mail to '[email protected]æ.
org.apache.commons.mail.EmailException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1203)
Caused by: javax.mail.MessagingException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:141)
Caused by: java.lang.IllegalArgumentException: port out of range:-1
at java.net.InetSocketAddress.checkPort(Unknown Source)

@openhab-bot
Copy link
Collaborator Author

From teichsta on July 12, 2013 08:18:37

does the problem still occur?

@openhab-bot
Copy link
Collaborator Author

From [email protected] on July 12, 2013 08:37:51

Yes, indeed.
I did not find a solution... nor an explanation that answers why it does not work for me.

@openhab-bot
Copy link
Collaborator Author

From teichsta on July 13, 2013 13:38:42

i managed to send email from my MacOS system with to following properties:

mail:hostname=smtp.gmail.com
mail:port=587
mail:[email protected]
mail:password=
mail:[email protected]
mail:tls=true

Can you confirm that they work for you as well? ( http://stackoverflow.com/questions/848794/sending-email-in-java-using-apache-commons-email-libs gave a hint).

Regards,

Thomas E.-E.

@openhab-bot
Copy link
Collaborator Author

From teichsta on August 13, 2013 09:11:49

any news?

@openhab-bot
Copy link
Collaborator Author

From [email protected] on August 16, 2013 07:17:54

No,

I've just lost all hope in getting it working...

@openhab-bot
Copy link
Collaborator Author

From [email protected] on September 28, 2013 14:04:31

Anyone has succesfully sent an e-mail using OpenHAB in Windows 7?

@openhab-bot
Copy link
Collaborator Author

From [email protected] on September 28, 2013 14:07:23

I am starting to think that the problem is the OS...

@openhab-bot
Copy link
Collaborator Author

From kai.openhab on September 28, 2013 20:44:15

As we are doing nothing particular, but simply using Apache commons-email, you might want to check on the web if there are any known issues regarding this library on Windows 7.

@openhab-bot
Copy link
Collaborator Author

From [email protected] on October 07, 2013 07:44:52

I hope this can help.
Just tested this on Win8, this works for me.

OS:
Win 8 64bit
JDK:
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

OpenHAB 1.4.0-SNAPSHOT:
commit 29ab2f1
Merge: 345fed9 1737950
Author: kaikreuzer [email protected]
Date: Sat Oct 5 20:23:05 2013 -0700

Merge pull request #27 from kgoderis/tcppatch

Fix sequence of Quartz startup in configureBinding()

@openhab-bot
Copy link
Collaborator Author

From [email protected] on October 07, 2013 12:38:12

I had one glitch afterwards (probably lost my connection for a minute), but it keeps on working now.

@openhab-bot
Copy link
Collaborator Author

From [email protected] on October 08, 2013 00:07:43

Am I supposed to set up or reinstall Apache, or is this something that OpenHAB does?
I agree that it looks like a problem with Apache but I have no clue at all...
Maybe it is not a problem with Windows 7 but something I am missing to do with Apache.

@openhab-bot
Copy link
Collaborator Author

From [email protected] on October 08, 2013 01:11:00

Hi,

Have you tried using another gmail account?

Here are my findings to the other configs you posted:

When I try to send email using:
mail:hostname=smtp.gmail.com
mail:port=25
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=false

I get an error Connection timed out.
So it does need tls to be true. I like this, it's secure!

Using:
mail:hostname=smtp.gmail.com
mail:port=465
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true
mail:popbeforesmtp=true

Gives me a port out of range error, I don't like pop so I would set that to false...
Anyway 465 is for smtps... config looks awkward.

When trying with:
mail:hostname=smtp.gmail.com
mail:port=465
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true

This takes too long to wait for the time-out ;-)
I suppose because we try to connect on port 465 on an smpt (not smtps) server.
Read this: http://stackoverflow.com/questions/15796530/what-is-the-difference-between-ports-465-and-587 Google does not have smtps.google.com

So the only working configuration for me is:
mail:hostname=smtp.gmail.com
mail:port=587
mail:username=myuser
mail:password=mypassword
mail:from=[email protected]
mail:tls=true

Did you download the openhab-runtime.zip, unpack that and run start.bat?

The error you get: Server doesn't support required transport level secu
rity, makes me think you have something configured in your gmail that blocks the connection...

I have another gmail account with two-factor auth, using this account I get :
10:09:38.627 ERROR o.o.action.mail.internal.Mail[:142] - Could not send e-mail to '[email protected]‘.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:138)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713)
at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: Error authenticating with server)
at javax.mail.Transport.send(Transport.java:163)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:138)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729)
Caused by: javax.mail.AuthenticationFailedException: Error authenticating with server
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:402)
at javax.mail.Service.connect(Service.java:265)
at javax.mail.Service.connect(Service.java:85)
at javax.mail.Service.connect(Service.java:70)
at javax.mail.Transport.send(Transport.java:94)
at javax.mail.Transport.send(Transport.java:48)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
at org.apache.commons.mail.Email.send(Email.java:1267)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:138)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Try using a 'clean' gmail account...

@openhab-bot
Copy link
Collaborator Author

From teichsta on November 05, 2013 14:47:54

Labels: To-Github

@teichsta teichsta reopened this Dec 8, 2013
@teichsta
Copy link
Member

Does this issue still apply?

@teichsta
Copy link
Member

since nobody else reported this issue currently i will close this issue. Please feel free to reopen it if this issue still apply. Best, Thomas E.-E.

@RemcoteWinkel
Copy link

Please reopen, same here.

[system]
Openhab 1.6.2
Linux a20-olimex 3.4.90+ #11 SMP PREEMPT Wed Aug 20 08:20:32 EEST 2014 armv7l GNU/Linux
java version "1.6.0_35"
OpenJDK Runtime Environment (IcedTea6 1.13.7) (6b35-1.13.7-1~deb7u1)
OpenJDK Zero VM (build 23.25-b01, mixed mode)

[openhab.cfg]
mail:hostname=s008.domeinbalie.nl
mail:port=465
mail:username=*@pmoguru.nl
mail:password=xx
mail:from=[email protected]
mail:tls=true
mail:popbeforesmtp=true

[rules]
sendMail("[email protected]", "Test bericht" , "Test")

[openhab.log]
22:27:12.676 ERROR o.o.action.mail.internal.Mail[:122]- Could not send e-mail to '*[email protected]‘.
org.apache.commons.mail.EmailException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1203)
at org.apache.commons.mail.Email.send(Email.java:1266)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:118)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Caused by: javax.mail.MessagingException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:141)
at javax.mail.Service.connect(Service.java:242)
at javax.mail.Service.connect(Service.java:85)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1198)
at org.apache.commons.mail.Email.send(Email.java:1266)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:118)
Caused by: java.lang.IllegalArgumentException: port out of range:-1
at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143)
at java.net.InetSocketAddress.(InetSocketAddress.java:224)
at java.net.Socket.(Socket.java:266)
at org.apache.geronimo.javamail.store.pop3.POP3Connection.getConnectedSocket(POP3Connection.java:215)
at org.apache.geronimo.javamail.store.pop3.POP3Connection.open(POP3Connection.java:89)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:139)
22:27:13.104 INFO o.o.b.e.internal.ExecBinding[:313]- executed commandLine 'sh /home/domo/heatmiser-wifi-read-only/bin/thermostaat.sh 16'
22:27:13.532 INFO org.openhab.model.script.hvac[:53]- Mail
22:27:15.465 ERROR o.o.action.mail.internal.Mail[:122]- Could not send e-mail to '[email protected]‘.
org.apache.commons.mail.EmailException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1203)
at org.apache.commons.mail.Email.send(Email.java:1266)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:118)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Caused by: javax.mail.MessagingException: Connection failed (java.lang.IllegalArgumentException: port out of range:-1)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:141)
at javax.mail.Service.connect(Service.java:242)
at javax.mail.Service.connect(Service.java:85)
at org.apache.commons.mail.Email.buildMimeMessage(Email.java:1198)
at org.apache.commons.mail.Email.send(Email.java:1266)
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:118)
Caused by: java.lang.IllegalArgumentException: port out of range:-1
at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143)
at java.net.InetSocketAddress.(InetSocketAddress.java:224)
at java.net.Socket.(Socket.java:266)
at org.apache.geronimo.javamail.store.pop3.POP3Connection.getConnectedSocket(POP3Connection.java:215)
at org.apache.geronimo.javamail.store.pop3.POP3Connection.open(POP3Connection.java:89)
at org.apache.geronimo.javamail.store.pop3.POP3Store.protocolConnect(POP3Store.java:139)

@richardcw1
Copy link

Unfortunately I also get sending failure on my linux server.
The rule fires and logs the change in Target Temperature of the Nest, but then fails in the same way...

2016-02-26 17:01:18.326 [INFO ] [org.openhab.model.script.Nest ] - Sanctuary Target Temperature sanctuary_target_temperature_c (Type=NumberItem, State=11)oC
2016-02-26 17:01:18.902 [ERROR] [nhab.action.mail.internal.Mail] - Could not send e-mail to 'myemail@domainname'.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242) ~[commons-email-1.2.jar:1.2]
at org.apache.commons.mail.Email.send(Email.java:1267) ~[commons-email-1.2.jar:1.2]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:121) [bundlefile:na]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:62) [bundlefile:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:729) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._featureCallOperation(XbaseInterpreter.java:713) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) [org.eclipse.xtext.util_2.3.0.v201206120633.jar:na]
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:69) [org.openhab.model.script_1.7.1.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) [org.eclipse.xtext.util_2.3.0.v201206120633.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateBlockExpression(XbaseInterpreter.java:321) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:291) [org.eclipse.xtext.util_2.3.0.v201206120633.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:218) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:204) [org.eclipse.xtext.xbase_2.3.0.v201206120633.jar:na]
at org.openhab.model.script.internal.engine.ScriptImpl.execute(ScriptImpl.java:59) [org.openhab.model.script_1.7.1.jar:na]
at org.openhab.core.scriptengine.ScriptExecutionThread.run(ScriptExecutionThread.java:44) [org.openhab.core.scriptengine_1.7.1.jar:na]
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: Error authenticating with server)
at javax.mail.Transport.send(Transport.java:163) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:48) ~[javax.mail_1.4.0.v201005080615.jar:na]
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232) ~[commons-email-1.2.jar:1.2]
... 32 common frames omitted
Caused by: javax.mail.AuthenticationFailedException: Error authenticating with server
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:402) ~[na:na]
at javax.mail.Service.connect(Service.java:265) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:85) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:70) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:94) ~[javax.mail_1.4.0.v201005080615.jar:na]
... 34 common frames omitted

When I review in my google account, it shows it being blocked, even though I've allowed "less secure" apps.
image

@9037568
Copy link
Contributor

9037568 commented Feb 27, 2016

Appears to be working fine here. Sample debug output below, but email is successfully received in my gmail account.

Probably redundant advice, but double check your credentials in openhab.cfg...

Sending data EHLO computerName<<<<<<
Sending data STARTTLS<<<<<<
Sending data EHLO computerName<<<<<<
Sending data AUTH LOGIN<<<<<<
Sending data hash1<<<<<<
Sending data hash2<<<<<<
Sending data MAIL FROM: [email protected]<<<<<<
Sending data RCPT TO: [email protected]<<<<<<
Sending data DATA<<<<<<
Sending data <<<<<<
Sending data .<<<<<<
Sending data QUIT<<<<<<

@TheKorn2
Copy link

TheKorn2 commented Mar 1, 2016

There's definitely something going on here, but I couldn't tell you why. I went and captured the connection to/from my (private) non-TLS mail server. Openhab sends a HELO but then also sends QUIT for some reason!

dump generated by running on openhab host (assuming it only has one network port):

sudo tcpdump -host (your mail server) -vvXS -w tcpdump_capture_file.cap

then dragging tcpdump_capture_file.cap into wireshark to examine.

I'm no SMTP expert, but wireshark says that openhab is sending three commands in packet 7:

EHLO
HELO
QUIT

When the remote side sees the quit message, it honors the quit request, says bye and closes the connection. (If I manually telnet in, type HELO BLAH, QUIT sure enough it closes the connection.)

Seems as though there's either a missing payload between HELO and QUIT, or sending QUIT is premature.

tcpdump capture file available here, since github insists this isn't a zip file (it is): http://www.thekorn.net/temp/tcpdump_capture_file.zip

@TheKorn2
Copy link

TheKorn2 commented Mar 1, 2016

For reference, here are the mail settings I'm using:

mail:hostname=mail.thekorn.net
mail:port=26
mail:username=(redacted)@thekorn.net
mail:password=(redacted #2)
mail:from=(redacted)@thekorn.net
mail:tls=false
#mail:popbeforesmtp=false
#mail:charset=

@jannegpriv
Copy link
Contributor

I have had gmail sending working previously but now I get the same error as above since 2016-02-23.
I've got gmail from openhab on 2016-02-22:
"[email protected] [email protected]
22 feb.

to me
It's raining! Current rain level is 0.101 mm."

I have since beginning of March upgraded openhab from 1.8.0 to 1.8.2 and moved my openhab installation to a Raspberry PI3 with latest Jessie. I was previously running on a PI2, but this error seems to have started on 2016-02-23 according to logs in my old PI2:

2016-02-23 19:02:15.868 [ERROR] [nhab.action.mail.internal.Mail] - Could not send e-mail to '[email protected]'.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587

A recent log on my PI3 looks like this:

2016-04-03 23:08:02.842 [ERROR] [nhab.action.mail.internal.Mail] - Could not send e-mail to '[email protected]'.
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242) ~[commons-email-1.2.jar:1.2]
at org.apache.commons.mail.Email.send(Email.java:1267) ~[commons-email-1.2.jar:1.2]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:155) [bundlefile:na]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:90) [bundlefile:na]
at org.openhab.action.mail.internal.Mail.sendMail(Mail.java:65) [bundlefile:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
...
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: Error authenticating with server)
at javax.mail.Transport.send(Transport.java:163) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:48) ~[javax.mail_1.4.0.v201005080615.jar:na]
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232) ~[commons-email-1.2.jar:1.2]
... 72 common frames omitted
Caused by: javax.mail.AuthenticationFailedException: Error authenticating with server
at org.apache.geronimo.javamail.transport.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:402) ~[na:na]
at javax.mail.Service.connect(Service.java:265) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:85) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Service.connect(Service.java:70) ~[javax.mail_1.4.0.v201005080615.jar:na]
at javax.mail.Transport.send(Transport.java:94) ~[javax.mail_1.4.0.v201005080615.jar:na]

gmail action settings:

The SMTP server hostname, e.g. "smtp.gmail.com"

mail:hostname=smtp.gmail.com

the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS))

##mail:port=

the username and password if the SMTP server requires authentication

mail:username=[email protected]
mail:password=xxxyyyzzz

The email address to use for sending mails

mail:from=[email protected]

set to "true", if TLS should be used for the connection

(optional, defaults to false)

mail:tls=true

set to "true", if POP before SMTP (another authentication mechanism)

should be enabled. Username and Password are taken from the above

configuration (optional, default to false)

##mail:popbeforesmtp=

Character set used to encode message body

(optional, if not provided platform default is used)

##mail:charset=

When configuring this for the first time I had to change my security settings in my gmail account to allow for less secure apps to connect to my gmail account:
https://support.google.com/accounts/answer/6010255?hl=en

Could it be problems on the gmail side that causes this?

BR,

/Janne

@watou
Copy link
Contributor

watou commented Apr 3, 2016

Could this be similar to what is described here? Please continue discussion there as there are few who would read this issue, and it can likely be resolved there.

hubermi pushed a commit to hubermi/openhab that referenced this issue Jan 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants