cancel
Showing results for 
Search instead for 
Did you mean: 

how to get email set up in global file

zlu
Champ in-the-making
Champ in-the-making
Hi all,

Can you tell me how to get the Alfresco email set up in the alfresco-global.properties file from the web script?

My server has the out-bound email set up and I want to use javax.mail to send out HTML email. So I need to know the email host and address, which is already stored in the global.properties file.

And I want to get it out by web script instead of hard code on the source. Can you tell me how to do it?

Cheers,
Daniel
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
Daniel,

Probably the easiest way to do it is to simply inject the values into your web script through Spring configuration. This is exactly what Alfresco does for its own beans and you have access to the same substitution variables.

It would look something like this:
<beans>
    <bean id="webscript.com.someco.GetGlobalProperty.get-global-property.get" class="com.someco.scripts.GetGlobalProperty" parent="webscript">
        <property name="host">
            <value>${mail.host}</value>
        </property>
        <property name="port">
            <value>${mail.port}</value>
        </property>
        <property name="protocol">
            <value>${mail.protocol}</value>
        </property>
    </bean>
</beans>
Then, in your Java-backed web script controller, assuming you had getters and setters that matched up to those properties (like getHost, setHost, getPort, setPort), you could just call those getters to grab the values.

Jeff