Keeping it Small and Simple


Alfresco: Sending mails with Gmail

Filed under: Alfresco — Tags: , , , , — Lorenzo E. Danielsson @ 12:04

I’ve been struggling with this for some time, in part no doubt, due to my limited knowledge of JavaMail. But, I always make up for lack of (knowledge, intelligence, experience) with pure stubbornness. Anyways, just thought I’d record it here, since it seems there are others struggling with it as well.

I had set up a Gmail account that I wanted to use to with an Alfresco installation. Here is some basic information (not that I think it matters).

  • Server: Debian Etch (odd packages from lenny and sid)
  • Alfresco: Alfresco Tomcat Community 2.1.0
  • JDK 6: package from Sid (aptitude search/show it to get the gory details)

There are exactly two files you need to edit to get STMP with Gmail to work. They are both located in /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco (assuming that you installed Alfresco in /opt/alfresco.

The first is Open in your favorite vi clone and search for mail: Modify to look like this:

# Email configuration =
mail.port = 465
mail.transport.protocol = smtp
mail.username =
mail.password= asecretpassword
mail.smtp.auth = true
mail.smtp.socketFactory.port = 465
mail.smtp.socketFactory.class =
mail.smtp.socketFactory.fallback = false
mail.smtp.timeout = 25000
mail.smtp.starttls.enable = true

There, half the job is done. You will obviously need to modify the username and password (no will not work).

Now vi core-services-context.xml, find the section on mail (you can search for MAIL to find it quickly). Modify it to look as follows.

<!—                        —>
<!— MAIL SERVICE           —>
<!—                        —>

<bean id="mailService" class="org.springframework.mail.javamail.JavaMailSenderImpl">
  <property name="host">
  <property name="port">
  <property name="protocol">                            
  <property name="username">
  <property name="password">
  <property name="defaultEncoding">

  <property name="javaMailProperties">
      <prop key="mail.smtp.auth">${mail.smtp.auth}</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>
      <prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>

You should now be set.

Test it

  1. Create a user for yourself if you haven’t already done so. Make sure you entered a valid email address in the email field (modify user if you didn’t).
  2. Select an existing space or create a new one. View space details.
  3. Find the option Manage Space Users and select it
  4. Invite a user. Select your user, and whatever role you want. Make sure you say Yes to sending an email to the user.
  5. When you are done and click finish, your user should have been added as a space user. If Alfresco freezes for a long time here then something is wrong and you need to go back and fix things.
  6. Check your personal email. There should be a mail from your Alfresco email user.

Good you are done, go and collect your money. Buy yourself a beer. And buy one for me too!


  1. Hi,

    I tried your solution but now i get the following error when i try to send mail


    Do you know what can be wrong?


    Comment by Johan — 2008.04.18 @ 10:41

  2. Your log output indicates that you have an encoding issue. Could you find out the value of ${mail.encoding}?

    Comment by Lorenzo E. Danielsson — 2008.04.18 @ 15:26

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: