Question

I have developed a spring Java Mail application in my project.I have configured my company mail server name in Spring.xml file. I am using JavaMailSenderImpl.

My spring.xml

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> 
 <property name="host" value="smtp.mycomp.com"/> 
</bean>

in my java class

public class ServiceEmail {

           public JavaMailSender getMailSender() {
            return mailSender;
        }

        @Autowired
        @Required
        public void setMailSender(JavaMailSender mailSender) {
            this.mailSender = mailSender;

             message.setTo("example@gmail.com");
         message.setFrom(fromEmailAddress);

             try{
                this.mailSender.send(preparator);
               }catch(MailException e){

                   e.printstacktrac();

}
}

}

But when I use this I am not able to send any mails to gmail or any other mail cllients it's failing with relaying denied exception. But it's working well with my internal server.Is it my mail server Issue or Do i need to configure for each and every email client.How can configure this to work all the mail clients.Can I configure in XML file?

Was it helpful?

Solution

This JavaMail FAQ entry should help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top