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 repository.properties. Open in your favorite vi clone and search for mail: Modify to look like this:
# Email configuration
mail.host = smtp.gmail.com
mail.port = 465
mail.transport.protocol = smtp
mail.username = someuser@gmail.com
mail.password= asecretpassword
mail.smtp.auth = true
mail.smtp.socketFactory.port = 465
mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
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 someuser@gmail.com/asecretpassword 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">
<value>${mail.host}</value>
</property>
<property name="port">
<value>${mail.port}</value>
</property>
<property name="protocol">
<value>${mail.transport.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.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>
</props>
</property>
</bean>
You should now be set.
Test it
- 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).
- Select an existing space or create a new one. View space details.
- Find the option Manage Space Users and select it
- Invite a user. Select your user, and whatever role you want. Make sure you say Yes to sending an email to the user.
- 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.
- 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!
Hi,
I tried your solution but now i get the following error when i try to send mail
see http://forums.alfresco.com/viewtopic.php?f=9&t=12052
Do you know what can be wrong?
Thnx!
Comment by Johan — 2008.04.18 @ 10:41
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