1
DoAGM
Please Help with xoopsmail issue
  • 2006/6/10 3:34

  • DoAGM

  • Just popping in

  • Posts: 2

  • Since: 2006/6/10


I installed XOOPS last week and have got everthing going almost how I want, there is just one last thing that I really really want to be able to do.

I have a number of groups on my XOOPS website, I want to send an e-mail to a user when I add them to a particular group. I have got most of the way there, but I can't seem to bring it home. The script is definately running through and variables are assigned correctly at the appropriate time (ie. when the group is question is modified). The member is added to the appropriate group, but no e-mail is sent. :(

Can anyone see any holes in my script as to why it won't send e-mails. Please please help, I want this site to go live tomorrow but don't want it to go live till this is fixed.

Here is the script as it stands at the moment:

case "addUser":
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header("admin.php?fct=groups&op=adminMain", 3, implode('
', $GLOBALS['xoopsSecurity']->getErrors()));
}
$member_handler =& xoops_gethandler('member');
$size = count($uids);
for ( $i = 0; $i < $size; $i++ ) {
$thisuser =& $member_handler->getUser($uids[$i]);
$thisuseremail = $thisuser->getvar('email');
$member_handler->addUserToGroup($groupid, $uids[$i]);
}
if ($groupid == 4) {
$config_handler =& xoops_gethandler('config');
$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
$myts =& MyTextSanitizer::getInstance();
$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setTemplate('activated.tpl');
$xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
$xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
$xoopsMailer->assign('SITEURL', XOOPS_URL."/");
$xoopsMailer->setToUsers($thisuseremail);
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT,$xoopsConfig['sitename']));
include 'header.php';
if ( !$xoopsMailer->send() ) {
printf(_US_ACTVMAILNG, $thisuser->getVar('uname')); // Script doesn't use this line (but it should due to no e-mail being sent?)
} else {
redirect_header("admin.php?fct=groups&op=modify&g_id=".$groupid."",0,_AM_DBUPDATED); // This line is run
}
include 'footer.php';
}
redirect_header("admin.php?fct=groups&op=modify&g_id=".$groupid."",0,_AM_DBUPDATED); // This line is run when using a different group.
break;

2
rabideau
Re: Please Help with xoopsmail issue
  • 2006/6/10 12:51

  • rabideau

  • Home away from home

  • Posts: 1042

  • Since: 2003/4/25


Have you tested your email send (setup) using the standard script? Does it work with the standard setup? If it does then the propblem is in your script, probably. If not the problem might be in your email variables and setup. I have had problems with that in the past....

Just a thought.
Pax vobiscum,
...mark

may the road rise to meet your feet!

http://treemagic.org

3
DoAGM
Re: Please Help with xoopsmail issue
  • 2006/6/10 23:57

  • DoAGM

  • Just popping in

  • Posts: 2

  • Since: 2006/6/10


Hi,

Thanks for your reply. Yes, the website can send out e-mails as parts of other modules (user registration etc). I have spent more time on this and discovered this:

Using the $Xoopsmailer->setbody($something) function allows the e-mail to be sent. However using the $Xoopsmailer->SetTemplateDir(XOOPS_ROOT_PATH."/language/english/mail_template") together with $xoopsmailer->SetTemplate("Sometemplate.tpl") doesn't work.

One possible reason for this is the XOOPS_ROOT_PATH appears to be blank (although this is not picked up by Xoopsmailer.php as it appears to be required to do and this is not the case in other areas of the website).

I have concluded from this that I am missing an include somewhere down the line, but I don't know what one, I am including Mainfile.php and xoopsmailer.php. These are the only includes I have added to the standard /modules/system/admin/groups/main.php file. Everything else I have added you can see here.

The website is working at the moment, but I would really prefer to have this e-mail set up to use templates rather that the setbody function.

Any advise would be greatly appreciated.

4
sceilig
Re: Please Help with xoopsmail issue
  • 2006/6/16 3:29

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


I havent looked at your code too deep but I think part of the problem might be this line.
$xoopsMailer->setToUsers($thisuseremail);

SetToUsers would be looking for a User object being passed to it.
Try using
$xoopsMailer->setToEmails($thisuseremail);

Login

Who's Online

282 user(s) are online (227 user(s) are browsing Support Forums)


Members: 0


Guests: 282


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits