cancel
Showing results for 
Search instead for 
Did you mean: 

3.4.b Outbound SMTP settings for Gmail...Anyone Succeeded?

afrescoaero
Champ in-the-making
Champ in-the-making
Hello All,

I have been battling this issue for days to no avail. I wish to use the gmail smtp server to send my "invites" from alfresco to new users, however I still havn't managed to solve it and i receive the "0 invites sent, 1 failure" error..

Does anyone have a working example of code they've used in the Oubound SMTP configuration file? and any other file they've edited to make it work? Any working code examples would be appreciated.


Best Regards
14 REPLIES 14

loftux
Star Contributor
Star Contributor
I've not tested Gmail, but I had to redefine the bean for OutboundSMTP for my mail server
In path tomcat/shared/classes/alfresco/extension/subsystems/email/OutboundSMTP/outbound
add a file, outboundsmtp-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <!–                        –>
    <!– MAIL SERVICE           –>
    <!–                        –>

    <bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host">
            <value>${mail.host}</value>
        </property>
        <property name="port">
            <value>${mail.port}</value>
        </property>
      <property name="protocol">
        <value>${mail.protocol}</value>
    </property>

        <property name="username">
            <value>${mail.username}</value>
        </property>
        <property name="password">
            <value>${mail.password}</value>
        </property>
        <property name="defaultEncoding">
            <value>${mail.encoding}</value>
        </property>
      <property name="javaMailProperties">
        <props>
            <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
            <prop key="mail.smtps.auth">${mail.smtps.auth}</prop>
            <prop key="mail.smtps.starttls.enable">${mail.smtps.starttls.enable}</prop>
        </props>
    </property>

    </bean>

</beans>
Notice the new property you can set (in alfresco-global.properties), mail.smtp.auth (true,false values), mail.smtps.auth existed before.
It may be that you need to add more javamail properties, bit this should get you started.
(EDIT: Moved this last paragraph out of code tag)

afrescoaero
Champ in-the-making
Champ in-the-making
Thanks for the reply. I've tried a lot of the tutorials and set my Stmp settings as described but still no joy. This part of the error keeps appearing:

Caused by: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.alfresco.com, port: 25;

The problem is I've set my mail.host as smtp.gmail.com in my global properties file and still no luck.

I've tried both on Ubuntu and Windows installs. Is there any working code examples that can be posted? It's been a week of attempting to get the email invitations working now, and im running out of things to try.


Best Regards

mehul1511
Champ in-the-making
Champ in-the-making
Hey, I had the same issue try to read my post under username of mehul1511. 

I got rid of the issue you are having right now but now having another issues where it says Mail server connection failed but now it fails to connect to smtp.gmail.com instead of smtp.alfresco.org. I just started my tomcat service and it accepted the overridden file.

if you were able to resolve this issue then please help me.

Thank you

mehul1511
Champ in-the-making
Champ in-the-making
Hey guys this issue has been SOLVED again by a different way though.

ok so this is all I did and it started working awesome for me!
All I did was made changes in two files

First: in alfresco-global.properties, just add this code in your file.

# Email settings
mail.host=smtp.gmail.com
mail.port=465
mail.protocol=smtps
mail.username=XXXXXXXX@gmail.com
mail.password=XXXXXXXX
mail.encoding=UTF-8   
mail.smtps.auth=true
mail.smtps.starttls.enable=true

Second and last step add this code in your outboundSMTP-context.xml

<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host">
            <value>${mail.host}</value>
        </property>
        <property name="port">
            <value>${mail.port}</value>
        </property>
      <property name="protocol">
        <value>${mail.protocol}</value>
    </property>

        <property name="username">
            <value>${mail.username}</value>
        </property>
        <property name="password">
            <value>${mail.password}</value>
        </property>
        <property name="defaultEncoding">
            <value>${mail.encoding}</value>
        </property>
      <property name="javaMailProperties">
        <props>
            <prop key="mail.smtps.auth">${mail.smtps.auth}</prop>
            <prop key="mail.smtps.starttls.enable">${mail.smtps.starttls.enable}</prop>
        </props>
    </property>

    </bean>

And here I also want to show if you want to do these settings for WEBMAIL 1and1
do these following settings.

Add these code in alfresco-global.properties


# Email settings
mail.host=smtp.1and1.com
mail.port=465
mail.protocol=smtps
mail.username=XXX
mail.password=XXX
mail.encoding=UTF-8   
mail.smtps.auth=true
mail.smtps.starttls.enable=true
mail.smtp.socketFactory.port=465
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback=false

And for the outboundSMTP-context.xml add the following


<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host">
            <value>${mail.host}</value>
        </property>
        <property name="port">
            <value>${mail.port}</value>
        </property>
      <property name="protocol">
        <value>${mail.protocol}</value>
    </property>

        <property name="username">
            <value>${mail.username}</value>
        </property>
        <property name="password">
            <value>${mail.password}</value>
        </property>
        <property name="defaultEncoding">
            <value>${mail.encoding}</value>
        </property>
      <property name="javaMailProperties">
        <props>
            <prop key="mail.smtps.auth">${mail.smtps.auth}</prop>
            <prop key="mail.smtps.starttls.enable">${mail.smtps.starttls.enable}</prop>
         <prop key="mail.smtp.socketFactory.port">${mail.smtp.socketFactory.port}</prop>
         <prop key="mail.smtp.socketFactory.class">${mail.smtp.socketFactory.class}</prop>
         <prop key="mail.smtp.socketFactory.fallback">${mail.smtp.socketFactory.fallback}</prop>
        </props>
    </property>

    </bean>

Please select yes it this post is helpful

Thank you

nfuchs
Champ in-the-making
Champ in-the-making
I'm new to Alfresco. I'm trying to also setup the mail file however I can't seem to find the files I need to modify. I'm using 3.4d. Can anyone provide some assistance?

mehul1511
Champ in-the-making
Champ in-the-making
Sure man!

As you can see in the post above you have to make changes in only two files.

1. C:\Alfresco\tomcat\shared\classes\alfresco-global.properties

2. C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\email\OutboundSMTP\outboubdSMTP-context.xml

You can also use search option to find those files!

Hope this helps

cariou
Champ in-the-making
Champ in-the-making
Beware of the blank spaces in this line :

mail.encoding=UTF-8

I made a copy/paste of your sample and it didn't succeed until I found that there was white space at the end of the property line !!!

Now it works !

wabson
Star Contributor
Star Contributor
It's worth noting that on version 4.x, the default 'mailService' bean already defines the additional properties, so the override XML file should not be needed. You can simply add the properties to alfresco-global.properties.

On older versions of Alfresco, if you do find you need to override the bean definition then note also that the subsystems allow you to place override config in alfresco/extension, so you can add the Spring configuration file in the directory alfresco/extension/subsystems/email/OutboundSMTP/default in tomcat/shared/classes. This is better practice than modifying the original files in the webapp.

Cheers,
Will.

rajaa90
Champ in-the-making
Champ in-the-making
I get a confirmation email by configuring outgoingSMTP  and send testmail=True,  but inviting does not
send any emails.  What could be the problem?

Raja