# \[SOLVED\] One again a topic: sendmail

**URL:** <https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619>\
**Category:** Actions\
**Created:** [June 18, 2019, 9:07pm UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619 "2019-06-18T21:07:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![franzda](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/85e7bf/32.png) [@franzda](https://community.openhab.org/u/franzda)\
**Post date:** [June 18, 2019, 9:07pm UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619/1 "2019-06-18T21:07:12Z")

</div>

I try to send email via sendMail using @gmail.com and/or @web.de; it does not work.  
what do I have to pay attention to the configuration

(tls / ssl …)  
i mean there is a logic inside the action software because the port is not taken from the mail.cfg file

depending on the mail.cfg i get  
**either:**  
2019-06-18 23:00:01.811 [ERROR] [rg.openhab.action.mail.internal.Mail] - Could not send e-mail to ‘xxx@web.de’.  
org.apache.commons.mail.EmailException: Sending the email to the following server failed : [smtp.gmail.com:465](http://smtp.gmail.com:465)

```
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421) ~[?:?]

```

**or:**

2019-06-18 22:59:01.113 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Nachricht’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object) on instance: null

---

<div class="post-metadata">

**Author:** ![sihui](https://community.openhab.org/user_avatar/community.openhab.org/sihui/32/55674_2.png) [@sihui](https://community.openhab.org/u/sihui)\
**Post date:** [June 19, 2019, 5:08am UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619/2 "2019-06-19T05:08:24Z")

</div>

This is my working config for gmail:

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

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

# the username and password if the SMTP server requires authentication
username=my_email_adress@gmail.com
password=yxyxyxy

# The email address to use for sending mails
from=my_email_adress@gmail.com

# set to "true", if STARTTLS is enabled (not required) for the connection
# (optional, defaults to false)
tls=true

# set to "true", if SSL negotiation should occur on connection
# do not use both tls=true and ssl=true
# (optional, defaults to false)
ssl=false

# 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)
popbeforesmtp=false

# Character set used to encode message body
# (optional, if not provided platform default is used)
#charset=

```

---

<div class="post-metadata">

**Author:** ![franzda](https://community.openhab.org/letter_avatar_proxy/v4/letter/f/85e7bf/32.png) [@franzda](https://community.openhab.org/u/franzda)\
**Post date:** [June 19, 2019, 6:05am UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619/3 "2019-06-19T06:05:12Z")

</div>

Hello. I detected later that the mail server blocked my login with the message. **“unknown device”**.  
I had to confirm that " **yes I was with the login"** and after this everything is running well with this setting.

[hostname=smtp.gmail.com](http://hostname=smtp.gmail.com)  
port=465  
[username=uuuu@gmail.com](mailto:username=uuuu@gmail.com)  
password=pppp  
[from=ffff@gmail.com](mailto:from=ffff@gmail.com)  
#tls=false  
ssl=true  
#popbeforesmtp=false  
#charset=

---

<div class="post-metadata">

**Author:** ![sihui](https://community.openhab.org/user_avatar/community.openhab.org/sihui/32/55674_2.png) [@sihui](https://community.openhab.org/u/sihui)\
**Post date:** [June 19, 2019, 10:10am UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619/4 "2019-06-19T10:10:19Z")

</div>

The initial problem probably is caused because you did not allow “Third Party Apps” in your Gmail account settings.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [June 19, 2019, 2:51pm UTC](https://community.openhab.org/t/solved-one-again-a-topic-sendmail/76619/5 "2019-06-19T14:51:47Z")

</div>

> [@sihui](#):
>
> you did not allow “Third Party Apps” in your Gmail account settings.

It’s also worth noting for future readers of this thread, that if you have two-factor authentication turned on for your Gmail (you really really should) that you will need to create an app password. Go to your Google account page, Security, and App Password. Generate a new password. Don’t lose that password. It is impossible to get it back after you close that screen and you will have to generate a new one.

Use that random string as your password and you can get the safety of using two-factor authentication and still have the ability to send email from openHAB or other services on your machines.
