phpFreechat related discussions.
You are not logged in.
Hi, Is there any way to have an email sent to me when someone log's in? Kind of like when their is an email sent to me when someone comment's on my blog? For example, if someone log's in for help, it would be nice if an email was sent out...so someone knows that they need to log in to chat.
Thanks for your help, and great script!
Offline
If should be possible to add a email notifier in the connect command.
Try to modify the pfccommand_connect.class.php to send an email when someone connect.
Offline
Sorry, I don't know how to code that. Maybe I should post in the 'feature request' forum?
Offline
mike909 wrote:
Sorry, I don't know how to code that. Maybe I should post in the 'feature request' forum?
Hi, i like this idea and am in the progress to code this into my chat.
PHP has a simple to use command to send mails, if the server is able to send (most likely the case with linux and sendmail / postfix)
Maybe tomorrow i could post the code here.
NetAndif
Offline
Cool. That would be great if you could post the code and where to put it. I noticed that my blog has this functionality... for example when someone posts a comment, I get an email notification. I found that code and it looks like this:
//send email on comment
$receive_email = "mike@mikealbano.com"; //email of the comment notification receiver
$emailnotification = true; //Use true or false
Offline
Ok, i have the code for sending emails when a user connects to the chat.
I've decided to put the mail command as a function into a seperate file for better handling of updates to the pfc source.
Put the following into a new file:
<?php
function pfcmail ($from_name='', $from_mail='', $to_mail='', $title='', $message='')
{
$from = 'From: ' . $from_name . ' <' . $from_mail . '>';
$message_headers = "$from";
mail($to_mail, $title, $message, $message_headers);
}
?>Upload the file as 'pfcmail.php' to the 'src' folder of phpfreechat.
Then edit the file 'pfccommand_connect.class.php' which is also in the 'src' folder.
Go to the end of the file and find the line with 'return $clientid'.
Right before this line, make a new line and put the following code there:
require_once(dirname(__FILE__)."/pfcmail.php");
pfcmail ('Chat Admin','you@thisserver.com','you@somewhere.com','Chat Login at ' . $c->title ,'The user ' . $c->nick . ' has logged in to your chat');The parameters in order:
'sender name', 'sender email adress', 'recipient email adress', 'mail title', 'mail message'
Offline
Hm, i noticed that at first connect of a user, the variable '$c->nick' is not set here.
Kerphi, what could i do?
Offline
Move the pfcmail(...) call to the pfccommand_nick.class.php file.
Put it near the "%s is connected" notice.
Offline
Yep, works like a charm is correct! Nice job guys & Thank you.
Offline
Hi,
I am using the latest stable release of phpFreeChat (1.0-beta-7) and have tried the modification discussed in this thread with no success. The instructions state to add the pfcmail() function call to the file pfccommand_nick.class.php. However, I do not have that file in the download package. Can anyone help? Thanks Robbie
Offline
the pfccommand_nick.class.php equivalent is src/commands/nick.class.php
Offline
Thanks kerphi - by placing the code in the file you suggested an email is now sent when a user enters the chat which is great. Interestingly the variables $c->title and $c->nick do not hold any values. Do you know what variables should be used for the Chat Room Title and the name of the entered user?
Offline
The new nickname can be found in $param (or in $newnick)
The old nickname can be found in $u->nick (or in $oldnick)
$c->title should work... I don't understand why it returns nothing, did you define it in your parameter list ?
Offline
I understand now, $c->title refers to the PHP variable $params["title"] which I had deliberately kept as an empty string as I did not want it's contents to appear in the chat area. Thanks very much for your help.
Regards
Robbie
Offline
I love this idea for a feature. I'm trying to implement it myself in pfc 1.0 final actually. However it appears to be not working. I never receive any a email message nor do I receive error messages on the web page let alone in the log files. Let me explain.
I created the pfcmail.php no problem in src/.
I then located the nick.class.php in /src/commands/ and try to find "%s is connected" as kerphi stated below, however I came up empty. So I took a guess and placed the require_once() and pfcmail() calls in nick.class.php at line 85 & 86. This obviously must be the wrong place or I've done something wrong.
My second guess to place the call for pfcmail() based on my search for "%s
joins %s" I found it in join.class.php. Should I place the call for pfcmail() at line 55 just after $cmd->run($xml_reponse, $cmdp);?
Any direction as to where I should call pfcmail() at a client joining chat would be appreciated. Thanks.
Offline
thewaden
here is what I did
I edited the src/commands/nick.class.php file and at the end above the return true;
I added
require_once(dirname(__FILE__)."/pfcmail.php");
pfcmail ('Chat Admin','chat@yourdomain.com','chat@yourdomain.com','Chat Login at ' . $c->title ,'The user ' . $u->nick . ' has logged in to your chat room');
also create file called pfcmail.php
and put these in it
<?php
function pfcmail ($from_name='', $from_mail='', $to_mail='', $title='', $message='')
{
$from = 'From: ' . $from_name . ' <' . $from_mail . '>';
$message_headers = "$from";
mail($to_mail, $title, $message, $message_headers);
}
?>
drop this file in the src/commands/
folder
works for me. I hope this was the right way to do it
Last edited by winracer (2007-10-17 17:23:13)
Offline
I have question how would you get it to send to serveral different e-mail address
like
require_once(dirname(__FILE__)."/pfcmail.php");
pfcmail ('Chat Admin','chat@yourdomain.com','chat@yourdomain.com;2ndemail@otherdomain.com;3rdemail@otherdomain.com','Chat Login at ' . $c->title ,'The user ' . $u->nick . ' has logged in to your chat room');
could you change the pfcmail.php
to
<?php
function pfcmail ($from_name='', $from_mail='', $to_mail='', $to_mail='',$to_mail='',$title='', $message='')
{
$from = 'From: ' . $from_name . ' <' . $from_mail . $from_mail .$from_mail '>';
$message_headers = "$from";
mail($to_mail, $title, $message, $message_headers);
}
?>
Last edited by winracer (2007-10-17 17:24:00)
Offline
winracer wrote:
drop this file in the src/commands/ folder
I have question how would you get it to send to serveral different e-mail address
Ahh well then that was the problem for me. I put the file pfcmail.php in the wrong location, geez. I had the file in /src/ instead it should have been located in /src/commands/. I also was using $u->nick for the nickname, however I missed that it should be $newnick.
Everything works perfectly now, thanks for the reply/help.
As for having multiple email addresses. Well all you have to do is have a string with email addresses separated by commons like so, 'webmaster@domainname.com,support@domainname.com,info@domainname.com'.
Offline
thewarden
wrote
As for having multiple email addresses. Well all you have to do is have a string with email addresses separated by commons like so, 'webmaster@domainname.com,support@domainname.com,info@domainname.com'.
worked.
Offline
question about every 30 mins I get new e-mail that I have loged-in the chat room, I am just setting in the chat room and not doing anything
Last edited by winracer (2007-10-19 17:09:10)
Offline
winracer wrote:
question about every 30 mins I get new e-mail that I have login, I am just setting in the chat room
That is strange as that does not happen for me. I only get one email message each time a user enters chat. I've posted exactly what I did. Not sure if this is okay but I'll post a link to my blog entry on this topic to ensure you have the reference to pfcmail() function in the correct location.
http://www.adamsdesk.com/be/archives/20 … ification/
Good luck!
Offline
thewarden
wrote
That is strange as that does not happen for me. I only get one email message each time a user enters chat.
I wonder if it because I added a 2nd e-mail address? or it could be because of time-out?
I think it might be sending e-mail when the user times-out. I am checking
ok it looks like when you timeout or /quit that i get e-mail that I loged-in
Last edited by winracer (2007-10-19 19:27:16)
Offline
I found out after adding e-mail code back to chat is that it times out when in private chat?
Offline