This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen_1.x. See http://git.chorem.org/pollen_1.x.git commit bd0368e81af4a39351de5dbf3d5837a0dd6adf02 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Nov 8 14:02:16 2014 +0100 fixes #1143: Be able to configure authenticated email sending --- .../org/chorem/pollen/PollenConfiguration.java | 24 ++++++++++++++++++++++ .../chorem/pollen/PollenConfigurationOption.java | 12 +++++++++++ .../i18n/pollen-persistence_en_GB.properties | 4 ++++ .../i18n/pollen-persistence_fr_FR.properties | 4 ++++ .../chorem/pollen/services/impl/EmailService.java | 9 ++++++-- src/site/fr/rst/configure.rst | 6 +++++- src/site/rst/configure.rst | 6 +++++- 7 files changed, 61 insertions(+), 4 deletions(-) diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java b/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java index 6d28e79..8bde13d 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfiguration.java @@ -177,6 +177,30 @@ public class PollenConfiguration { return result; } + public boolean isEmailAuth() { + boolean result = applicationConfig.getOptionAsBoolean( + PollenConfigurationOption.EMAIL_AUTH.key); + return result; + } + + public boolean isEmailAuthSsl() { + boolean result = applicationConfig.getOptionAsBoolean( + PollenConfigurationOption.EMAIL_SSL.key); + return result; + } + + public String getEmailAuthLogin() { + String result = applicationConfig.getOption( + PollenConfigurationOption.EMAIL_AUTH_LOGIN.key); + return result; + } + + public String getEmailAuthPassword() { + String result = applicationConfig.getOption( + PollenConfigurationOption.EMAIL_AUTH_PASSWORD.key); + return result; + } + public String getEmailFrom() { String result = applicationConfig.getOption( PollenConfigurationOption.EMAIL_FROM.key); diff --git a/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java b/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java index 35d7ab8..b113174 100644 --- a/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java +++ b/pollen-persistence/src/main/java/org/chorem/pollen/PollenConfigurationOption.java @@ -66,6 +66,18 @@ public enum PollenConfigurationOption implements ApplicationConfig.OptionDef { /** port for email sending configuration. */ EMAIL_PORT("email_port", n_("pollen.configuration.emailPort"), "25", String.class), + /** flag to use ssl for email sending configuration. */ + EMAIL_SSL("email_ssl", n_("pollen.configuration.emailSsl"), "false", boolean.class), + + /** flag to use auth for email sending configuration. */ + EMAIL_AUTH("email_auth", n_("pollen.configuration.emailAuth"), "false", boolean.class), + + /** login to use if auth at email sending. */ + EMAIL_AUTH_LOGIN("email_auth_login", n_("pollen.configuration.emailAuthLogin"), "", String.class), + + /** password to use if auth at email sending. */ + EMAIL_AUTH_PASSWORD("email_auth_password", n_("pollen.configuration.emailAuthPassword"), "", String.class), + /** from for email sending configuration. */ EMAIL_FROM("email_from", n_("pollen.configuration.emailFrom"), "bot@pollen.org", String.class), diff --git a/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties b/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties index 1b59f84..17f0a9e 100644 --- a/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties +++ b/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties @@ -20,9 +20,13 @@ pollen.configuration.defaultPollType=Default poll type to use at a new poll crea pollen.configuration.defaultPollVoteVisibility=Default vote visibility to use at a new poll creation pollen.configuration.defaultVoteCountingType=Default vote counting type to use at a new poll creation pollen.configuration.emaiDirectory=directory to store emails before sending them +pollen.configuration.emailAuth=Flag to use authenticated user to send emails +pollen.configuration.emailAuthLogin=Login to use to send email if auth is required +pollen.configuration.emailAuthPassword=Password to use to send email if auth is required pollen.configuration.emailFrom=from for email sending configuration pollen.configuration.emailHost=host for email sending configuration pollen.configuration.emailPort=port for email sending configuration +pollen.configuration.emailSsl=flag to use ssl to send emails pollen.configuration.feedDirectory=path for feed directory pollen.configuration.imageDirectory=path for uploaded images directory pollen.configuration.nbVoteByPage=nb votes to display per page diff --git a/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties b/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties index 4380536..c3eec76 100644 --- a/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties +++ b/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties @@ -20,9 +20,13 @@ pollen.configuration.defaultPollType=Type de sondage par défaut à utiliser lor pollen.configuration.defaultPollVoteVisibility=Visibilité des votes par défaut à utiliser lors de la création d'un sondage pollen.configuration.defaultVoteCountingType=Type de dépouillement par défaut à utiliser lors de la création d'un sondage pollen.configuration.emaiDirectory=Répertoire des emails +pollen.configuration.emailAuth=Drapeau pour utiliser un login/password lors de l'envoie des courriels +pollen.configuration.emailAuthLogin=Login de l'utilisateur pour l'authentification lors de l'envoie des courriels +pollen.configuration.emailAuthPassword=Mot de passe de l'utilisateur pour l'authentification lors de l'envoie des courriels pollen.configuration.emailFrom=Email de l'envoyeur dans les emails pollen.configuration.emailHost=Serveur d'envoie d'email pollen.configuration.emailPort=Port du serveur d'envoi d'email +pollen.configuration.emailSsl=Drapeau pour utiliser le transport sll lors de l'envoie des courriels pollen.configuration.feedDirectory=Répertoire des flux rss pollen.configuration.imageDirectory=répertoire où sont enregistrés les images pollen.configuration.nbVoteByPage=Nombre de votes à afficher par page diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java b/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java index 038e4fd..5580935 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/impl/EmailService.java @@ -39,7 +39,6 @@ import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.services.PollenServiceSupport; import org.nuiton.util.StringUtil; -import java.util.Comparator; import java.util.List; import java.util.Locale; @@ -296,8 +295,14 @@ public class EmailService extends PollenServiceSupport { email.setHostName(configuration.getEmailHost()); email.setSmtpPort(configuration.getEmailPort()); + email.setSSLOnConnect(configuration.isEmailAuthSsl()); email.setFrom(configuration.getEmailFrom()); email.setCharset(configuration.getCharset()); + if (configuration.isEmailAuth()) { + String authUsername = configuration.getEmailAuthLogin(); + String authPassword = configuration.getEmailAuthPassword(); + email.setAuthentication(authUsername, authPassword); + } email.addTo(to); email.setSubject(subject); @@ -326,7 +331,7 @@ public class EmailService extends PollenServiceSupport { return new PollenEmail(to, subject, content); } - public static class PollenEmail implements Comparable<PollenEmail>{ + public static class PollenEmail implements Comparable<PollenEmail> { protected String subject; diff --git a/src/site/fr/rst/configure.rst b/src/site/fr/rst/configure.rst index 8f1f1be..952d547 100644 --- a/src/site/fr/rst/configure.rst +++ b/src/site/fr/rst/configure.rst @@ -65,6 +65,10 @@ configuration: email_host= Serveur smtp pour envoyer les emails email_port= Port du serveur smtp email_from= Adresse de l'envoyeur de mail + email_ssl=false|true (pour utiliser le transport ssl) + email_auth=false|true (pour utiliser un login/password d'authentification) + email_auth_login=Login de l'utilisateur pour l'authentification (utilisé uniquement si email_auth=true) + email_auth_password=Mot de passe de l'utilisateur pour l'authentification (utilisé uniquement si email_auth=true) Configurer la base de données ----------------------------- @@ -101,4 +105,4 @@ Voici un tableau des propriétés pour les bases usuelles: | MySql | org.hibernate.dialect.MySQLDialect | com.mysql.jdbc.Driver | jdbc:mysql:pollen | +-------------------------+------------------------------------------+-----------------------------------+------------------------------------------+ -.. _page des options: ./config-report.html +.. _page des options: ./application-config-report.html diff --git a/src/site/rst/configure.rst b/src/site/rst/configure.rst index e9b1357..0b4b113 100644 --- a/src/site/rst/configure.rst +++ b/src/site/rst/configure.rst @@ -62,6 +62,10 @@ So that Pollen can send emails you must fill in the following configuration: email_host= Smtp server address (ex: localhost, smtp.free.fr, ...) email_port= Smtp server port (by default: 25) email_from= Mail sender address (ex: mypolleninstance@me.com) + email_ssl=false|true (to use ssl transport layer) + email_auth=false|true (to use a login/password authentication) + email_auth_login=Login for authentication (only used if email_auth=true) + email_auth_password=Password for authentication (only used if email_auth=true) Configure database ------------------ @@ -96,4 +100,4 @@ Here are the properties for usual databases: | MySql | org.hibernate.dialect.MySQLDialect | com.mysql.jdbc.Driver | jdbc:mysql:pollen | +-------------------------+------------------------------------------+-----------------------------------+------------------------------------------+ -.. _options page: ./config-report.html +.. _options page: ./application-config-report.html -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.