Skip to content

Commit

Permalink
Update EmailMessage.java
Browse files Browse the repository at this point in the history
in order to use the port specified in server settings
  • Loading branch information
greensi committed Oct 5, 2014
1 parent 3fcd5a6 commit 95d5024
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions BimServer/src/org/bimserver/mail/EmailMessage.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package org.bimserver.mail;

/******************************************************************************
* Copyright (C) 2009-2014 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

package org.bimserver.mail;

/******************************************************************************
* Copyright (C) 2009-2014 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

import java.util.Properties;

import javax.mail.Message;
Expand Down Expand Up @@ -55,6 +55,12 @@ public EmailMessage(BimServer bimServer) {
public void send() throws MessagingException {
Properties props = new Properties();
ServerSettings serverSettings = bimServer.getServerSettingsCache().getServerSettings();

//in order to use the port specified in server settings.
String smtpProps = serverSettings.getSmtpProtocol() == SmtpProtocol.SMTPS ? "mail.smtps.port" : "mail.smtp.port";
props.put(smtpProps, serverSettings.getSmtpPort();


props.put("mail.smtp.localhost", "bimserver.org");
Session mailSession = Session.getDefaultInstance(props);

Expand Down Expand Up @@ -100,4 +106,4 @@ public void setRecipients(RecipientType to, InternetAddress[] addressTo) {
public void setFrom(InternetAddress from) {
this.from = from;
}
}
}

0 comments on commit 95d5024

Please sign in to comment.