Email, Gmail troubles

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Email, Gmail troubles

bercy46
Hi,

Trying to get Gmail working with Appfuse.

First, I started my project with a Maven archetype.  I can't remember which one exactly, I remember it was basic, and I'm using Spring, Struts and Hibernate.

The symptom is that AppFuse is complaining with this error:

MailEngine.send(78) | Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com ). Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com )

This is my mail.properties :


# This properties file is used to configure mail settings in
# /WEB-INF/applicationContext-service.xml.

mail.default.from=Name <address@gmail.com>
mail.debug=true
mail.transport.protocol=smtp
mail.smtp.starttls.enable=true
mail.host=smtp.gmail.com
mail.username=address@gmail.com
mail.password=password
mail.port=587
mail.mime.address.strict=false
mail.mime.charset=UTF-8


I've tried debugging the thing using the PasswordHint action which hasn't been touched.

What I'm finding is that only the "smtp.gmail.com" is being set.  All other properties are not loaded.


So, I've googled extensively, and found references to the applicationContext-service.xml.

It seems this file is supposed to be in the WEB-INF/ directory.

It's NOT !  I have no idea if it's important or not ??!?

Help !

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

mraible
Administrator
If you run "mvn appfuse:full-source", you should get access to the applicationContext-service.xml file.

You can also put the following beans in your context file to get the functionality you're looking for. Adding these will override the ones in applicationContext-service.xml.

    <bean id="mailEngine" class="org.appfuse.service.MailEngine">
        <property name="mailSender" ref="mailSender"/>
        <property name="velocityEngine" ref="velocityEngine"/>
        <property name="from" value="${mail.default.from}"/>
    </bean>

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${mail.host}"/>
        <property name="defaultEncoding" value="UTF-8"/>
        <!-- Uncomment if you need to authenticate with your SMTP Server -->
        <!--property name="username" value="${mail.username}"/>
        <property name="password" value="${mail.password}"/>
        <property name="javaMailProperties">
            <value>
                mail.smtp.auth=true
            </value>
        </property-->
    </bean>

On Oct 2, 2013, at 3:30 PM, bercy46 <[hidden email]> wrote:

> Hi,
>
> Trying to get Gmail working with Appfuse.
>
> First, I started my project with a Maven archetype.  I can't remember which
> one exactly, I remember it was basic, and I'm using Spring, Struts and
> Hibernate.
>
> The symptom is that AppFuse is complaining with this error:
>
> MailEngine.send(78) | Mail server connection failed; nested exception is
> javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com
> (java.net.UnknownHostException: smtp.gmail.com ). Failed messages:
> javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com
> (java.net.UnknownHostException: smtp.gmail.com )
>
> This is my mail.properties :
>
>
> # This properties file is used to configure mail settings in
> # /WEB-INF/applicationContext-service.xml.
>
> mail.default.from=Name <[hidden email]>
> mail.debug=true
> mail.transport.protocol=smtp
> mail.smtp.starttls.enable=true
> mail.host=smtp.gmail.com
> mail.username=[hidden email]
> mail.password=password
> mail.port=587
> mail.mime.address.strict=false
> mail.mime.charset=UTF-8
>
>
> I've tried debugging the thing using the PasswordHint action which hasn't
> been touched.
>
> What I'm finding is that only the "smtp.gmail.com" is being set.  All other
> properties are not loaded.
>
>
> So, I've googled extensively, and found references to the
> applicationContext-service.xml.
>
> It seems this file is supposed to be in the WEB-INF/ directory.
>
> It's NOT !  I have no idea if it's important or not ??!?
>
> Help !
>
> Thanks.
>
>
>
> --
> View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
Thank you Matt for the quick reply.

I added both beans to src/main/webapp/WEB-INF/applicationContext.xml.

The result is the same.

I noticed there was something to uncomment for authentication, I uncommented and tried again, same result.

I do have some progress though.  If I break in PasswordHintAction.setMailEngine(...) and look at the mailEngine instance, I now see the username and password.  Port was still -1 though.

