wiki:MolgenisEmail

Version 2 (modified by Morris Swertz, 15 years ago) (diff)

--

Emaling from within your MOLGENIS application

Since 3.4.x

Set your email settings in 'molgenis.properties'

See MolgenisProperties?.

###############################################################
# 3. EMAIL settings if you want to email from within MOLGENIS plugins
# If you use smpts you may need to certify that you trust the server
# see http://blogs.sun.com/andreas/entry/no_more_unable_to_find
###############################################################

mail_smtp_from = noreply@molgenis.org
mail_smtp_protocol = smtps 
# protocol is either smtp or smtps
mail_smtp_hostname = smtp.gmail.com
mail_smtp_port = 587
mail_smtp_user = molgenis
mail_smtp_password = molgenispass

Add the following code to your plugin

Inside your plugin you can use 'getEmailService()' to get access to the mail system. For example:

String from    = "test@myserver.org";
String to      = "myfriend@anotherserver.org";
String message = "Dear Mr. X. We welcome you to read our first email.";
this.getEmailService().email(from, message, to);