Email related settings in Lift
I think Lift's MegaProtoUser is a good starting point when you want to create a web site that requires user management. It basically gives you the basic features for those sites, such as sign-up form, confirmation email and password reset.
When a user submits the sign-up form, an email will be sent to him. But, you might want to customize the email settings. I'll get you through the code and settings for changing the behavior.
Settings and code
SMTP server
The default SMTP server that Lift uses is "localhost". To change it, add an entry like the following in your project's property file.
mail.smtp.host=smtp.example.com
You should find a file named default.props, production.default.props or some such under
The property is used in net.liftweb.util.Mailer object.
From: field
The default value of "From" header is "noreply@
You can override this in your User object, which extends MetaMegaProtoUser.
Mail subject and boy
In net.liftweb.proto.ProtoUser trait, you'll also see the methods listed below:
- signupMailSubject
- signupMailBody
- passwordResetEmailSubject
- passwordResetMailBody
You can override these methods in your User singleton object.
It's not that elegant that ProtoUser holds subject and body text, but at least it's customizable.
Conclusion
Lift offers variety of ready-to-use features. It also gives you flexibility of customizing the behavior. This entry explains how to customize email related features with pointers to the source code. I hope this will help some of you.