How to Send E-Mails From Hybris Commerce Using Google Mail?

At a recent client engagement, the client asked to review the Hybris Commerce Out-of-the-Box (OOTB) email templates' copy early in the project. During this engagement, I worked off-site on most days, and could not reliably access the client's SMTP Server to send emails from Hybris. In this situation, I decided to use my Gmail account to send Hybris emails to the client directly. In this tutorial, I will demonstrate how to send emails from Hybris Commerce using Google Mail (Gmail).

Prerequisites: To complete this tutorial, you will need a Google Mail (Gmail) account.

Note: Hybris Commerce 6.x OOTB has SMTP disabled in the project. properties file.

  1. Copy the commented SMTP configuration settings from the project.properties file, then paste these settings into the local.properties file in your preferred IDE. It's considered a best practice to make custom changes to the local.properties (located in the config directory) file instead of modifying the project.properties file. For good measure, I will also update the mail.from and mail.replyto properties. After pasting the SMTP settings into the local.properties file, the local.properties file should now include the following settings:
  2. Un-comment the SMTP Settings in the local.properties file. Remove the (#) symbols at the beginning of each SMTP configuration setting.
    Your local.properties file should now resemble the following:
  3. Update the SMTP Settings with your Google Mail (Gmail) settings and set mail.use.tls to true . Insert your gmail.com address where you see info@hybrisarchitect.com in the next screen capture. Note: Google Mail is the email provider for hybrisarchitect.com. Custom domain email addresses hosted with Google Mail are also supported. The following settings are required to send emails using Google Mail:
    mail.smtp.server=smtp.gmail.com
    mail.smtp.port=587
    mail.smtp.user=INSERT_YOUR_GOOGLE_MAIL_ADDRESS
    mail.smtp.password=INSERT_YOUR_GOOGLE_MAIL_PASSWORD_HERE
    mail.use.tls=true

  4.  Open the command prompt.
  5. Go to <HYBRIS_BIN_DIR>/platform , and start Hybris by running hybrisserver.bat (Windows) or ./hybrisserver.sh (Linux).
    No need to perform an ant all command, it's not required for property file modifications. However, you will need to stop Hybris, if it is currently running, then restart by running the hybrisserver.bat or /hybrisserver.sh. After several minutes, Hybris should be up and running.
  6. Sign into HAC to verify the email settings are configured properly in Hybris.

  7.  Once you've signed in successfully, click on Platform-> Configuration.
  8. Type SMTP into the Search Box to confirm the SMTP settings have been properly configured in Hybris. The mail.smtp.password, mail.smtp.port, mail.smtp.server and mail.smtp.user should contain the values set in the local.properties file in step #3.
  9. Type tls into the Search Box to confirm the mail.use.tls setting has been properly set to true.
  10. The tutorial is complete, now you know how to send e-mails from Hybris Commerce using Google Mail.

 

Troubleshooting notes

If you receive the following error: Script execution has failed [reason: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587]
1. Go to your Google Account's Less Secure Apps page: https://myaccount.google.com/lesssecureapps
2. Set Allow less secure apps to ON


Watch the Video 

How to Send E-Mails From Hybris Commerce Using Google Mail (Video Edition)

 


Marc Raygoza

Marc is the Founder of HybrisArchitect.com.
He enjoys helping others learn more about SAP Commerce Cloud (Hybris). Marc is a SAP Commerce Certified Professional and has held the role of SAP Commerce Cloud Architect at Deloitte, PwC, Brillio (a Bain Company), and Nasty Gal. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at: mraygoza@hybrisarchitect.com

You may also like...

Popular Posts