Sunday, October 4, 2015

Configuring JavaMailSenderImpl for SSL as a Spring bean and with Spring Integration

Because my Window's Firewall blocked all outgoing requests on port 587, I had no option but to configure my JavaMailSenderImpl to use SSL instead of TLS. Below are the bean settings.

<beans:bean id="mailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<beans:property name="username" value="your_mail@gmail.com" />
<beans:property name="password" value="your_mail" />
<beans:property name="protocol" value="smtp"/>
<beans:property name="port" value="465" />
<beans:property name="host" value="smtp.gmail.com" />
<beans:property name="javaMailProperties">
<beans:props>
 <beans:prop key="mail.smtp.ssl.enable">true</beans:prop>      
 <beans:prop key="mail.smtp.auth">true</beans:prop>    
         <beans:prop
                          key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</beans:prop>
       <beans:prop key="mail.smtp.auth">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>


@Autowired
@Qualifier("mailSender")
private JavaMailSender javaMailSender;

@Override
public void sendAnmeldung(Message message) throws Exception {

    MimeMessage mimemsg = javaMailSender.createMimeMessage();   
    MimeMessageHelper helper = new MimeMessageHelper(mimemsg, true);
        
     helper.setTo("your_recipient@gmail.com");
     helper.setFrom("your_account@gmail.com");
     helper.setText(String.format("Javamail using spring JavaMailSender: %s",  Calendar.getInstance().getTime()));
     helper.setSubject("test email");

      this.javaMailSender.send(mimemsg);

}

The above settings can be used with Spring Integration's out-bound-channel-adapter as follows (of course the prefixes util and int-mail must be bound to their appropriate namespaces properly):

<util:properties id="javaMailProps">
<beans:prop key="mail.smtp.ssl.enable">true</beans:prop>      
<beans:prop key="mail.smtp.auth">true</beans:prop>    
<beans:prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</beans:prop>
<beans:prop key="mail.smtp.auth">true</beans:prop>
</util:properties>
 
<int-mail:outbound-channel-adapter id="mails" 
host="smtp.gmail.com"
java-mail-properties="javaMailProps"
password="your_password"
port="465"
                username="your_username@gmail.com"/>

Thursday, October 1, 2015

InstallShield's InstallScript debugger stops working

If you find that your InstallShield's (2014 Premier Version) InstallScript debugger unexpectedly stopped working, then check your MSI project's build settings (Build->Settings) and make sure that the MisExec.EXE Command-Line Argument's edit box is completely empty (As shown below).

After selecting various Log File Options, my debugger stopped working and it wasn't until I COMPLETELY cleared the options that it started working again.