Results 1 to 5 of 5

Thread: JavaMailSenderImpl

  1. #1
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default 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. #2
    Join Date
    Nov 2006
    Location
    The Netherlands
    Posts
    33

    Default

    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
    Barre Dijkstra

  3. #3
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default

    <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 at 07:44 AM.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote 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 at 07:22 AM. Reason: removed host, username and password.... security and all that

  5. #5
    Join Date
    Nov 2006
    Location
    The Netherlands
    Posts
    33

    Default

    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>
    Barre Dijkstra

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •