6.5 Sending emails
Sending emails from SmartFoxServer Extension is very easy and it allows developers
to send confirmation messages after a user registration, news about the game,
administrator messages etc...
Emails can be formatted as simple text or HTML.
Before you can send email messages from an extension you should configure the SMTP server you're going to use.
» Configuring the SMTP
Open your config.xml file and look for the <Mailer></Mailer> block:
<Mailer> <MailHost>smtp.mail.com</MailHost> <MailUser>myAccount@mail.com</MailUser> <MailPass>myPassword</MailPass> <WorkerThreads>1</WorkerThreads> </Mailer>
|MailHost||Your email SMTP IP address or url|
|MailUser||Your SMTP account|
|MailPassword||Your account password|
|WorkerThreads||The number of threads that should handle the mail taks. By default it is set to 1.
We recommend not to change this value unless you really need it and you understand what java threads are and how they work.
/* * Example of how to send an email. */ var from = "firstname.lastname@example.org" var to = "dickDynamite@mail.com" var subject = "1, 2, 3 ... check!" var message = "Hi there! This email was sent from SmartFoxServer!" var ok = _server.sendMail(from, to, subject, message) if (ok) trace("Mail sent!") else trace("Ooops! Failed sending mail to: " + to)
|from||the email address of the sender|
|to||the email address of the recipient|
|subject||the subject of the email|
|message||a text or html message|