Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

simple-java-mail

This is a simple java library that helps you to send emails from your java projects.

Visitor Count

Installation

Just download the required version of jar from releases and add .jar file to project build path

Usage

You need to implement MailAuth interface.

packageio.github.itsmrajesh.samplemail;
publicinterfaceMailAuth {
StringgetHostMailAddress();
StringgetHostPassword();
}
importio.github.itsmrajesh.samplemail.MailAuth;;
publicclassMyMailAuthimplementsMailAuth {
@OverridepublicStringgetHostmailaddress() {
return"example@gmail.com";
}
@OverridepublicStringgetHostpassword() {
return"mysecret@apppassword"; // your password 
}
}

After implmenting MailAuth interface, you need invoke following method MailService.sendMail and pass the all parameters to sendMail method.

//create object for newly implemented class and pass it in following methodMailAuthmailAuth = newMyMailAuth(); booleanstatus = MailService.sendMail(MailAuthmailAuth, StringrecipientMailAddress, StringmailSubject, Stringmessage);

status will be true when your mail sent is successfully.

Example

importio.github.itsmrajesh.samplemail.MailAuth;
publicclassSimpleMailAppTester {
publicstaticvoidmain(String[] args) {
MailAuthmailAuth = newMyMailAuth();
StringrecipientMailAddress = "example@gmail.com";
StringmailSubject = "Thank You-Simple Mail"; // This is your mail subjectStringmessage = "Hello User, <br> <h4>Thanks for using our services.</h4> <br> <br> Thank You, <br> Team Simple Mail.";
System.out.println("Please wait while we send your mail.");
booleanmailStatus = SimpleMailService.sendMail(mailAuth, recipientMailAddress, mailSubject, message);
if (mailStatus) {
System.out.println("Mail Sent Successfully!");
} else {
System.out.println("Failed in sending mail.");
}
} // End of main method
} // End of Class

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

This is a simple java library that helps you to send emails from java.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages