atticus Posted July 24, 2008 Share Posted July 24, 2008 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 https://forums.phpfreaks.com/topic/116416-solved-undefined-variables-in-mail-script/ Share on other sites More sharing options...
DarkWater Posted July 24, 2008 Share Posted July 24, 2008 Put quotes around sendmail_from in the ini_set and ini_restore calls. Link to comment https://forums.phpfreaks.com/topic/116416-solved-undefined-variables-in-mail-script/#findComment-598642 Share on other sites More sharing options...
atticus Posted July 24, 2008 Author Share Posted July 24, 2008 thanks! I am still getting an error for this line of code: $headers .= "From: " . $name . "<" . $email . ">\r\n"; Link to comment https://forums.phpfreaks.com/topic/116416-solved-undefined-variables-in-mail-script/#findComment-598658 Share on other sites More sharing options...
Jabop Posted July 24, 2008 Share Posted July 24, 2008 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 https://forums.phpfreaks.com/topic/116416-solved-undefined-variables-in-mail-script/#findComment-598671 Share on other sites More sharing options...
atticus Posted July 24, 2008 Author Share Posted July 24, 2008 Original: $headers .= "From: " . $name . "<" . $email . ">\r\n"; Fixed: $headers = "From: " . $name . "<" . $email . ">\r\n"; I removed the period before the "=" Thanks for all your help! Cheers Link to comment https://forums.phpfreaks.com/topic/116416-solved-undefined-variables-in-mail-script/#findComment-598687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.