This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
Hi there,
Today i try to use a OSGI to send email in AEM, below is code snippet:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd "> <modelVersion>4.0.0</modelVersion> <!-- ====================================================================== --> <!-- P A R E N T P R O J E C T D E S C R I P T I O N --> <!-- ====================================================================== --> <parent> <groupId>com.adobe.cq</groupId> <artifactId>customer</artifactId> <version>1.0-SNAPSHOT</version> </parent> <!-- ====================================================================== --> <!-- P R O J E C T D E S C R I P T I O N --> <!-- ====================================================================== --> <artifactId>customer-bundle</artifactId> <packaging>bundle</packaging> <name>Customer Training Package Bundle</name> <!-- ====================================================================== --> <!-- B U I L D D E F I N I T I O N --> <!-- ====================================================================== --> <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-scr-plugin</artifactId> <executions> <execution> <id>generate-scr-descriptor</id> <goals> <goal>scr</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>com.adobe.cq.customer-bundle</Bundle-SymbolicName> </instructions> </configuration> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>com.adobe.cq.schedule-bundle</Bundle-SymbolicName> </instructions> </configuration> </plugin> <plugin> <groupId>org.apache.sling</groupId> <artifactId>maven-sling-plugin</artifactId> <configuration> <slingUrl>http://${crx.host}:${crx.port}/apps/customer-training/install</slingUrl> <usePut>true</usePut> </configuration> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-Category>cq5</Bundle-Category> <Embed-Dependency> dom4j, jaxen;scope=compile|runtime;inline=false </Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> <Import-Package> com.sun.msv.*;resolution:=optional, nu.xom;resolution:=optional, org.gjt.xpp;resolution:=optional, org.jdom.*;resolution:=optional, org.relaxng.datatype;resolution:=optional, org.xmlpull.v1;resolution:=optional, * </Import-Package> </instructions> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.scr.annotations</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.osgi.core</artifactId> <version>1.4.0</version> </dependency> <dependency> <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-core</artifactId> <version>2.4.3</version> </dependency> <dependency> <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-jcr-commons</artifactId> <version>2.4.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.api</artifactId> <version>2.2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>javax.jcr</groupId> <artifactId>jcr</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>com.day.cq.wcm</groupId> <artifactId>cq-wcm-api</artifactId> <version>5.5.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.day.cq</groupId> <artifactId>cq-commons</artifactId> <version>5.5.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.json</artifactId> <version>2.0.6</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.scheduler</artifactId> <version>2.3.4</version> <scope>provided</scope> </dependency> <!-- HttpClient --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.2.1</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> <version>4.2.1</version> </dependency> <!-- WSDL --> <dependency> <groupId>com.globalsight.jaxrpc</groupId> <artifactId>jaxrpc</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.globalsight.log</groupId> <artifactId>log</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.globalsight.mail</groupId> <artifactId>mail</artifactId> <version>1.4.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.globalsight.saaj</groupId> <artifactId>saaj</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.globalsight.wsdl</groupId> <artifactId>wsdl</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId> <version>0.2</version> <scope>provided</scope> </dependency> <!-- dom4j --> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> </dependency> <!-- aem email --> <dependency> <groupId>com.day.cq</groupId> <artifactId>cq-mailer</artifactId> <version>5.6.2</version> <scope>provided</scope> </dependency> </dependencies> <repositories> <repository> <id>adobe</id> <name>Adobe Public Repository</name> <url>http://repo.adobe.com/nexus/content/groups/public/</url> <layout>default</layout> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>adobe</id> <name>Adobe Public Repository</name> <url>http://repo.adobe.com/nexus/content/groups/public/</url> <layout>default</layout> </pluginRepository> </pluginRepositories> </project>
String jobName = job.getJobName(); String target = job.getTarget(); logger.info("Done message: job " + jobName + " translated into " + target + " is completed."); try { MessageGateway<Email> messageGateway; Email email = new SimpleEmail(); String emailToRecipients = "brian.lei@163.com"; email.addTo(emailToRecipients); email.setSubject("Job Done Message"); email.setFrom("test@adobe.com"); email.setMsg("This message is to inform you that the job \'" + jobName + "\' translated into language " + target + " has been completed!"); messageGateway = messageGatewayService.getGateway(Email.class); messageGateway.send((Email) email); }catch(Exception ex){ logger.error("Error post email: " +ex); }
But when i try to run command "mvn clean install" it appears error following:
[img]mailerror.png[/img]
Anyone knows how to manage to this problem?
Thanks a lot.
Best regards,
Brian
Solved! Go to Solution.
Views
Replies
Total Likes
See this community article. Covers your use case
https://helpx.adobe.com/experience-manager/using/creating-custom-cq-email-services.html
in this article, we use Java MAIL API and wrap the code into a bundle using Eclipse plugin project.
If you want to use Message Service Gateway, see
https://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html
Views
Replies
Total Likes
See this community article. Covers your use case
https://helpx.adobe.com/experience-manager/using/creating-custom-cq-email-services.html
in this article, we use Java MAIL API and wrap the code into a bundle using Eclipse plugin project.
If you want to use Message Service Gateway, see
https://helpx.adobe.com/experience-manager/using/creating-custom-aem-workflow-steps.html
Views
Replies
Total Likes
Can you first try to use https://repo.adobe.com/ instead of http://repo.adobe.com/
Views
Replies
Total Likes
Thanks,
Kishore
Views
Replies
Total Likes
hi feike, thank you for your comments, and i try changing that but no help for that error.
I have to continue resarech it.
Views
Replies
Total Likes
what version of maven do you have installed?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies