{"id":20208,"date":"2013-12-20T08:34:11","date_gmt":"2013-12-20T14:04:11","guid":{"rendered":"https:\/\/www.solutionanalysts.com\/blog\/send-an-email-from-liferay-portal\/"},"modified":"2023-08-16T23:02:47","modified_gmt":"2023-08-17T04:32:47","slug":"send-email-liferay-portal","status":"publish","type":"post","link":"https:\/\/www.solutionanalysts.com\/blog\/send-email-liferay-portal\/","title":{"rendered":"Send an Email from Liferay Portal"},"content":{"rendered":"<p class=\"\">If you want to send an email from your liferay portal then its bit easy because liferay provide an Utility class called MailEngine.So we don&#8217;t have to play with direct JavaMail API.<\/p>\n<p class=\"\">In this article, we\u2019ll use Gmail as SMTP<\/p>\n<h3><strong>Below are the steps to send an email in Liferay.<\/strong><\/h3>\n<ul>\n<li>Configure your SMTP provider, outgoing port, user id and password.<\/li>\n<li>Login as super user in your liferay portal<\/li>\n<li>Go to Control Panel<\/li>\n<li>Click on Server Administration from server section<\/li>\n<li>Click on Mail Tab<\/li>\n<li>Fill out the SMTP fields here,<\/li>\n<li>Set Outgoing SMTP Server (E.g. smtp.gmail.com)<\/li>\n<li>Set Outgoing Port (E.g. 465)<\/li>\n<li>Check the box of Use a Secure Network Connection if you want.<\/li>\n<li>Set User Name and Password.<\/li>\n<li>Press \u201cSave\u201d Button<\/li>\n<li>You are done with SMTP configuration of outgoing mail sever<\/li>\n<li>In your MVCPortlet or related class add the below peace of code to send an email.<\/li>\n<\/ul>\n<p><code>MailMessage mailMessage = new MailMessage();<br \/>\nmailMessage.setHTMLFormat(true);<br \/>\nmailMessage.setBody(\"set body here\");<br \/>\nmailMessage.setFrom(new InternetAddress(\"fromAddress\",\"fromName\"));<br \/>\nmailMessage.setSubject(\"set mail subject here\");<br \/>\nmailMessage.setTo(new InternetAddress(\"set receiver email id here\"));<br \/>\nmailEngine.send(mailMessage);<\/code><\/p>\n<ul>\n<li>If you want to add attachment to your email or you want to add Cc you can use below send method of MailEngine class,<\/li>\n<\/ul>\n<p><code>send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,<br \/>\nString subject, String body, boolean html format, InternetAddress[] replyTo, String messageId,<br \/>\nString inReplyTo, File[] attachments);<\/code><\/p>\n<p class=\"\">I hope this tutorial will help you.. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to send an email from your liferay portal then its bit easy because liferay provide an Utility class called MailEngine.So we don&#8217;t have to play with direct JavaMail API. In this article, we\u2019ll use Gmail as SMTP Below are the steps to send an email in Liferay. Configure your SMTP provider, outgoing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20209,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-20208","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mobile-app"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/comments?post=20208"}],"version-history":[{"count":1,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20208\/revisions"}],"predecessor-version":[{"id":38579,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/posts\/20208\/revisions\/38579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/media\/20209"}],"wp:attachment":[{"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/media?parent=20208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/categories?post=20208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.solutionanalysts.com\/blog\/wp-json\/wp\/v2\/tags?post=20208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}