Skip to content

Instantly share code, notes, and snippets.

@Enome
Created January 16, 2013 23:01
Show Gist options
  • Select an option

  • Save Enome/4551798 to your computer and use it in GitHub Desktop.

Select an option

Save Enome/4551798 to your computer and use it in GitHub Desktop.
<?php
# WRITE TO FILE
function write_to_file ($file, $str) {
$open = fopen($file, 'a');
fwrite($open, "$str \n");
fclose($open);
};
# CSV
function write_csv ($file, $post) {
$values = array();
# Add values to array
foreach ($post as $key => $val) {
$values[] = str_replace(array("\n", "\r"), "", $val);
}
$values = join($values, "|");
write_to_file($file, $values);
};
# EMAIL
function email ($to, $from, $subject, $template, $values, $redirect) {
# Get content from template
ob_start();
include($template);
$recruiter = ob_get_clean();
# Headers for html templates
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from" . "\r\n";
# Mail it
return mail($to, $subject, $recruiter, $headers);
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment