After creating a user by admin, a welcome mail should be sent to the user's email address with login credentials i.e. username (user's email) and password.
Can you help me in the smtp settings as well?
Thank You!
After creating a user by admin, a welcome mail should be sent to the user's email address with login credentials i.e. username (user's email) and password.
Can you help me in the smtp settings as well?
Thank You!
I needed this functionality once and got it working by creating a method in my mailer
def welcome_email(user,password)
@user = user
@password = password
mail(to: @user.email, subject: 'Welcome Email')
end
In my welcome_email.html.erb :
<p>Dear <%= @user.name %>,</p>
<p> Welcome to this site. Your account has successfully been created. </p>
<p> Please Login to your account</a> using these credentials: </p>
<ul>
<li>Username: <%= @user.email %></li>
<li>Password: <%= @password %></li>
</ul>
And call this method from your devise users/registration_controller in create action after creating the user.
MyMailer.welcome_email(resource,params[:user][:password]).deliver_later
you might have to change the code according to your needs, but you'll get an idea as from where to start.
For SMTP settings, see this