Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forgot Password don't send a email #1060

Closed
Raceeend opened this issue Jan 18, 2021 · 8 comments
Closed

Forgot Password don't send a email #1060

Raceeend opened this issue Jan 18, 2021 · 8 comments

Comments

@Raceeend
Copy link
Contributor

Forgot Password or sending a notification to another user.
This has already been reported (and closed) but I am not getting it working.

When I look in the code I see that a notification has no ToEmail when the Job is executed and therefore no message can be sent (a mailadress need a valid email address).

However, the ToUserId is available.
It goes wrong on ines 86-90 in NotificationJob.cs:
if (notification.ToUserId! = null)
{
mailMessage.To.Add (new MailAddress (user.Email, user.DisplayName)); <--- Error
mailMessage.Body + = "To:" + user.DisplayName + "<" + user.Email + ">" + "\ n";
}

Is this a setting problem (do I something wrong) or else?

@sbwalker
Copy link
Member

The code you posted above looks different than the code in the NotificationJob:

                            if (notification.ToUserId != null)
                            {
                                mailMessage.To.Add(new MailAddress(notification.ToEmail, notification.ToDisplayName));
                                mailMessage.Body += "To: " + notification.ToDisplayName + "<" + notification.ToEmail + ">" + "\n";
                            }
                            else
                            {
                                mailMessage.To.Add(new MailAddress(notification.ToEmail));
                                mailMessage.Body += "To: " + notification.ToEmail + "\n";
                            }

If ToUserId has been specified for a Notification then the system retrieves the ToEmail and ToDisplayName from the User table. If ToUserId has not been specified for a Notification then the system expects that the ToEmail has been explicitly provided.

@sbwalker
Copy link
Member

Are you using the latest code in the dev branch? I am asking because there was an issue related to the Sender which was fixed recently in #1044

@artmedia
Copy link
Contributor

artmedia commented Jan 18, 2021

Me too I'm trying to send password, without success.
After downloading the latest code in the dev branch (added Email Sender in SMTP config),
I click on "Forgot Password" and then in Notification Job I see this message:
"The parameter 'address' cannot be an empty string. (Parameter 'address')"

I don't understand which 'address' is.
In Profile Management I removed all fields but FirstName and LastName, is it the reason for the message?
Anyway email was not sent

@sbwalker
Copy link
Member

My apologies.... after further research I was able to determine that the original API was modified to prevent the leakage of user information which caused an impact to the sending of notifications. The original API included joins from the Notification table to the User table - which is how the FromEmail and ToEmail properties were populated. These joins were removed in PR #581. Thank you for reporting this issue - I will submit a new PR to fix the problem.

@sbwalker
Copy link
Member

This should be fixed in #1065. The Notification API now relies on the ToEmail/ToDisplayName properties rather than ToUserId ( although if you only specify ToUserId and do not provide ToEmail/ToDisplayName it will retrieve them in the NotificationJob ). I also added some additional constructors to the Notification class to simplify the creation of objects and abstract the more internal properties.

@sbwalker
Copy link
Member

@artmedia @Raceeend please let me know if the latest changes resolve your problem

@artmedia
Copy link
Contributor

I confirm that now email to User Password Reset is sent succesfully.
Thanks

@Raceeend
Copy link
Contributor Author

Sorry for mine late respons. But yes its working fine. The problem is solved. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants