Announcement Announcement Module
Collapse
No announcement yet.
Spring Mail - UnsupportedOperationException: Method not yet implemented Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Mail - UnsupportedOperationException: Method not yet implemented

    After reading on the forums and spring documentation I tried to send mail using gmail

    <code>
    <bean id="mailSender"
    class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="host" value="smtp.gmail.com" />
    <property name="port" value="465" />
    <property name="protocol" value="smtps" />
    <property name="username" value="[email protected]" />
    <property name="password" value="password" />
    <property name="javaMailProperties">
    <props>
    <prop key="mail.smtps.auth">true</prop>
    <prop key="mail.smtps.starttls.enable">true</prop>
    <prop key="mail.smtps.debug">true</prop>
    </props>
    </property>
    </bean>

    <bean id="templateMessage"
    class="org.springframework.mail.SimpleMailMessage" >
    <property name="from" value="[email protected]" />
    <property name="subject" value="Your Subject" />
    </bean>


    </code>

    But I get following method not found error when i try to send mail

    Exception in thread "main" java.lang.UnsupportedOperationException: Method not yet implemented
    at javax.mail.internet.MimeMessage.<init>(MimeMessage .java:89)
    at org.springframework.mail.javamail.SmartMimeMessage .<init>(SmartMimeMessage.java:52)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.createMimeMessage(JavaMailSenderImpl.java:315)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.send(JavaMailSenderImpl.java:294)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.send(JavaMailSenderImpl.java:284)
    at scrapebook.SimpleOrderManager.placeOrder(SimpleOrd erManager.java:33)
    at scrapebook.SimpleOrderManager.main(SimpleOrderMana ger.java:47)


    <code>
    private MailSender mailSender;
    private SimpleMailMessage templateMessage;

    public void setMailSender(MailSender mailSender) {
    this.mailSender = mailSender;
    }

    public void setTemplateMessage(SimpleMailMessage templateMessage) {
    this.templateMessage = templateMessage;
    }

    public void placeOrder(Employee employee) {

    // Create a thread safe "copy" of the template message and customize it
    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
    msg.setTo(employee.getPrimaryAddress().getEmail()) ;
    msg.setText(
    "Dear " + employee.getFirstName()
    + employee.getLastName()
    + ", thank you for placing order. Your order number is 456 "
    );
    try{
    this.mailSender.send(msg);
    }
    catch(MailException ex) {
    // simply log it and go on...
    System.err.println(ex.getMessage());
    }
    }

    public static void main(String[] args) {
    OrderManager orderManager = (OrderManager)BeanHelper.getBean("orderManager");
    Employee employee = new Employee();
    employee.setFirstName("Eric");
    employee.setLastName("euler");
    employee.getPrimaryAddress().setEmail("singhjess@g mail.com");
    orderManager.placeOrder(employee);
    }
    </code>

  • #2
    Hi,

    Did you get any resolution to this? I am also facing the same issue.

    Thanks.

    Comment


    • #3
      Conflicting dependency?

      I recently ran into this error relating to SimpleMailMessage sending via JavaMailSenderImpl. The root cause in my case was due to the addition of a few new dependencies in the POM. One of the dependency pulled in an older or conflicting class. Removing the dependency (in this case, I wasn't quite ready to leverage the added dependency) causes the error to go away.

      Possibly need to exclude something in the dependency before I can bring it back in.

      Hope that helps.

      Comment

      Working...
      X