Announcement Announcement Module
No announcement yet.
overriding SimpleMailMessage template config? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • overriding SimpleMailMessage template config?

    I have a web application that includes a form mailer feature wherein a user can enter his email address and his recipients' address as well, which should reflect on the delivered message. It successfully sends messages but my problem is that the sender's email address, instead of displaying my site's domain, always display my Gmail account address, which is only used for authenticating the SMTP.

    In applicationContext-mail.xml
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>

        <bean id="emailManager" class="">
          <property name="mailSender" ref="mailSender"/>
          <property name="templateMessage" ref="templateMessage"/>
        <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
          <property name="host" value=""/>
          <property name="port" value="465"/>
          <property name="protocol" value="smtps"/>
          <property name="username" value="[email protected]"/>
          <property name="password" value="xxx"/>
          <property name="javaMailProperties">
              <prop key="mail.smtps.auth">true</prop>
              <prop key="mail.smtps.starttls.enable">true</prop>
              <prop key="mail.smtps.debug">true</prop>
        <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage">
          <property name="from" value="[email protected]"/>
          <property name="to" value="[email protected]"/>

    The specific module in
    PHP Code:
    public void sendReferral(ReferralForm form) {
    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);

    msg.setFrom(form.getSenderEmail()); // It doesn't seem to override the template >_<
    msg.setTo(form.getRecipientEmail()); // But the setTo and the others do...

        } catch(
    MailException mex) {

    Any ideas, guys?
    Last edited by keiko; Jan 3rd, 2008, 01:03 AM.

  • #2
    That's a limitation of Gmail's SMTP server. It always rewrite the sender's email with the email used to authenticate. Gmail isnt a totally open SMTP relay. For that, you should probably use your ISP's server.


    • #3
      Oh, darn. Really? That sucks. So even if I subscribed my domain to that Google Apps Standard Edition, there's no workaround?

      Oh, well...

      Thanks for pointing it out. I'm glad, my web app is still in its early stages, a bit far from deployment. And I'm more glad it wasn't my coding.


      • #4
        I dont know anything about "Google Apps Standard Edition", and domain mail hosting at Google. You might be able to get it working ... But this is a Google problem, nothing wrong with your code ...