{"id":2629,"date":"2013-10-09T01:30:44","date_gmt":"2013-10-08T23:30:44","guid":{"rendered":"http:\/\/www.dontesta.it\/blog\/?p=2629"},"modified":"2017-07-13T16:58:50","modified_gmt":"2017-07-13T14:58:50","slug":"how-to-send-email-from-liferay-portlet","status":"publish","type":"post","link":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/","title":{"rendered":"How to send email from Liferay Portlet"},"content":{"rendered":"<p><\/p>\n<p style=\"text-align: justify;\">Often there is the need of having to send email from your application. Each development platform provides its own tools to perform this task and the Java platform provides this capability natively through the <a title=\"JavaMail API Framework\" href=\"http:\/\/www.oracle.com\/technetwork\/java\/javamail\/index.html\" target=\"_blank\" rel=\"noopener\"><em>JavaMail<\/em><\/a> framework.<\/p>\n<p style=\"text-align: justify;\">From Liferay platform (Java based) is obviously possible (\"with no prohibition\") using <em>JavaMail<\/em> to send email from the portlet. In general, my idea is that using the tools offered by the development platform, is the best way to go. To send email notifications, Liferay provides the <a title=\"INTRODUZIONE A LIFERAY MESSAGE BUS \" href=\"https:\/\/www.dontesta.it\/2013\/03\/29\/introduzione-a-liferay-message-bus\/\" target=\"_blank\" rel=\"noopener\">Message Bus<\/a>, avoiding the direct use of the <em>JavaMail API<\/em> making it easier operation.<\/p>\n<p style=\"text-align: justify;\">There are two destinations configured on the Message Bus that allow you to send email:<\/p>\n<ul>\n<li><strong>liferay\/subscription_sender<\/strong>: on this target \"answers\" the listener<em>\u00a0SubscriptionSenderMessageListener<\/em><\/li>\n<li><strong>liferay\/mail<\/strong>: on this target \"answers\" the listeneril\u00a0<em>listener\u00a0MailMessageListener<\/em><\/li>\n<\/ul>\n<p style=\"text-align: justify;\">Delivering your message to the Message Bus, on one of the above destinations, the message will be sent (<em>asynchronously<\/em>) via email. Sending emails considers the configuration of Liferay <a title=\"Using the Control Panel \u00bb Server Administration\" href=\"http:\/\/www.liferay.com\/documentation\/liferay-portal\/6.1\/user-guide\/-\/ai\/lp-6-1-ugen12-server-administration-0\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\"><em>Mail<\/em><\/a> (refer to the parameters SMTP).<\/p>\n<p style=\"text-align: justify;\">Messages sent to both destinations are then sent as an email to the recipients, each destination has different responsibilities, in particular:<\/p>\n<ul>\n<li>the messages forwarded via <em>liferay\/subscription_sender<\/em> all those messages are subjected to a \"treatment\" and that will be delivered to those who have subscribed to certain elements:\n<ul>\n<li>Announcements<\/li>\n<li>Blogs<\/li>\n<li>Journal<\/li>\n<li>Message Boards<\/li>\n<li>Wiki<\/li>\n<\/ul>\n<\/li>\n<li>the messages forwarded via <em>liferay\/mail<\/em> are generally simple messages that are sent by \"direct route\" via email<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">On the repository <a title=\"Liferay Message Bus Subscribe Example Portlet\" href=\"https:\/\/github.com\/amusarra\/liferay-messagebus-subscribe-example\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">Liferay Portlet Example Subscribe Message Bus<\/a> is available a complete portlet that shows the use of two different mechanisms for sending email. The sample portlet, send an email containing the list of users who are in off state.<\/p>\n<p style=\"text-align: justify;\">Once again we have seen how the Liferay Message Bus can meet your needs in a simple and effective. The Message Bus service provider as <em>\"send email\"<\/em> avoids the proliferation of dozens of lines of code JavaMail.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Often there is the need of having to send email from your application. Each development platform provides its own tools to perform this task and the Java platform provides this capability natively through the&#46;&#46;&#46;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[490,15],"tags":[190,506,637,227,507,249,314],"class_list":["post-2629","post","type-post","status-publish","format-standard","hentry","category-blog-2","category-liferay","tag-java","tag-javamail","tag-liferay","tag-liferay-api","tag-liferay-message-bus","tag-message-bus","tag-portlet"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to send email from Liferay Portlet<\/title>\n<meta name=\"description\" content=\"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to send email from Liferay Portlet\" \/>\n<meta property=\"og:description\" content=\"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\" \/>\n<meta property=\"og:site_name\" content=\"Antonio Musarra&#039;s Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/antoniomusarrablog\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/antoniomusarrablog\" \/>\n<meta property=\"article:published_time\" content=\"2013-10-08T23:30:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-07-13T14:58:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Antonio Musarra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@antonio_musarra\" \/>\n<meta name=\"twitter:site\" content=\"@antonio_musarra\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Antonio Musarra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\"},\"author\":{\"name\":\"Antonio Musarra\",\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24\"},\"headline\":\"How to send email from Liferay Portlet\",\"datePublished\":\"2013-10-08T23:30:44+00:00\",\"dateModified\":\"2017-07-13T14:58:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\"},\"wordCount\":667,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24\"},\"keywords\":[\"Java\",\"JavaMail\",\"Liferay\",\"Liferay API\",\"Liferay Message Bus\",\"Message Bus\",\"Portlet\"],\"articleSection\":[\"Blog\",\"Liferay\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\",\"url\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\",\"name\":\"How to send email from Liferay Portlet\",\"isPartOf\":{\"@id\":\"https:\/\/www.dontesta.it\/#website\"},\"datePublished\":\"2013-10-08T23:30:44+00:00\",\"dateModified\":\"2017-07-13T14:58:50+00:00\",\"description\":\"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.dontesta.it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to send email from Liferay Portlet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dontesta.it\/#website\",\"url\":\"https:\/\/www.dontesta.it\/\",\"name\":\"Antonio Musarra&#039;s Blog\",\"description\":\"The ideal solution for a problem\",\"publisher\":{\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dontesta.it\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24\",\"name\":\"Antonio Musarra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png\",\"contentUrl\":\"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png\",\"width\":512,\"height\":512,\"caption\":\"Antonio Musarra\"},\"logo\":{\"@id\":\"https:\/\/www.dontesta.it\/#\/schema\/person\/image\/\"},\"description\":\"I began my journey into the world of computing from an Olivetti M24 PC (http:\/\/it.wikipedia.org\/wiki\/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until \u2026 Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.\",\"sameAs\":[\"https:\/\/www.dontesta.it\",\"https:\/\/www.facebook.com\/antoniomusarrablog\",\"https:\/\/www.linkedin.com\/in\/amusarra\/\",\"https:\/\/x.com\/antonio_musarra\",\"https:\/\/www.youtube.com\/channel\/UC5D3_EtVPbZYUhrUcEK_THA\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to send email from Liferay Portlet","description":"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/","og_locale":"en_US","og_type":"article","og_title":"How to send email from Liferay Portlet","og_description":"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.","og_url":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/","og_site_name":"Antonio Musarra&#039;s Blog","article_publisher":"https:\/\/www.facebook.com\/antoniomusarrablog","article_author":"https:\/\/www.facebook.com\/antoniomusarrablog","article_published_time":"2013-10-08T23:30:44+00:00","article_modified_time":"2017-07-13T14:58:50+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png","type":"image\/png"}],"author":"Antonio Musarra","twitter_card":"summary_large_image","twitter_creator":"@antonio_musarra","twitter_site":"@antonio_musarra","twitter_misc":{"Written by":"Antonio Musarra","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#article","isPartOf":{"@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/"},"author":{"name":"Antonio Musarra","@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24"},"headline":"How to send email from Liferay Portlet","datePublished":"2013-10-08T23:30:44+00:00","dateModified":"2017-07-13T14:58:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/"},"wordCount":667,"commentCount":0,"publisher":{"@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24"},"keywords":["Java","JavaMail","Liferay","Liferay API","Liferay Message Bus","Message Bus","Portlet"],"articleSection":["Blog","Liferay"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/","url":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/","name":"How to send email from Liferay Portlet","isPartOf":{"@id":"https:\/\/www.dontesta.it\/#website"},"datePublished":"2013-10-08T23:30:44+00:00","dateModified":"2017-07-13T14:58:50+00:00","description":"Have you wondered how to send emails from Liferay? In this article we will see how to leverage the methods offered by Liferay to send emails.","breadcrumb":{"@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dontesta.it\/en\/2013\/10\/09\/how-to-send-email-from-liferay-portlet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dontesta.it\/"},{"@type":"ListItem","position":2,"name":"How to send email from Liferay Portlet"}]},{"@type":"WebSite","@id":"https:\/\/www.dontesta.it\/#website","url":"https:\/\/www.dontesta.it\/","name":"Antonio Musarra&#039;s Blog","description":"The ideal solution for a problem","publisher":{"@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dontesta.it\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/0c69ed36230e1477875d6171b48b9b24","name":"Antonio Musarra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/image\/","url":"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png","contentUrl":"https:\/\/www.dontesta.it\/wp-content\/uploads\/2024\/06\/cropped-foto_profilo.png","width":512,"height":512,"caption":"Antonio Musarra"},"logo":{"@id":"https:\/\/www.dontesta.it\/#\/schema\/person\/image\/"},"description":"I began my journey into the world of computing from an Olivetti M24 PC (http:\/\/it.wikipedia.org\/wiki\/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until \u2026 Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.","sameAs":["https:\/\/www.dontesta.it","https:\/\/www.facebook.com\/antoniomusarrablog","https:\/\/www.linkedin.com\/in\/amusarra\/","https:\/\/x.com\/antonio_musarra","https:\/\/www.youtube.com\/channel\/UC5D3_EtVPbZYUhrUcEK_THA\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/posts\/2629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/comments?post=2629"}],"version-history":[{"count":0,"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/posts\/2629\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/media?parent=2629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/categories?post=2629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontesta.it\/en\/wp-json\/wp\/v2\/tags?post=2629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}