User Login    
 + Register
  • Main navigation
Login
Username:

Password:


Lost Password?

Register now!
Documentation
Who's Online
121 user(s) are online (6 user(s) are browsing XoopsWiki)

Members: 2
Guests: 119

julius-leo, bravo, more...
[Main Page]

Dev:XoopsMailer

From XOOPS Project

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: Development

This class is sometimes overlooked or not used my module developers, here is an example using a template rather than enter the content of the email with the PHP Code. This keeps the whole process cleaner and easir to manage.

I think it would be an excellent feature to allow webmasters access via the module to edit these templates in future. thus giving them more control over the email content. Needed include for emailer

include XOOPS_ROOT_PATH."/class/xoopsmailer.php"; Set up the email class

   $xoopsMailer =& getMailer();
   $xoopsMailer->useMail();

Sets the template directory, in this example we are using the language directory. This can be useful if we need the email in more than one language.

   $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH.'/modules/wfchannel/language/'.$xoopsConfig['language'].'/mail_template');

Sets the file to be used for this email

   $xoopsMailer->setTemplate("refer.tpl");

Now we setup needed vars for this email Email address we will be sending too

   $xoopsMailer->setToEmails($remail);

Email address and uname sending from

   $xoopsMailer->setFromEmail($semail);
   $xoopsMailer->setFromName($sname);

This is the email subject line

   $xoopsMailer->setSubject($subject);

Use can assign other information to be used within the body of the email if you wish

   $xoopsMailer->assign("MESSAGE", $message);
   $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']);
   $xoopsMailer->assign("SITEURL", XOOPS_URL."/");
   $xoopsMailer->assign("TITLE", _MD_MESSAGETITLE);

Send the email, without verifying

   $xoopsMailer->send();

or, with verifying

   if ( !$xoopsMailer->send() ) {
   'print error and return'
   } else {
   //do something else to indicate success
   }

Example email template

Hello.

You have received one request to become partner of your site {SITENAME} The request was sent by the user {USER} from the IP {IP} The information you provide us in the join form was:

Títle: {TITLE} URL: {URL} Image: {IMAGE} Description: {DESCRIPTION}

Can add this request from this url: {SITEURL}modules/xoopspartners/admin/index.php?op=partners_manage_add

{SITENAME} ({SITEURL})

Catzwolf


Back to Main Page

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/Dev:XoopsMailer"

This page has been accessed 420 times. This page was last modified 17:21, 15 December 2007. Content is available under XOOPS Project.


Local Support Sites
Powered by
XOOPS Code hosted on SourceForge

Powered by PHP



Powered by MySQL

Powered by Smarty

OSI certified

All content on this site is subject to the Creative Commons License
Developers for Hire