Skip to content

Commit

Permalink
Added more documentation, more error messages and an example configur…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
Wolfgang Apolinarski committed Jul 26, 2017
1 parent 21ead28 commit af738f5
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# Mail2Slack
A small service that sends e-mails to slack.

## Requirements
* Currently only supports Gmail.

## Build Requirements
* Java 8
* Maven

## Configuration
See src/main/resources/settings.sample.conf for an example configuration file.
## Other
New features (individual icons, more configuration settings) will be added gradually.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
Expand Down
40 changes: 40 additions & 0 deletions src/assembly/bin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>release</id>
<formats>
<format>tar.gz</format>
<format>zip</format>
</formats>

<fileSets>
<fileSet>
<includes>
<include>README*</include>
<include>pom.xml</include>
</includes>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>**/*.class</include>
<include>/*.sample.conf</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/java</directory>
<outputDirectory>src</outputDirectory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet>
<directory>target</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>Mail2Slack-*SNAPSHOT.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ public void readAndPost()
LocalDate maxDate = date.plusDays(settings.getDeleteOldMesagesDays());
if(LocalDate.now().isAfter(maxDate))
{
System.err.println("Deleted mail that is older than 14 days.");
message.setFlag(Flag.DELETED, true);
}
continue;
}
String channel = extractChannel(message.getSubject());
if(channel==null)
{
System.err.println("Channel is invalid: "+message.getSubject());
message.setFlag(Flag.DELETED, true);
continue;
}
Expand All @@ -71,6 +73,7 @@ public void readAndPost()
InternetAddress[] userNameAddress=(InternetAddress[]) message.getFrom();
if(userNameAddress==null || userNameAddress.length==0 || userNameAddress[0]==null)
{
System.err.println("No valid user name address!");
message.setFlag(Flag.DELETED, true);
continue;
}
Expand All @@ -81,6 +84,7 @@ public void readAndPost()
userName = userNameAddress[0].getAddress();
if(userName==null)
{
System.err.println("No valid user name!");
message.setFlag(Flag.DELETED, true);
continue;
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/settings.sample.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This is a configuration file for the Mail2Slack server application


# SECURITY = [STARTTLS|TLS|NONE]
SECURITY = STARTTLS

# USERNAME = me@example.com
# PASSWORD = <PASSWORD>

# RELEVANT-FOLDER - the folder that should be searched for new messages
RELEVANT-FOLDER = inbox

# DELETE-OLD-MESSAGES-AFTER-DAYS = [<DAYS>|0<NEVER>|-1<AS_SOON_AS_SENT>]
DELETE-OLD-MESSAGES-AFTER-DAYS = 14

# IMAP-Settings:
# IMAP-SERVER = imap.example.com
IMAP-SERVER = imap.gmail.com

# IMAP-PROTOCOL = [IMAPS]
IMAP-PROTOCOL = IMAPS

# Settings that are not used:
# SMTP-SERVER = smtp.example.com
SMTP-SERVER = smtp.gmail.com
# SMTP-PORT = <PORT_NUMBER>
SMTP-PORT = 587

SLACK-HOOK-URL = https://hooks.slack.com/services/<URL>

0 comments on commit af738f5

Please sign in to comment.