public function notifyUploader($email, $token, $fileData = array(), $sendTo = array()) { $WeTransfer_Files = new WeTransfer_Files(); $uploadInfo = $WeTransfer_Files->fetchFileDataByToken($token); $mail = new PHPMailer(); $mail->From = SITE_EMAIL_ADDRESS; $mail->FromName = SITE_NAME; $mail->addAddress($email); $mail->addReplyTo(SITE_EMAIL_ADDRESS, SITE_NAME); $mail->WordWrap = 50; $mail->isHTML(true); $sendToCount = count($sendTo); $mail->Subject = '[' . SITE_NAME . '] Thanks for using ' . SITE_NAME . ' - '; $mail->Subject .= 'file sent to ' . $sendTo[0]; if ($sendToCount > 2) { $mail->Subject .= ' (& ' . $sendToCount . ' others)'; } elseif ($sendToCount == 2) { $mail->Subject .= ' & ' . $sendTo[1]; } $body = 'Your recent upload to ' . SITE_NAME . ' was successful. <br>You will be notified via email '; $body .= 'when one of your recipients downloads it.<br><br>'; if (strlen($uploadInfo['expiration_date'])) { $body .= 'The file(s) will be deleted on ' . date('F d, Y @ H:i:s T', $uploadInfo['expiration_date']) . '.<br><br>'; } $body .= 'Recipient(s):<br>'; $body .= '<ol>'; foreach ($sendTo as $key => $value) { $body .= '<li><a href="mailto:' . $value . '">' . $value . '</a></li>'; } $body .= '</ol>'; if (!empty($fileData)) { $totalFileSize = array(); foreach ($fileData as $key => $value) { $totalFileSize[] = $value['bytes']; } $totalFileSizeReadable = bytesToHumanReadable(array_sum($totalFileSize)); $body .= '<br>Uploaded Files (' . $totalFileSizeReadable . ' Total): <br>'; $body .= '<ol>'; foreach ($fileData as $key => $value) { $body .= '<li>' . $value['name'] . ' (' . $value['size'] . ') </li>'; } $body .= '</ol>'; } if (strlen($uploadInfo['comment'])) { $body .= '<br>Message:<br><br>'; // fix escaped text $comment = str_replace(array("\r\n", "\n", "\r"), '<br>', $uploadInfo['comment']); $comment = stripcslashes($comment); $comment = stripslashes($comment); $body .= nl2br($comment); } $body .= '<br><br><br>Download:<br><br><a target="_blank" href="' . BASEURL . '/transfer/' . $token . '">' . BASEURL . '/transfer/' . $token . '</a>'; $body .= '<br><br><br>Thank you, '; $body .= '<br>' . SITE_NAME; $body .= '<br>' . BASEURL; $mail->Body = $body; $body = "\r\n\r\nYour recent upload to " . SITE_NAME . " was successful.\r\n You will be notified via email "; $body .= "\r\nwhen one of your recipients downloads it.\r\n\r\n"; if (strlen($uploadInfo['expiration_date'])) { $body .= "The file(s) will be deleted on " . date('F d, Y @ H:i:s T', $uploadInfo['expiration_date']) . ".\r\n\r\n"; } $body .= "Recipient(s):\r\n\r\n"; foreach ($sendTo as $key => $value) { $body .= $value . "\r\n"; } if (!empty($fileData)) { $body .= "\rnUploaded Files (" . $totalFileSizeReadable . " Total): "; $body .= "\r\n\r\n"; foreach ($fileData as $key => $value) { $body .= "\r\n" . $value['name'] . ' (' . $value['size'] . ')'; } } if (strlen($uploadInfo['comment'])) { $body .= "\r\n\r\nMessage:\r\n\r\n"; // fix escaped text $comment = stripcslashes($comment); $comment = stripslashes($comment); $body .= $comment; } $body .= "\r\n\r\n\r\nDownload:\r\n\r\n" . BASEURL . "/transfer/" . $token; $body .= "\r\n\r\n\r\nThank you, "; $body .= "\r\n" . SITE_NAME; $body .= "\r\n" . BASEURL; $mail->AltBody = $body; if (!$mail->send()) { return $mail->ErrorInfo; } return true; }