The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ] 
Author Message
PostPosted: Sun Sep 06, 2009 4:22 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
Hi

I am trying to add an auto-responder to a registration form so that when the user registers, the program will send a form message to their e-mail

Can anyone tell me how to go about doing this?

Thanks

Star6966


Top
 Profile  
 
PostPosted: Sun Sep 06, 2009 7:05 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
Hi,

which version of Joomla do you have?

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Mon Sep 07, 2009 4:55 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
1.0


Top
 Profile  
 
PostPosted: Mon Sep 07, 2009 9:09 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
Please migrate to Joomla 1.5:
http://docs.joomla.org/Upgrading_1.5_fr ... 5x_version

Please note the Joomla 1.0 End-of-Life notice:
http://community.joomla.org/blogs/commu ... f-age.html

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Tue Sep 08, 2009 12:07 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
ok
how would I do it in 1.5?


Top
 Profile  
 
PostPosted: Tue Sep 08, 2009 9:28 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
In Joomla 1.5 you would create a small plugin which listens on an Event like onAfterStoreUser:

http://docs.joomla.org/Reference:User_E ... rStoreUser

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 1:09 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
Ok

and how would I get it to send a message

I am pretty new at this kind of programing

Thanks alot

Star6966


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 1:39 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
would this work in 1.5?

function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;


$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];

if ($isnew)
{
$message = "Test"
$subject = "Test Mail"
mail ($user['email'],$subject,$message,)
}
else
{
}
}


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 8:53 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
You might want to use the JMail class instead:
http://api.joomla.org/Joomla-Framework/Mail/JMail.html

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 12:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
so i would replace mail with JMail

would it still have the form in terms of the
JMail($user['email'],$subject,$message,)?


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 12:12 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
No, it would be more like this:

Code:
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();


Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Wed Sep 09, 2009 5:30 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
So to recap
Would this send an email to a user that created a new account?

Code:
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;


$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];

if ($isnew)
{
$body = "Test"
$subject = "Test Mail"
$email = $user['email']
$name = $user['name']
$recipient = $user['name']
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();
}
else
{
}
}


Top
 Profile  
 
PostPosted: Fri Sep 18, 2009 5:51 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
hey is this right

I just need to know so I can get it up and working

thanks
Star6966


Top
 Profile  
 
PostPosted: Fri Sep 18, 2009 6:38 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
Well, that looks ok. Did you try it? Does is work?

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Fri Sep 18, 2009 8:15 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
i can't try it yet

we are still in the process of migrating to 1.5

i intend to try it as soon as the site is back up and running


Top
 Profile  
 
PostPosted: Mon Oct 12, 2009 8:45 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
so I tried it and nothing

I am not sure if it has something to do with the way i installed it
or maybe the rest of the code

i am posting the entire code here
Code:
<?php


defined('_JEXEC') or die( 'Restricted access' );


jimport('joomla.plugin.plugin');



class plgUserExample extends JPlugin
{


   
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;


$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];

if ($isnew)
{
$body = "Test"
$subject = "Test Mail"
$email = $user['email']
$name = $user['name']
$recipient = $user['name']
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();
}
else
{
}
}
}


that is the .php file

and here is the .xml file
Code:
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5.2" type="plugin" group="system" method="upgrade">
   <name>System - Test</name>
   <author>Erik Smith</author>
   <creationDate>September 2009</creationDate>
   <copyright>Copyright (C) 2008 Holder. All rights reserved.</copyright>
   <license>GNU General Public License</license>
   <authorEmail>Star6966@hotmail.com</authorEmail>
   <authorUrl></authorUrl>
   <version>1.0.1</version>
   <description>A test system plugin</description>
   <files>
      <filename plugin="example">test2.php</filename>
   </files>
   <params>
        <param name="Test"
        type="text"
        default=""
        label="Test"
        description="An example text parameter" />
   </params>
</install>


I have the files
test.php
and
test.xml
in a zip file which i can install, but if i register a user, no response
any suggestions


Top
 Profile  
 
PostPosted: Sun Oct 18, 2009 9:13 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
and did you enable the plugin in the plugin manager?

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 12:20 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
Yes I did


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 9:21 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
The code is missing a couple of semicolons and the Recipient is not an email address. Moreover, the name of the plugin is test2 and in the system group but your plugin class is using this plgUserExample

You can also check if the mail was send like this:
http://docs.joomla.org/JFactory/getMailer

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 8:13 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
So here is the code thus far
I am still not sure what to put for the address
Code:
<?php


defined('_JEXEC') or die( 'Restricted access' );


jimport('joomla.plugin.plugin');



class test2 extends JPlugin
{


   
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;


$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];

if ($isnew)
{$mail =& JFactory::getMailer();
 
$config =& JFactory::getConfig();
$mail->addRecipient( $config->getValue( 'What do I put here' ) );
$mail->setSubject( 'Test message' );
$mail->setBody( 'This is an example email to test the Joomla! JFactory::getMailer() method.  Please ignore it' );
 
if ($mail->Send()) {
  echo "Mail sent successfully.";
} else {
  echo "An error occurred.  Mail was not sent.";
}

else
{
}
}
}


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 8:38 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
the class is not test2, it would be more like this plgSystemTest2

or if you use the group user: plgUserTest2

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 9:49 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
anything else?


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 10:04 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
Who is the supposed to be the recipient? You might want to consider to use a user plugin instead of a system plugin.

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Mon Oct 19, 2009 10:51 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
I want the recipient to be every new user


Top
 Profile  
 
PostPosted: Tue Oct 20, 2009 7:41 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
well, then you would need to use the email address in the $mail->addRecipient method:

Code:
$mail->addRecipient($user['email']);

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
PostPosted: Tue Oct 20, 2009 9:43 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Sep 06, 2009 4:11 pm
Posts: 17
what is the difference between a user plugin and a system plugin


Top
 Profile  
 
PostPosted: Tue Oct 20, 2009 10:44 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 10943
Location: Ireland
Have a look here:
http://docs.joomla.org/Reference:System ... gin_System
http://docs.joomla.org/Reference:User_E ... gin_System

Olaf

_________________
Olaf Offick - Global Moderator
http://learnskills.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 27 posts ] 



Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group