Announcement Announcement Module
Collapse
No announcement yet.
JavaMailSenderImpl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaMailSenderImpl

    My email server need smtp authentication

    how can I set it?

    I'm using:

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
    <property name="host" value="host.host.com" />
    <property name="username" value="user" />
    <property name="password" value="passkey" />
    </bean>

  • #2
    From the API documentation of JavaMailSenderImpl:
    setPassword

    public void setPassword(String password) Set the password for the account at the mail host, if any. Note that the underlying JavaMail Session has to be configured with the property "mail.smtp.auth" set to "true", else the specified password will not be sent to the mail server by the JavaMail runtime. If you are not explicitly passing in a Session to use, simply specify this setting via JavaMailSenderImpl's "javaMailProperties".

    See Also:setJavaMailProperties(java.util.Properties), setSession(javax.mail.Session), setUsername(java.lang.String)
    I'd say adding the mail.smtp.auth prop and setting it to true should fix your problem.


    Cheers,

    Barre

    Comment


    • #3
      <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl">
      <property name="host" value="host.host.com" />
      <property name="username" value="user" />
      <property name="password" value="123" />
      <property name="mail.smtp.auth" value="true" />
      </bean>

      I tried this way and I got an exception saying that this property does not exist.
      it seems that I need to set a property file, does sum1 know has an idea how I can do this?
      Last edited by vammpiro; Nov 30th, 2006, 07:44 AM.

      Comment


      • #4
        Originally posted by vammpiro View Post
        I tried this way and I got an exception saying that this property does not exist. it seems that I need to set a property file, does sum1 know has an idea how I can do this?
        If you looked at the java doc salp added the link to, that isn't a property.

        Code:
        <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
            <property name="host" value="myhost.com" />
            <property name="username" value="myUsername" />
            <property name="password" value="myPassword" />
            <property name="javaMailProperties">
                <props>
                    <prop key="mail.smtp.auth">true</prop>
                </props>
            </property>
        </bean>
        Last edited by karldmoore; Nov 30th, 2006, 07:22 AM. Reason: removed host, username and password.... security and all that

        Comment


        • #5
          First of all, I'd suggest you edit your post to remove any hosts, usernames and passwords.

          The mail.smtp.auth is set in the javaMailProperties method, as specified in the API documentation i posted.


          Code:
          <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
                  <property name="host" value="some.host" />
                  <property name="username" value="uname" />
                  <property name="password" value="passwd" />
                  <property name="javaMailProperties">
                          <props>
                                  <prop key="mail.smtp.auth">true</prop>
                         </props>
                  </property>
          </bean>

          Comment

          Working...
          X