05-29-2018 06:22 AM
Alfresco Community (Build: 201707)
===============================Contains:
- Alfresco Platform: 5.2.g
- Alfresco Share: 5.2.falfresco-global.properties:
### Outbound SMTP configuration properties - Working example #### Sample Gmail settingsmail.host=smtp.gmail.commail.port=465mail.username=elcamino@gmail.commail.password=*********mail.protocol=smtpsmail.smtps.starttls.enable=truemail.smtps.auth=trueProject dependency:
compile group: 'org.alfresco', name: 'alfresco-repository', version: '6.50' // https://mvnrepository.com..
Hello
I would like to send a test email with the alfresco built in "send email" action.
What are the theoretical steps needed to do so ?
1. Include alfresco-repository dependency in the project
2. Create _Alfresco_sendmail() method (see test code below)
3. And now im a little lost, what next ?
3.1. As you notice there is no authentication hire, what is the logic behind the authentication user pass server ip Where to put those? From what I understand I can not do it with CMIS1.1
Hire is my test code.
05-29-2018 12:15 PM
You have the right idea. The question I have is, what do you want to trigger this code? Your method looks right (except for the method name, which should look more like "alfrescoSendMail"). But what class is your method in?
* Is this an action executer that you are calling from a folder rule? (See Actions Tutorial).
* Or is this a web script controller that you are invoking via REST? (See Web Script Tutorial).
* Or is this a behavior that you have bound to a policy to trigger when something happens to a node of a certain type or with a certain aspect? (See Behavior Tutorial).
Once you have decided what will trigger your email, you can put your method in a class that extends the appropriate parent class, then you can package your JAR up as an AMP and use the MMT to merge it with your Alfresco WAR (See Maven SDK Tutorial).
05-30-2018 03:24 AM
Use case:
1. So basically I have an example jHipster java/angular project & Alfresco server.
2. I can add/pull files to/from Alfreesco repo via CMIS 1.1 & atompub URL
3. I can receive emails with attachments into alfresco
3. Now I would like to take received email with an attachment & send it to lets say to my Gmail account
If I understood correctly then Alfresco Share comes with a built in "Send Email" action. (This action can be triggered with a folder rule for example).
1. Is it possible to trigger this "Send Email" action with a custom java code?
For example:
1. Generate an example "Hello world" project (maven+java+Spring Boot) at Spring Initializr website
2. Inside this project call alfrescoSendMail();
3. This method then should connect to Alfresco serverort, authenticate, pass in parameters like (subject, to , from, message, attachments).
05-30-2018 02:02 PM
Hello.
The Java service you used in your code is intended to be used in the Alfresco process, and not from outside.
In order to achieve what you need, I would use the webscript way (the link Jeff shared) and then, with the method exposed, use anything you want to execute it via REST, passing on the parameters you already have.
Your custom webscript would have the code you shared as part of it.
05-30-2018 04:42 PM
Either way it is Java code, so I don't think one is easier or harder than the other. From an architectural perspective it seems to me that Alfresco might be the right place to send the email because it is also the system receiving the email. On the other hand, if your JHipster app needs to do some processing, then maybe your JHipster app should send the email.
If you decide to send the email from Alfresco you have to decide what triggers the email to be sent. If you need it to be triggered from your JHipster app, then write a web script and trigger it by calling the webscript's URL from the JHipster app.
If you decide to send the email from JHipster, use CMIS to grab the files, then send it from there using whatever Java API you want.
Explore our Alfresco products with the links below. Use labels to filter content by product module.