Jump to content

[SOLVED] Undefined Variables in mail script


atticus

Recommended Posts

This script generates an email when a user registers (there is not db connection).  I am getting an error and I am not sure what it means. 

 

Error:

Notice: Undefined variable: headers in /var/www/../confirm.php on line 43

 

Notice: Use of undefined constant sendmail_from - assumed 'sendmail_from' in /var/www/..project/confirm.php on line 45

 

Notice: Use of undefined constant sendmail_from - assumed 'sendmail_from' in /var/www/../confirm.php on line 47

 

Notice: Use of undefined constant sendmail_from - assumed 'sendmail_from' in /var/www/..confirm.php on line 50

 

Notice: Use of undefined constant sendmail_from - assumed 'sendmail_from' in /var/www/..confirm.php on line 52

 

<?php
foreach ($_POST as $key => $val) {
      $_POST[$key] = stripslashes($val);
}
$to = "an email address"; // me
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$password = $_POST['password'];


$subject2 = "A new FTP Account Registration!";

email body...

$headers .= "From: " . $name . "<" . $email . ">\r\n";

ini_set(sendmail_from, $email);
mail($to, $subject2, $msg, $headers);
ini_restore(sendmail_from);

$to2 = 'email address 2';
ini_set(sendmail_from, $email);
mail($to2, $subject2, $msg, $headers);
ini_restore(sendmail_from);

 

Thanks in advance!

Link to comment
Share on other sites

thanks!

 

I am still getting an error for this line of code:

 

$headers .= "From: " . $name . "<" . $email . ">\r\n";

 

It must be in the previous lines that you didn't paste, cause that shows no errors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.