mail cover picture 2darray

How about setting up an automated mail sender application which sends the birthday and anniversary mails to the employees in your organization ? It will be awesome right!!!! Let’s find out how to make it happen.

The GitHub Link :

I have written an application in my free time to send birthday and anniversary mails to our colleagues. You can use it too as I have made it completely open source licensed under Apache-v2.0. Here is the complete link of the source code from GitHub.

The Hello-World Application

Requirements :

  • CentOS Linux Recommended for hosting the application
  • MariaDB to store the configurations and email contents
  • JDK 1.8
  • JavaMail (Or you can configure your own SMTP server)

Features :

  • All the configurations are in Database. Any configuration change is picked up quickly by the application.
  • Configurable email templates
  • Free-marker support.
  • Add multiple probable mail content and the application will select one of them randomly.

Installation Instructions :

  • Download the source from the above link
  • Build the application by running the command –
$ mvn clean package
  • Run in background – 
$ nohup java -jar /home/centos/hello-world-0.0.1-SNAPSHOT.jar > /var/log/hello-world/hello-world.log &
  • Checking detailed log –
$ tail -f /var/log/hello-world/hello-world.log

Application Properties :

As this is a Spring Boot Application, below is the application properties that you will need to configure the Data Source, Logging and the SMTP Mail Server. Note that, if you don’t have a SMTP mail server, this application can also run on JavaMail dependency.

logging.level.org.springframework=INFO
logging.level.se.seamless.sfo=DEBUG
logging.file=/var/log/hello-world/hello-world.log
logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%


# Spring DataSource properties
spring.datasource.url=jdbc:mysql://0.0.0.0:3306/HELLO_WORLD?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true


############# MAIL CONFIGURATION ##############
#spring.mail.host=smtp.gmail.com
#spring.mail.port=587
#[email protected]
#spring.mail.password=###########
#spring.mail.properties.mail.smtp.auth=true
#spring.mail.properties.mail.smtp.starttls.enable=true

Running the Birthday and Anniversary Mail Sender :

Once you complete setup the configuration, it is recommended to start your application in background in a server. To run the application you need to fire the below command from your terminal.

java -jar hello-world.jar --spring.config.location=<link to your customized properties file>

More details about the application and all the configuration for setting up is provided in the README file of the GitHub Repository.

I hope this application will bring some smiles to your colleagues when they will receive those greetings on their Birthdays and Work Anniversaries.

Check out my other articles on Miscellaneous category.

LEAVE A REPLY

Please enter your comment!
Please enter your name here