Skip to content

Commit

Permalink
[mail] Correctly named STARTTLS and a few small improvements (openhab…
Browse files Browse the repository at this point in the history
…#7292)

* Correctly name STARTTLS and a few small improvements

Signed-off-by: Kai Kreuzer <[email protected]>
Signed-off-by: Eugen Freiter <[email protected]>
  • Loading branch information
kaikreuzer authored and Eugen Freiter committed Apr 27, 2020
1 parent a074eb5 commit f61b0de
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
18 changes: 9 additions & 9 deletions bundles/org.openhab.binding.mail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ There are three things: `smtp`, `imap` and `pop3` which represents respective se

## Thing Configuration

### SMTP server (`smtp`)
### SMTP Server (`smtp`)

There are two mandatory parameters `hostname` and `sender`.

Expand All @@ -17,13 +17,13 @@ The `sender` must be a valid mail address used as sender address for mails.

The `security`, `port`, `username` and `password` parameters are optional.

The `security` parameter defines the transport security and can be set to `PLAIN` (default), `SSL` or `TLS`.
The `security` parameter defines the transport security and can be set to `PLAIN` (default), `STARTTLS` or `SSL` (for implicit SSL/TLS).
The `port` parameter is used to change the default ports for the SMTP server.
Default ports are `25` (for `PLAIN` and `TLS`) and `465` (for `SSL`).
Default ports are `25` (for `PLAIN` and `STARTTLS`) and `465` (for `SSL`).
For authentication, `username` and `password` can be supplied.
If one or both are empty, no authentication data is provided to the SMTP server during connect.

### IMAP server (`imap`) / POP3 server (`pop3`)
### IMAP Server (`imap`) / POP3 Server (`pop3`)

There is one mandatory parameter: `hostname`, `username`, `password`.
The `hostname` may contain an IP address or a FQDN like `mail.gmail.com`.
Expand All @@ -33,9 +33,9 @@ The `refresh`, `security`, `port`, `username` and `password` parameters are opti

The `refresh` parameter is the time in seconds between two refreshes of the thing's channels.
If omitted, the default of 60s is used.
The `security` parameter defines the transport security and can be set to `PLAIN` (default), `SSL` or `TLS`.
The `security` parameter defines the transport security and can be set to `PLAIN` (default), `STARTTLS` or `SSL` (for implicit SSL/TLS).
The `port` parameter is used to change the default ports for the SMTP server.
Default ports are `143` (for `PLAIN` and `TLS`) and `993` (for `SSL`) in the case of `imap` or `110` (for `PLAIN` and `TLS`) and `995` (for `SSL`) in the case of `pop3`.
Default ports are `143` (for `PLAIN` and `STARTTLS`) and `993` (for `SSL`) in the case of `imap` or `110` (for `PLAIN` and `STARTTLS`) and `995` (for `SSL`) in the case of `pop3`.

## Channels

Expand All @@ -55,7 +55,7 @@ Channels with type `UNREAD` give the number on unread mails in that folder.
mail.things:

```
Thing mail:smtp:samplesmtp [ hostname="smtp.example.com", sender="[email protected]", security="TLS", username="user", password="pass" ]
Thing mail:smtp:samplesmtp [ hostname="smtp.example.com", sender="[email protected]", security="SSL", username="user", password="pass" ]
Thing mail:imap:sampleimap [ hostname="imap.example.com", security="SSL", username="user", password="pass" ] {
Channels:
Expand Down Expand Up @@ -85,7 +85,7 @@ sitemap demo label="Main Menu"

## Rule Action

This binding includes rule actions for sending mail.
This binding includes rule actions for sending email.
Six different actions available:

* `sendMail(String recipient, String subject, String text)`
Expand All @@ -104,7 +104,7 @@ Since there is a separate rule action instance for each `smtp` thing, this needs
The first parameter always has to be `mail` and the second is the full Thing UID of the SMTP server that should be used.
Once this action instance is retrieved, you can invoke the action method on it.

Please note: all strings are expected to be UTF-8 encoded.
Please note: All strings are expected to be UTF-8 encoded.
Using different character sets may produce unwanted results.

Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static boolean sendMail(@Nullable ThingActions actions, @Nullable String
logger.warn("Could not send mail: {}", e.getMessage());
return false;
} catch (EmailException e) {
logger.warn("could not send mail: {}", e.getMessage());
logger.warn("Could not send mail: {}", e.getMessage());
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean sendMail(Email mail) {
mail.setSSLOnConnect(true);
mail.setSslSmtpPort(config.port.toString());
break;
case TLS:
case STARTTLS:
mail.setStartTLSEnabled(true);
mail.setStartTLSRequired(true);
mail.setSmtpPort(config.port);
Expand All @@ -95,7 +95,10 @@ public boolean sendMail(Email mail) {
}
mail.send();
} catch (EmailException e) {
logger.warn("Trying to send mail but exception occured: {} ", e.getMessage());
logger.warn("{}", e.getMessage());
if (e.getCause() != null) {
logger.warn("{}", e.getCause().toString());
}
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
public enum ServerSecurity {
PLAIN,
SSL,
TLS
STARTTLS
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">

<name>Mail Binding</name>
<description>Email support</description>
<description>This binding is used to access POP3, IMAP and SMTP servers.</description>
<author>Jan N. Klug</author>

</binding:binding>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# binding
binding.mail.name = Mail Binding
binding.mail.description = E-Mail Unterstützung
binding.mail.description = Unterstützung von POP3, IMAP und SMTP Servern

# thing types
thing-type.mail.smtp.label = SMTP Server
Expand All @@ -10,22 +10,22 @@ thing-type.config.mail.smtp.sender.description = Standard-Absender f
thing-type.config.mail.smtp.hostname.label = IP-Adresse
thing-type.config.mail.smtp.hostname.description = IP-Adresse oder Hostname des SMTP Servers
thing-type.config.mail.smtp.port.label = Port
thing-type.config.mail.smtp.port.description = Standard Ports sind 25 für PLAIN/TLS und 465 für SSL
thing-type.config.mail.smtp.security.label = Sicherheits-Protokoll
thing-type.config.mail.smtp.security.description = Server Sicherheits-Protokoll zur Kommunikation mit dem SMPT Server
thing-type.config.mail.smtp.port.description = Standard Ports sind 25 für PLAIN/STARTTLS und 465 für SSL/TLS
thing-type.config.mail.smtp.security.label = Sicherheitsprotokoll
thing-type.config.mail.smtp.security.description = Server Sicherheitsprotokoll zur Kommunikation mit dem SMTP Server
thing-type.config.mail.smtp.username.label = Benutzer
thing-type.config.mail.smtp.username.description = Benutzer zur Authentifizierung am SMPT Server
thing-type.config.mail.smtp.username.description = Benutzer zur Authentifizierung am SMTP Server
thing-type.config.mail.smtp.password.label = Passwort
thing-type.config.mail.smtp.password.description = Passwort zur Authentifizierung am SMPT Server
thing-type.config.mail.smtp.password.description = Passwort zur Authentifizierung am SMTP Server

thing-type.mail.imap.label = IMAP Server
thing-type.mail.imap.description = IMAP Postfach Überwachung
thing-type.config.mail.imap.hostname.label = IP-Adresse
thing-type.config.mail.imap.hostname.description = IP-Adresse oder Hostname des IMAP Servers
thing-type.config.mail.imap.port.label = Port
thing-type.config.mail.imap.port.description = Standard Ports sind 143 für PLAIN/TLS und 993 für SSL
thing-type.config.mail.imap.security.label = Sicherheits-Protokoll
thing-type.config.mail.imap.security.description = Server Sicherheits-Protokoll zur Kommunikation mit dem IMAP Server
thing-type.config.mail.imap.port.description = Standard Ports sind 143 für PLAIN/STARTTLS und 993 für SSL/TLS
thing-type.config.mail.imap.security.label = Sicherheitsprotokoll
thing-type.config.mail.imap.security.description = Server Sicherheitsprotokoll zur Kommunikation mit dem IMAP Server
thing-type.config.mail.imap.username.label = Benutzer
thing-type.config.mail.imap.username.description = Benutzer zur Authentifizierung am IMAP Server
thing-type.config.mail.imap.password.label = Passwort
Expand All @@ -38,9 +38,9 @@ thing-type.mail.pop3.description = POP3 Postfach
thing-type.config.mail.pop3.hostname.label = IP-Adresse
thing-type.config.mail.pop3.hostname.description = IP-Adresse oder Hostname des POP3 Servers
thing-type.config.mail.pop3.port.label = Port
thing-type.config.mail.pop3.port.description = Standard Ports sind 110 für PLAIN/TLS und 995 für SSL
thing-type.config.mail.pop3.security.label = Sicherheits-Protokoll
thing-type.config.mail.pop3.security.description = Server Sicherheits-Protokoll zur Kommunikation mit dem POP3 Server
thing-type.config.mail.pop3.port.description = Standard Ports sind 110 für PLAIN/STARTTLS und 995 für SSL/TLS
thing-type.config.mail.pop3.security.label = Sicherheitsprotokoll
thing-type.config.mail.pop3.security.description = Server Sicherheitsprotokoll zur Kommunikation mit dem POP3 Server
thing-type.config.mail.pop3.username.label = Benutzer
thing-type.config.mail.pop3.username.description = Benutzer zur Authentifizierung am POP3 Server
thing-type.config.mail.pop3.password.label = Passwort
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="mail"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<thing-type id="smtp">
<label>SMTP Server</label>
<description>Used for sending mail via rule-actions</description>
<description>Used for sending emails via rule actions</description>
<config-description>
<parameter name="sender" type="text" required="true">
<label>Sender</label>
Expand All @@ -16,15 +17,15 @@
</parameter>
<parameter name="port" type="text" required="false">
<label>Server Port</label>
<description>Default values are 25 for plain/TLS and 465 for SSL</description>
<description>Default values are 25 for plain/STARTTLS and 465 for SSL/TLS</description>
<advanced>true</advanced>
</parameter>
<parameter name="security" type="text" required="false">
<label>SMTP Server Security Protocol</label>
<options>
<option value="PLAIN">plain</option>
<option value="SSL">SSL</option>
<option value="TLS">TLS</option>
<option value="STARTTLS">STARTTLS</option>
<option value="SSL">SSL/TLS</option>
</options>
<limitToOptions>true</limitToOptions>
<default>PLAIN</default>
Expand All @@ -40,22 +41,22 @@
</thing-type>
<thing-type id="imap" extensible="mailcount">
<label>IMAP Server</label>
<description>Used for receiving mail</description>
<description>Used for receiving emails</description>
<config-description>
<parameter name="hostname" type="text" required="true">
<label>Server Hostname</label>
</parameter>
<parameter name="port" type="text" required="false">
<label>Server Port</label>
<description>Default values are 143 for plain/TLS and 993 for SSL</description>
<description>Default values are 143 for plain/STARTTLS and 993 for SSL/TLS</description>
<advanced>true</advanced>
</parameter>
<parameter name="security" type="text" required="false">
<label>SMTP Server Security Protocol</label>
<options>
<option value="PLAIN">plain</option>
<option value="SSL">SSL</option>
<option value="TLS">TLS</option>
<option value="STARTTLS">STARTTLS</option>
<option value="SSL">SSL/TLS</option>
</options>
<limitToOptions>true</limitToOptions>
<default>PLAIN</default>
Expand All @@ -75,22 +76,22 @@
</thing-type>
<thing-type id="pop3" extensible="mailcount">
<label>POP3 Server</label>
<description>Used for receiving mail</description>
<description>Used for receiving emails</description>
<config-description>
<parameter name="hostname" type="text" required="true">
<label>Server Hostname</label>
</parameter>
<parameter name="port" type="text" required="false">
<label>Server Port</label>
<description>Default values are 110 for plain/TLS and 995 for SSL</description>
<description>Default values are 110 for plain/STARTTLS and 995 for SSL/TLS</description>
<advanced>true</advanced>
</parameter>
<parameter name="security" type="text" required="false">
<label>SMTP Server Security Protocol</label>
<options>
<option value="PLAIN">plain</option>
<option value="SSL">SSL</option>
<option value="TLS">TLS</option>
<option value="STARTTLS">STARTTLS</option>
<option value="SSL">SSL/TLS</option>
</options>
<limitToOptions>true</limitToOptions>
<default>PLAIN</default>
Expand All @@ -112,8 +113,8 @@
<channel-type id="mailcount">
<item-type>Number</item-type>
<label>Mail Count</label>
<description>Number of mails in folder</description>
<state readOnly="true" />
<description>Number of emails in folder</description>
<state readOnly="true"/>
<config-description>
<parameter name="folder" type="text" required="true">
<label>Folder Name</label>
Expand Down

0 comments on commit f61b0de

Please sign in to comment.