So, I added a couple of properties to the mailSender bean:

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> 
        <property name="host" value="${mail.host}"/> 
        <property name="defaultEncoding" value="UTF-8"/> 
         
        <property name="username" value="${mail.username}"/> 
        <property name="password" value="${mail.password}"/> 
        <property name="port" value="${mail.port}"/>
        <property name="debug" value="true"/>
        <property name="javaMailProperties"> 
            <value> 
                mail.smtp.auth=true,
                mail.smtp.starttls.enable=true
            </value> 
        </property> 
    </bean> 

I now see the port (587), and also the smtp.starttls.enable thingie in the javaMailProperties while debugging.

But I still get the same connection exception :-(

Notice that I added the debug property, and I also added this to the log4j.xml file :

    <logger name="javax.mail">
        <level value="DEBUG"/>
    </logger>
   
I don't know if that's supposed to help, I was hoping for some juicy details, but no luck :-(

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

khalid el hayani
hello,
after I made the change below, the email service is working now:

1) If you work with tomcat you must add this jar in the folder:: C:\Apache_Software_Foundation\Tomcat_6.0\lib ( see attached file)
2) Configure mai.properties like :

mail.default.from=........."laber of mail that you send"<emailAdresse>
mail.debug=true 
mail.transport.protocol=smtp
mail.host=smtp.gmail.com
mail.username=....... "your username of adresseEmail"
mail.password=.......  " your passwordof adresseEmail"
mail.port=587
(note that exist 2 file named mail.properties, one in "Other source" folder and other in Other test resources" did the same in the both)

3) Add these lines in ApplicationContext-service.xml file:

  <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${mail.host}"/>
        <property name="defaultEncoding" value="UTF-8"/>
        <!-- Uncomment if you need to authenticate with your SMTP Server -->

        <property name="username" value="${mail.username}"/>
        <property name="password" value="${mail.password}"/>
        <property name="javaMailProperties">
            <props>
                <prop key="mail.smtp.auth">true</prop>
                <prop key="mail.smtp.starttls.enable">true</prop>
                <prop key="mail.smtps.ssl.enable">true</prop>
                <prop key="mail.smtp.quitwait">false</prop>
                <prop key="mail.smtp.host">${mail.host}</prop>
                <prop key="mail.transport.protocol">${mail.transport.protocol}</prop>
                <prop key="mail.smtp.port">${mail.port}</prop>
            </props>
        </property>
    </bean>
    <bean id="mailEngine" class="org.appfuse.service.MailEngine"> 
        <property name="mailSender" ref="mailSender"/> 
        <property name="velocityEngine" ref="velocityEngine"/> 
        <property name="from" value="${mail.default.from}"/> 
     </bean>

I hope, that will help you

2013/10/3 bercy46 <[hidden email]>
Thank you Matt for the quick reply.

I added both beans to src/main/webapp/WEB-INF/applicationContext.xml.

The result is the same.

I noticed there was something to uncomment for authentication, I uncommented
and tried again, same result.

I do have some progress though.  If I break in
PasswordHintAction.setMailEngine(...) and look at the mailEngine instance, I
now see the username and password.  Port was still -1 though.

So, I added a couple of properties to the mailSender bean:

    <bean id="mailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host" value="${mail.host}"/>
        <property name="defaultEncoding" value="UTF-8"/>

        <property name="username" value="${mail.username}"/>
        <property name="password" value="${mail.password}"/>
        <property name="port" value="${mail.port}"/>
        <property name="debug" value="true"/>
        <property name="javaMailProperties">
            <value>
                mail.smtp.auth=true,
                mail.smtp.starttls.enable=true
            </value>
        </property>
    </bean>

I now see the port (587), and also the smtp.starttls.enable thingie in the
javaMailProperties while debugging.

