简体   繁体   中英

Forgot password: How can I send an email to user in DotNetNuke

I have made custom login control for DNN (DotNetNuke). Now I am trying to implement the forgot password feature. I am able to retrieve password from the database using the code:

UserInfo uInfo = UserController.GetUserByName(this.PortalId, userName);
if (uInfo != null)
{
    string password = UserController.GetPassword(ref uInfo, String.Empty);
}

I want to send the retrieved password to the user using DNN.

Any help will be appreciated.

Sending passwords via email is considered as a big security vulnerability and really not recomended .

If you still need this functionality though, I guess you can simply accomplish this by sending email through SendMail or SendEmail methods:

DotNetNuke.Services.Mail.Mail.SendEmail()
DotNetNuke.Services.Mail.Mail.SendMail()

The SendMail method provides more options/parameters than the SendEmail method. The paramters names should be self explanatory enough to use the methods.

The simplest way to send a user their password is to call the DotNetNuke.Services.Mail.Mail.SendMail overload that takes a UserInfo , a MessageType , and PortalSettings . You can pass in the user and MessageType. PasswordReminder MessageType. PasswordReminder and DNN will take care of the rest.

That said, I join the crowd in saying that it would be much better to switch to using hashed passwords and consider this an impossible feature request (that should, instead, be fulfilled with a password reset feature).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM