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: Sending twice mail
Hello, I use a method addUser and set a boolean flag sendEmails to true from a class UserLocalServiceImpl to send an email verification. Unfortunately, i came across to 2 problems.
1) Why do i receive 2 the same emails, one is written in english and second one in my native language ? Obviously, i want to receive only one mail which will be written in the selected default language for the page.
2)My url verification always contains 2 nulls. It looks like this nullnull/portal/update_password?ticketKey=5c795f5b-6056-e95e-54fa-72a052247dc4. Thanks in advance : )
1) Why do i receive 2 the same emails, one is written in english and second one in my native language ? Obviously, i want to receive only one mail which will be written in the selected default language for the page.
2)My url verification always contains 2 nulls. It looks like this nullnull/portal/update_password?ticketKey=5c795f5b-6056-e95e-54fa-72a052247dc4. Thanks in advance : )
More steps to reproduce please.
(exact) version? Who are the mails addressed to? (both to the same account?) How did you set this up? Was it always like this? Did you upgrade from a previous version?
(exact) version? Who are the mails addressed to? (both to the same account?) How did you set this up? Was it always like this? Did you upgrade from a previous version?
Version: Liferay 7.3.4 GA5
This is my addUser method, here i set up where to send emails. For testing purposes i hardcoded my private mail peterczak@wp.pl
try {
UserLocalServiceUtil.addUser(
0, //creatorUserId
companyId, //companyId
true, //autoPassword
"password", //password1
null, //password2
false, //autoScreenName
"Krzesniakowo", //screenName
"peterczak@wp.pl", //emailAddress
0, //facebookId
null, //openId
LocaleUtil.getDefault(), //locale
"Piotr", //firstName
"Jan", //middleName
"Krzesniak", //lastName
0, //prefixId
0, //suffixId
false, //male
0, //birthdayMonth
1, //birthdayDay
1970, //birthdayYear
null, //jobTitle
null, //groupIds
null, //organizationIds
null, //roleIds
null, //userGroupIds
true, //sendEmail
null);
} catch (Exception e) {
in the attachment I am sending photos of my received messages from the server and a sample e-mail. As you can see they are doubled. OPEC is my email sender, i configured this in instance settings -> email sender. And the whole configuration of mail is made in Control Panel > Server Administration > Mail.
This is my addUser method, here i set up where to send emails. For testing purposes i hardcoded my private mail peterczak@wp.pl
try {
UserLocalServiceUtil.addUser(
0, //creatorUserId
companyId, //companyId
true, //autoPassword
"password", //password1
null, //password2
false, //autoScreenName
"Krzesniakowo", //screenName
"peterczak@wp.pl", //emailAddress
0, //facebookId
null, //openId
LocaleUtil.getDefault(), //locale
"Piotr", //firstName
"Jan", //middleName
"Krzesniak", //lastName
0, //prefixId
0, //suffixId
false, //male
0, //birthdayMonth
1, //birthdayDay
1970, //birthdayYear
null, //jobTitle
null, //groupIds
null, //organizationIds
null, //roleIds
null, //userGroupIds
true, //sendEmail
null);
} catch (Exception e) {
in the attachment I am sending photos of my received messages from the server and a sample e-mail. As you can see they are doubled. OPEC is my email sender, i configured this in instance settings -> email sender. And the whole configuration of mail is made in Control Panel > Server Administration > Mail.
Was it always like this? Did you upgrade from a previous version?I haven't done this before, its my first time i used this method.
Attachments:
Anyone ?
Krzysztof Gołębiowski, modified 5 Years ago.
Liferay Master
Posts: 549
Join Date: 6/25/11
Recent Posts
Hi Piotr,
I haven't used this feature for a bit, but I guess that one is just the "email verification" which should be sent first and then after it is successfully verified, the second one is sent as an account creation confirmation. You can set localized text for both of them in "Instance Settings" -> "Email".
In Liferay, some actions are executed based on serviceContext parameter, the last in addUser method which is null in your case. One of them is portalUrl, which is used to generate the hostname for the email. I don't know why both the emails are sent at the same time, but maybe it's also caused by missing serviceContext paramters. The best way to find that out would be to check the original source code in UserLocalServiceImpl.
KG
I haven't used this feature for a bit, but I guess that one is just the "email verification" which should be sent first and then after it is successfully verified, the second one is sent as an account creation confirmation. You can set localized text for both of them in "Instance Settings" -> "Email".
In Liferay, some actions are executed based on serviceContext parameter, the last in addUser method which is null in your case. One of them is portalUrl, which is used to generate the hostname for the email. I don't know why both the emails are sent at the same time, but maybe it's also caused by missing serviceContext paramters. The best way to find that out would be to check the original source code in UserLocalServiceImpl.
KG
Okay, thank you for helping

Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™