javasmtpappfuse

Why is appfuse not sending emails? (SMTPSendFailedException)


I used the appfuse quickstart to create a basic Spring MVC project.

mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring-archetype -DarchetypeVersion=3.0.0 -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository=http://oss.sonatype.org/content/repositories/appfuse 

I signed up at https://mailtrap.io (a fake smtp service). I edited the mail.properties file with the mailtrap credentials:

mail.default.from=AppFuse <appfuse@raibledesigns.com>
mail.host=mailtrap.io
mail.username=199******d30ac
mail.password=ca8******aae39

I launched the app and tried to register a new user, but I got:

ERROR [qtp8455718-31] MailEngine.send(78) | Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.1 Authentication required

I double checked the credentials and I'm sure they are correct.

I googled and found the source code for MailEngine, it looks like a wrapper around org.springframework.mail.MailSender.

I'm a bit dissapointed, I thought appfuse was supposed to work out of the box.


Solution

  • Make sure you've properly edited (see comments in bold) the following section in applicationContext-service.xml file as too:

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
       <property name="host" value="${mail.host}"/>
       <property name="defaultEncoding" value="UTF-8"/>
       <!-- Uncomment if you need to authenticate with your SMTP Server -->
       <!--property name="username" value="${mail.username}"/>
       <property name="password" value="${mail.password}"/>
       <property name="javaMailProperties">
           <value>
            mail.smtp.auth=true
           </value>
        </property-->

    </bean>

    hope that helps.