Thank you in advance for reading.
I have an email function that partially works: it does send an email, with the correct message, subject, and headers, when I hard code in the email address. The SQL insertion above it works fine, so I know it is saving all the variables correctly to the database.
It does not send through the $email
, $first_names
, or $pass variables
, however. They come up as blanks in the message and $email does not work in the mail($email
, etc) function. Right now, mail()
only works when I hard code in an email.
The code, from the PHP file:
$email = $_POST['email'];
$first_names = str_replace("'","",$_POST['fname']);
$last_names = str_replace("'","",$_POST['lname']);
$password = $_POST['password'];
$user_type = 2;
$status = 1;
$last_login = '0000-00-00 00:00:00';
$sql_insert = "INSERT INTO `cb_sub_users` (`id`, `email`, `password`, `firstName`, `lastName`, `user_type`, `super_user`, `last_login`, `status`) VALUES (NULL, '$email', '$password', '$first_names', '$last_names', '$user_type', '$super_user_id', '$last_login', '1');";
$check_user = mysql_num_rows(mysql_query("SELECT * FROM `cb_sub_users` WHERE email='".$email."'"));
$message = 'Hi, ' + $first_names + '! Your team has invited you to join Our Site. Your username is ' . $email . ' and your password is ' . $password . '. Log in at blank for analytics you will actually use. If you have any questions, get in touch at help@help.com.';
$subject = 'Welcome to Our Site';
$headers = array("From: help@help.com",
"Reply-To: help@help.com",
"X-Mailer: PHP/" . PHP_VERSION );
$headers = implode("\r\n", $headers);
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail('myhardcoded@email.com', $subject, $message, $headers);
ini_set("mail.log", "/tmp/mail.log");
ini_set("mail.add_x_header", TRUE);
Thanks so much! Any help is much appreciated.