Message Boards

Sending twice mail

Piotr Krzesniak, modified 3 Years ago.

Sending twice mail

New Member Posts: 23 Join Date: 7/24/20 Recent Posts
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 : )
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Sending twice mail

Liferay Legend Posts: 6396 Join Date: 9/23/08 Recent Posts
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?
Piotr Krzesniak, modified 3 Years ago.

RE: Sending twice mail

New Member Posts: 23 Join Date: 7/24/20 Recent Posts
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.
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.
Piotr Krzesniak, modified 3 Years ago.

RE: Sending twice mail

New Member Posts: 23 Join Date: 7/24/20 Recent Posts
Anyone ?
thumbnail
Krzysztof Gołębiowski, modified 3 Years ago.

RE: Sending twice mail

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
Piotr Krzesniak, modified 3 Years ago.

RE: Sending twice mail

New Member Posts: 23 Join Date: 7/24/20 Recent Posts
Okay, thank you for helping emoticon