[VIVO-1230] Make contact form compatible with SMTP relays
This commit is contained in:
parent
1493711434
commit
4df281bcd2
1 changed files with 12 additions and 4 deletions
|
@ -12,6 +12,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.SendFailedException;
|
||||
|
@ -256,13 +257,13 @@ public class ContactMailController extends FreemarkerHttpServlet {
|
|||
MimeMessage msg = new MimeMessage( s );
|
||||
//System.out.println("trying to send message from servlet");
|
||||
|
||||
// Set the from address
|
||||
// Set the reply address
|
||||
try {
|
||||
msg.setFrom( new InternetAddress( webuseremail, webusername ));
|
||||
msg.setReplyTo( new Address[] { new InternetAddress( webuseremail, webusername ) } );
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("Can't set message sender with personal name " + webusername +
|
||||
log.error("Can't set message reply with personal name " + webusername +
|
||||
" due to UnsupportedEncodingException");
|
||||
msg.setFrom( new InternetAddress( webuseremail ) );
|
||||
// msg.setFrom( new InternetAddress( webuseremail ) );
|
||||
}
|
||||
|
||||
// Set the recipient address
|
||||
|
@ -272,6 +273,13 @@ public class ContactMailController extends FreemarkerHttpServlet {
|
|||
}
|
||||
msg.setRecipients( Message.RecipientType.TO, address );
|
||||
|
||||
// Set the from address
|
||||
if (address != null && address.length > 0) {
|
||||
msg.setFrom(address[0]);
|
||||
} else {
|
||||
msg.setFrom( new InternetAddress( webuseremail ) );
|
||||
}
|
||||
|
||||
// Set the subject and text
|
||||
msg.setSubject( deliveryfrom );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue