Combu  3.2.2
Unity API Documentation
Email configuration and Reset Password

Table of Contents

In this section you will learn how to setup your server to send email to clients and reset the user's password.

Server configuration

To enable sending mails to your users you need to set REGISTER_EMAIL_REQUIRED to TRUE in /lib/config.php and start to store the users email address.

If you want to send an email as welcome after registration then you also need to set REGISTER_EMAIL_ACTIVATION to TRUE, then set your custom message for subject in REGISTER_EMAIL_SUBJECT and a file name (it must exist in /email_templates) in REGISTER_EMAIL_MESSAGE.

We suggest to create a copy of /email_templates/email_register.html and use it as your own, same for any other sample files that you find in /email_templates which may be overwritten during updates).

The built-in method User.ResetPassword (to reset the password of a user when it has been lost) sends a random generated code by email to the user, so this feature also requires REGISTER_EMAIL_REQUIRED to TRUE. In your interface you need a frame where he can input the code received by email and you call User.ChangePassword like here:

// Generate a random code and send to the user's email address
User.ResetPassword("username", (bool success, string error) =>
Debug.Log(success + " -- " + error);
// User has received the code 'codeReceivedByEmail' by email after ResetPassword
User.ChangePassword(0, "username", "codeReceivedByEmail", "newPasswordChosen", (bool success, string error) =>
Debug.Log("Success: " + success + " --- Error: " + error);

You can customize the email sent to the user by setting RESETPWD_EMAIL_SUBJECT and RESETPWD_EMAIL_MESSAGE (same as above for REGISTER_EMAIL_*).