But I still get the same connection exception :-(

Notice that I added the debug property, and I also added this to the
log4j.xml file :

    <logger name="javax.mail">
        <level value="DEBUG"/>
    </logger>

I don't know if that's supposed to help, I was hoping for some juicy
details, but no luck :-(





--
View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734p4656736.html
Sent from the AppFuse - User mailing list archive at Nabble.com.



--
Khalid El HAYANI
(+33) 7 70 01 41 06
l'Homme tout d'abord et après tout le reste .. 

mail.jar (678K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
Merci Khalid pour ton message :-)

I have made the changes Khalid suggested, and I do have a different exception this time :


ERROR [http-bio-8080-exec-9] MailEngine.send(78) | Mail server connection failed; nested exception is javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp . Failed messages: javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp

I did step into PasswordHintAction again, and verified that the javaMailProperties were set according to the values in mail.properties.

Just to be sure, here are my config files :

applicationContext.xml:


    <bean id="mailEngine" class="org.appfuse.service.MailEngine"> 
        <property name="mailSender" ref="mailSender"/> 
        <property name="velocityEngine" ref="velocityEngine"/> 
        <property name="from" value="${mail.default.from}"/> 
    </bean> 

    <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> 
        <property name="host" value="${mail.host}"/> 
        <property name="defaultEncoding" value="UTF-8"/> 
         
        <property name="username" value="${mail.username}"/> 
        <property name="password" value="${mail.password}"/> 
        <property name="javaMailProperties"> 
            <props>
                <prop key="mail.smtp.auth">true</prop>
                <prop key="mail.smtp.starttls.enable">true</prop>
                <prop key="mail.smtps.ssl.enable">true</prop>
                <prop key="mail.smtp.quitwait">false</prop>
                <prop key="mail.smtp.host">${mail.host}</prop>
                <prop key="mail.transport.protocol">${mail.transport.protocol}</prop>
                <prop key="mail.smtp.port">${mail.port}</prop>
            </props>
        </property> 
    </bean> 


And mail.properties:


mail.default.from=Email-Label <address@gmail.com>
mail.debug=true
mail.transport.protocol=smtp
mail.smtp.starttls.enable=true
mail.host=smtp.gmail.com
mail.username=address@gmail.com
mail.password=password
mail.port=587
mail.mime.address.strict=false
mail.mime.charset=UTF-8

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
On a side note, i'm using http://appfuse.org/display/APF/Forum to post to the mailing list...

I don't know who's in charge of that web site, but when we click on buttons (like "Post Message"), there is no visual feedback during the click, and to make things even more confusing, the web site takes about 20 seconds to refresh the page with the posted message...

I would suggest making the button disabled once it is clicked ?

I'm guessing there must be tons of double- and triple- posts if others are getting the same user experience.

I'm on a Macbook if that makes a difference.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

mraible
Administrator
In reply to this post by bercy46
What happens if you remove mail.transport.protocol as a property?

On Oct 3, 2013, at 6:51 AM, bercy46 <[hidden email]> wrote:

> Merci Khalid pour ton message :-)
>
> I have made the changes Khalid suggested, and I do have a different
> exception this time :
>
>
> ERROR [http-bio-8080-exec-9] MailEngine.send(78) | Mail server connection
> failed; nested exception is javax.mail.NoSuchProviderException: Unable to
> locate provider for protocol: smtp . Failed messages:
> javax.mail.NoSuchProviderException: Unable to locate provider for protocol:
> smtp
>
> I did step into PasswordHintAction again, and verified that the
> javaMailProperties were set according to the values in mail.properties.
>
> Just to be sure, here are my config files :
>
> applicationContext.xml:
>
>
>    <bean id="mailEngine" class="org.appfuse.service.MailEngine">
>        <property name="mailSender" ref="mailSender"/>
>        <property name="velocityEngine" ref="velocityEngine"/>
>        <property name="from" value="${mail.default.from}"/>
>    </bean>
>
>    <bean id="mailSender"
> class="org.springframework.mail.javamail.JavaMailSenderImpl">
>        <property name="host" value="${mail.host}"/>
>        <property name="defaultEncoding" value="UTF-8"/>
>
>        <property name="username" value="${mail.username}"/>
>        <property name="password" value="${mail.password}"/>
>        <property name="javaMailProperties">
>            <props>
>                <prop key="mail.smtp.auth">true</prop>
>                <prop key="mail.smtp.starttls.enable">true</prop>
>                <prop key="mail.smtps.ssl.enable">true</prop>
>                <prop key="mail.smtp.quitwait">false</prop>
>                <prop key="mail.smtp.host">${mail.host}</prop>
>                <prop
> key="mail.transport.protocol">${mail.transport.protocol}</prop>
>                <prop key="mail.smtp.port">${mail.port}</prop>
>            </props>
>        </property>
>    </bean>
>
>
> And mail.properties:
>
>
> mail.default.from=Email-Label <[hidden email]>
> mail.debug=true
> mail.transport.protocol=smtp
> mail.smtp.starttls.enable=true
> mail.host=smtp.gmail.com
> mail.username=[hidden email]
> mail.password=password
> mail.port=587
> mail.mime.address.strict=false
> mail.mime.charset=UTF-8
>
>
>
>
>
> --
> View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734p4656738.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

mraible
Administrator
In reply to this post by bercy46
We're just iframing Nabble, so you might be better off going directly to it:

http://appfuse.547863.n4.nabble.com/AppFuse-User-f547864.html

Or you could send a blank email to [hidden email] to subscribe to the mailing list and do everything through your email client.

On Oct 3, 2013, at 6:56 AM, bercy46 <[hidden email]> wrote:

> On a side note, i'm using http://appfuse.org/display/APF/Forum to post to the
> mailing list...
>
> I don't know who's in charge of that web site, but when we click on buttons
> (like "Post Message"), there is no visual feedback during the click, and to
> make things even more confusing, the web site takes about 20 seconds to
> refresh the page with the posted message...
>
> I would suggest making the button disabled once it is clicked ?
>
> I'm guessing there must be tons of double- and triple- posts if others are
> getting the same user experience.
>
> I'm on a Macbook if that makes a difference.
>
>
>
>
> --
> View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734p4656739.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

mraible
Administrator
In reply to this post by bercy46
Here's a related thread where it looks like someone has used gmail successfully.

http://appfuse.547863.n4.nabble.com/how-to-config-GMail-s-SMTP-server-to-be-used-by-AppFuse-td574061.html


On Oct 3, 2013, at 6:51 AM, bercy46 <[hidden email]> wrote:

> Merci Khalid pour ton message :-)
>
> I have made the changes Khalid suggested, and I do have a different
> exception this time :
>
>
> ERROR [http-bio-8080-exec-9] MailEngine.send(78) | Mail server connection
> failed; nested exception is javax.mail.NoSuchProviderException: Unable to
> locate provider for protocol: smtp . Failed messages:
> javax.mail.NoSuchProviderException: Unable to locate provider for protocol:
> smtp
>
> I did step into PasswordHintAction again, and verified that the
> javaMailProperties were set according to the values in mail.properties.
>
> Just to be sure, here are my config files :
>
> applicationContext.xml:
>
>
>    <bean id="mailEngine" class="org.appfuse.service.MailEngine">
>        <property name="mailSender" ref="mailSender"/>
>        <property name="velocityEngine" ref="velocityEngine"/>
>        <property name="from" value="${mail.default.from}"/>
>    </bean>
>
>    <bean id="mailSender"
> class="org.springframework.mail.javamail.JavaMailSenderImpl">
>        <property name="host" value="${mail.host}"/>
>        <property name="defaultEncoding" value="UTF-8"/>
>
>        <property name="username" value="${mail.username}"/>
>        <property name="password" value="${mail.password}"/>
>        <property name="javaMailProperties">
>            <props>
>                <prop key="mail.smtp.auth">true</prop>
>                <prop key="mail.smtp.starttls.enable">true</prop>
>                <prop key="mail.smtps.ssl.enable">true</prop>
>                <prop key="mail.smtp.quitwait">false</prop>
>                <prop key="mail.smtp.host">${mail.host}</prop>
>                <prop
> key="mail.transport.protocol">${mail.transport.protocol}</prop>
>                <prop key="mail.smtp.port">${mail.port}</prop>
>            </props>
>        </property>
>    </bean>
>
>
> And mail.properties:
>
>
> mail.default.from=Email-Label <[hidden email]>
> mail.debug=true
> mail.transport.protocol=smtp
> mail.smtp.starttls.enable=true
> mail.host=smtp.gmail.com
> mail.username=[hidden email]
> mail.password=password
> mail.port=587
> mail.mime.address.strict=false
> mail.mime.charset=UTF-8
>
>
>
>
>
> --
> View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734p4656738.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
In reply to this post by mraible
This is the exception:

ERROR [http-bio-8080-exec-7] MailEngine.send(78) | Mail server connection failed; nested exception is javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com ). Failed messages: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com )

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
In reply to this post by mraible
I had read that thread, I see nothing in there I haven't tried...

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

mraible
Administrator
In reply to this post by bercy46
Can you ping it? Maybe a firewall is blocking it.

$ ping smtp.gmail.com
PING gmail-smtp-msa.l.google.com (74.125.129.109): 56 data bytes
64 bytes from 74.125.129.109: icmp_seq=0 ttl=46 time=45.969 ms
64 bytes from 74.125.129.109: icmp_seq=1 ttl=46 time=49.823 ms
64 bytes from 74.125.129.109: icmp_seq=2 ttl=46 time=46.260 ms
64 bytes from 74.125.129.109: icmp_seq=3 ttl=46 time=48.597 ms

On Oct 3, 2013, at 11:50 AM, bercy46 <[hidden email]> wrote:

> This is the exception:
>
> ERROR [http-bio-8080-exec-7] MailEngine.send(78) | Mail server connection
> failed; nested exception is javax.mail.MessagingException: Unknown SMTP
> host: smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com ).
> Failed messages: javax.mail.MessagingException: Unknown SMTP host:
> smtp.gmail.com  (java.net.UnknownHostException: smtp.gmail.com )
>
>
>
>
>
> --
> View this message in context: http://appfuse.547863.n4.nabble.com/Email-Gmail-troubles-tp4656734p4656743.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

bercy46
Yes I can ping it.

How would I turn on any debugging output which might help me pinpoint my problem ?

Adding javax.mail to log4j.xml didn't do anything...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles : SOLVED

bercy46
In reply to this post by bercy46
Hi,

Answering my own post here...

These are the settings that worked for me as far as using Gmail with Appfuse :

mail.properties:

mail.default.from=From <address@gmail.com>
mail.transport.protocol=smtp
mail.host=smtp.gmail.com
mail.username=address@gmail.com
mail.password=password
mail.port=587
mail.mime.address.strict=false
mail.mime.charset=UTF-8

applicationContext.xml:

        <bean id="mailEngine" class="org.appfuse.service.MailEngine">
                <property name="mailSender" ref="mailSender" />
                <property name="velocityEngine" ref="velocityEngine" />
                <property name="from" value="${mail.default.from}" />
        </bean>

        <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
                <property name="host" value="${mail.host}" />
                <property name="defaultEncoding" value="UTF-8" />
               
                <property name="username" value="${mail.username}" />
                <property name="password" value="${mail.password}" />
                <property name="javaMailProperties">
                        <props>
                                <prop key="mail.smtp.auth">true</prop>
                                <prop key="mail.smtp.host">${mail.host}</prop>
                                <prop key="mail.transport.protocol">${mail.transport.protocol}</prop>
                                <prop key="mail.smtp.port">${mail.port}</prop>
                        </props>
                </property>
        </bean>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Email, Gmail troubles

matteo.manilii
In reply to this post by bercy46
Remember to turn off the antivirus (Avast and others) !!!
Loading...