Page 1 of 1

email notification

PostPosted: Wed Nov 09, 2011 4:21 pm
by csuno
Hy folks, and admins ;)

we want to use your "daddy's file host" scripts in our company. Would it be possible for you, to make an option to decide wether i want to send a notification email to a special emailadress automaticly everytime a file is uploaded!?

many thanks for thinging about this... yours csuno

Re: email notification

PostPosted: Sat Nov 12, 2011 7:15 am
by SamEA
Due to the limited time I have, at this time I won't be able to come up with a MOD for you. However this is the basics of what will need to be implemented:
1) Adding an option in the AdminCP to enable automatic email notifications followed by the e-mail address.
2) Adding a code in ./upload.php where if (1) option is enabled, to e-mail the set e-mail in (1).

If you require this feature sooner, I suggest posting a freelance job for the community here or by completing a private freelance application form: viewforum.php?f=25

Re: email notification

PostPosted: Sat Nov 12, 2011 11:19 am
by csuno
Thank you Sam... i already changed line 162++ in upload.php from this:
Code: Select all
if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
$rand2 = urlencode($rand2);
$uploadmsg = "$lang[ufile] (".$filename.") $lang[wup].\n  ". $lang[udownfile] . ":" . $scripturl . "$short" . $rand2 . "\n ". $lang[udeletefile] . ":" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "\n $lang[thank]";
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: ". $email ."\n");
$rand2 = urldecode($rand2);


to this:
Code: Select all
$rand2 = urlencode($rand2);
$uploadmsg = "$lang[ufile] (".$filename.") $lang[wup].\n  ". $lang[udownfile] . ":" . $scripturl . "$short" . $rand2 . "\n ". $lang[udeletefile] . ":" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "\n $lang[thank]";
if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: ". $email ."\n");}
mail('sendalwaysto@mail.com',"Uploaded File",$uploadmsg,"From: ". $email ."\n");
$rand2 = urldecode($rand2);

And for me this works just fine...maybe if you wish to, i can take a deeper look, and we (you) can intergrate it into the AdminCP with the responding variables and switches!?

Thank you for your work! yours csuno

Re: email notification

PostPosted: Sat Nov 12, 2011 12:45 pm
by SamEA
The above code will email the uploader even if he has not entered his e-mail, resulting in PHP sending blank e-mails after each upload. I advise you replace the if statement back and

Add this line
Code: Select all
mail('sendalwaysto@mail.com',"Uploaded File",$uploadmsg,"From: ". $email ."\n");
after the IF statement.

Re: email notification

PostPosted: Sun Nov 13, 2011 10:03 am
by csuno
Thnks SamEA for your time...

when i add this line after the if statement, than it may happen, that the $uploadmsg is undefined. Isnt it?
I also dont understand why, he should send unwanted mail, with my changed uploaded.php

$rand2 = urlencode($rand2);
- Encode
$uploadmsg = "$lang[ufile] (".$filename.") $lang[wup].\n ". $lang[udownfile] . ":" . $scripturl . "$short" . $rand2 . "\n ". $lang[udeletefile] . ":" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "\n $lang[thank]";
- generate uploadmsg
if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: ". $email ."\n");}
- if someone type in his mailadress in uploadfront end (and emailoption is activated) he sends a mail to "_POST[myemail]" (the uploader)
mail('sendalwaysto@mail.com',"Uploaded File",$uploadmsg,"From: ". $email ."\n");
- this is my mail adress, i want to have a mail everytime, something is uploaded
$rand2 = urldecode($rand2);
- decode

I'm sorry that i dont understand... but i willl test this on monday. To get what you say'd. So please, dont investigate to much in this...but maybe you can add this to a future "feature Request" list!? to integrate this option the right way, later!?

Thank you anyway for your help. have a nice sunday!