Created
December 19, 2012 20:42
-
-
Save jda/4340254 to your computer and use it in GitHub Desktop.
Generic Form Mailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Generic form mailer | |
// Settings you can change | |
$to = "[email protected]"; | |
$subject = "Contact form"; | |
$username = "[email protected]"; | |
$password = "email passwd here"; | |
// add form elements below to exclude them from the mail | |
$exclude = array( | |
"test1", | |
"test2", | |
); | |
// Don't change stuff below this line | |
// We take whatever we get and spit it out in a email | |
require_once "Mail.php"; | |
// set up params for Mail factory | |
$p = array(); | |
$p["host"] = "mail.netwurx.net"; | |
$p["port"] = 587; | |
$p["auth"] = true; | |
$p["username"] = $username; | |
$p["password"] = $password; | |
$m =& Mail::factory("smtp", $p); | |
// Set up headers to go on message | |
$h = array(); | |
$h['From'] = $to; | |
$h['To'] = $to; | |
$h['Subject'] = $subject; | |
$newurl = $_POST["redirect"]; | |
$body = ""; | |
foreach ($exclude as $key) { | |
unset($_POST[$key]); | |
} | |
foreach ($_POST as $key => $val) { | |
$body .= "$key: $val\n\n"; | |
} | |
$res = $m->send($to, $h, $body); | |
if ($newurl != "") { | |
header("Location:$newurl"); | |
exit(); | |
} else { | |
print "Generic Formmail. New URL not set.\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment