Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to debug emails in LF7?
Václav Suchánek, modificado hace 7 años.
Junior Member
Mensajes: 26
Fecha de incorporación: 15/08/18
Mensajes recientes
Hello,
Is there an easy way how to trace/debug outcoming emails?
My scenario:
I am implementing in ServiceConfiguration.java custom email templates (custom.tmpl) for actions - article added and update.
My feature is ready to go, but i don't know how to debug these customized emails.
I have tried these methods:
1) To create 2 testing accounts (allowing them email notification in Account settings -> Alerts and Annoucements delivery)
Results was: Only notifications were sent but no emails. Tested on default MessageBoards portlet and Wiki portlet.
2) Follow this blog: https://community.liferay.com/blogs/-/blogs/how-to-trace-mail-in-liferay-portal
To set debug level in Server administration or in portal-log4j-ext.xml on email related categories.
To set debug level in Server Administration -> Log Levels -> set debug level on com.liferay.mail.service.impl.MailServiceImpl and on all mail category related items.
Result was: Only one line in tomcat console showed up:
2019-03-13 10:34:16.033 DEBUG [liferay/subscription_sender-1][MailServiceImpl:257] sendEmail
This line is nice, but i would like to know the email body.
Is there an another way or recomendation how to do it? Maybe use some extension/overrides for debugging MailServiceImpl methods? Or somehow work with an optional JavaMail properties in mail server administration?
My env:
liferay ce portal 7.1.2 ga3
tomcat 9.0.10
tested on localhost
Thanks in advance.
Vaclav
Is there an easy way how to trace/debug outcoming emails?
My scenario:
I am implementing in ServiceConfiguration.java custom email templates (custom.tmpl) for actions - article added and update.
My feature is ready to go, but i don't know how to debug these customized emails.
I have tried these methods:
1) To create 2 testing accounts (allowing them email notification in Account settings -> Alerts and Annoucements delivery)
Results was: Only notifications were sent but no emails. Tested on default MessageBoards portlet and Wiki portlet.
2) Follow this blog: https://community.liferay.com/blogs/-/blogs/how-to-trace-mail-in-liferay-portal
To set debug level in Server administration or in portal-log4j-ext.xml on email related categories.
To set debug level in Server Administration -> Log Levels -> set debug level on com.liferay.mail.service.impl.MailServiceImpl and on all mail category related items.
Result was: Only one line in tomcat console showed up:
2019-03-13 10:34:16.033 DEBUG [liferay/subscription_sender-1][MailServiceImpl:257] sendEmail
This line is nice, but i would like to know the email body.
Is there an another way or recomendation how to do it? Maybe use some extension/overrides for debugging MailServiceImpl methods? Or somehow work with an optional JavaMail properties in mail server administration?
My env:
liferay ce portal 7.1.2 ga3
tomcat 9.0.10
tested on localhost
Thanks in advance.
Vaclav
Fernando Fernandez, modificado hace 7 años.
Expert
Mensajes: 401
Fecha de incorporación: 22/08/07
Mensajes recientes
Hi Václav,
As a complement to debugging the emails inside the Liferay stack, I find a tool like FakeSMTP very useful. It's a fake server you can use on your dev machine and "trap" outgoing emails, allowing you to immediatly look at headers and message bodies.
HTH
Fernando
As a complement to debugging the emails inside the Liferay stack, I find a tool like FakeSMTP very useful. It's a fake server you can use on your dev machine and "trap" outgoing emails, allowing you to immediatly look at headers and message bodies.
HTH
Fernando
Jan Tošovský, modificado hace 7 años.
Liferay Master
Mensajes: 576
Fecha de incorporación: 22/07/10
Mensajes recientes
Seeing the code responsible for sending emails I am afraid that log level settings won't help here anymore:
https://github.com/liferay/liferay-portal/blob/0a5bb514913ee7e6f765926451900f8c7967fc48/portal-impl/src/com/liferay/mail/service/impl/MailServiceImpl.java#L260
After printing "sendEmail" message the task is forwarded to the MessageBus, where I am loosing the track what is done next.
https://github.com/liferay/liferay-portal/blob/0a5bb514913ee7e6f765926451900f8c7967fc48/portal-impl/src/com/liferay/mail/service/impl/MailServiceImpl.java#L260
After printing "sendEmail" message the task is forwarded to the MessageBus, where I am loosing the track what is done next.
Olaf Kock, modificado hace 7 años.
Liferay Legend
Mensajes: 6441
Fecha de incorporación: 23/09/08
Mensajes recientes
Jan TošovskýThis might be the actual sender
After printing "sendEmail" message the task is forwarded to the MessageBus, where I am loosing the track what is done next.
Jan Tošovský, modificado hace 7 años.
Liferay Master
Mensajes: 576
Fecha de incorporación: 22/07/10
Mensajes recientes
So emails are sent using petra-mail module: https://github.com/liferay/liferay-portal/blob/master/modules/apps/petra/petra-mail/src/main/java/com/liferay/petra/mail/MailEngine.java
The logging is still available, but it cannot be activated directly from the Server Administration as it is not a core LR functionality any more. So the only way to enable debugging is to tweak log4j properties:
Tested, it works.
Btw, for testing you can generate emails via script. Go to the Script tab in the Server Administration and paste this Gist:
https://gist.github.com/jan-tosovsky-cz/56cd44d3216fb056d9b4259a997a9e86
Jan
The logging is still available, but it cannot be activated directly from the Server Administration as it is not a core LR functionality any more. So the only way to enable debugging is to tweak log4j properties:
<logger name="com.liferay.petra.mail">
<level value="DEBUG" />
</logger>Tested, it works.
Btw, for testing you can generate emails via script. Go to the Script tab in the Server Administration and paste this Gist:
https://gist.github.com/jan-tosovsky-cz/56cd44d3216fb056d9b4259a997a9e86
Jan
Scott McIntosh, modificado hace 6 años.
New Member
Mensajes: 9
Fecha de incorporación: 26/03/10
Mensajes recientes
I know this is an old thread, but in case anyone comes looking I wanted to say that I had no problem setting com.liferay.petra.mail.MailEngine to DEBUG via the Server Administration.
Community
Company
Feedback