Hello guys,
In my JFU configuration the upload is done only by a publisher via the frontend. The publisher sees an upload folder that contains subfolders for each user (labeled with the username). I would like to amend the plugin so that if a new set of files was uploaded by the publisher the correspondent user gets an email notification.
I amended the send_email function of the plugin and handed over the additional variable $folder. Then I'm making sure it contains only the actual foldername (without slashes or parent folders). With that string I have the actual username and I'm fetching the JUser object and get the email addresse from it. Then I overwrite the $mail_to variable with this addresse.
I spent half the day to get this working but without success. It's not working. Anyone got an idea what I'm doing wrong here?
Code:
function send_email($mail_from, $mail_to, $subject, $mailtext, $type, $fix_utf8, $folder) {
while (strpos($folder, '/') != false) { // remove parent folders and slashes
$pos = strpos($folder, "/");
$string = substr($folder, $pos+1);
}
$user =& JFactory::getUser( $folder );// get the user object that is the owner of the folder (username=foldername)
$mail_to = $user->email ; //set mail_to to the users email addresse
$submailheaders = "From: $mail_from\n";
$submailheaders .= "Reply-To: $mail_from\n";
$submailheaders .= "Return-Path: $mail_from\n";
if ($fix_utf8 != '') {
$submailheaders .= 'Content-Type: '.$type.'; charset=' . $fix_utf8 . "\n";
} else {
$submailheaders .= 'Content-Type: '.$type.'; charset=UTF-8' . "\n";
}
if ($type=="text/plain") {
@mail ($mail_to, html_entity_decode ($subject), html_entity_decode ($mailtext), $submailheaders);
} else {
$submailheaders .= "MIME-Version: 1.0\n";
@mail ($mail_to, html_entity_decode ($subject), $mailtext, $submailheaders);
}
}
Thanks for your feedback
Sebastian