Exemplo n.º 1
0
 /**
  * Sends an email from a specified file
  *
  * @param {string} $to the recipient's email address
  * @param {string} $from the sender's email address
  * @param {string} $fromName the name of the sender
  * @param {string} $subject the subject of the email
  * @param {Array} $replace an associative array of strings to replace
  * @param {string} $file the file to send
  * @return void
  */
 public static function sendEmailFromFile($to, $from, $fromName, $subject, $replace, $file)
 {
     if (file_exists($file)) {
         $content = file_get_contents($file);
         // walk through and replace values in associative array
         foreach ($replace as $key => &$value) {
             $content = str_replace($key, $value, $content);
             $subject = str_replace($key, $value, $subject);
         }
         // send email
         Utilities::sendEmail($to, $from, $fromName, $subject, $content);
         return true;
     } else {
         echo 'File does not exist=' . $file;
         return false;
     }
 }