PDA

View Full Version : PHP's mail() function


Phantom
05-07-2003, 10:28 PM
A new problem has evolved in my expedition, and I don't know WTF the problem with it is. I'm trying to use PHP's mail() function to send a confirmation email, but it isn't sending the email.

} else { // Everything went ok, or did it?
createMessage('r');
$message = $out;
$db = new dbStuff;
$db->dbM("INSERT INTO ${table} SET name = '$uname', email = '$uemail', domain = '$udomain', issue = '$uissue', date = ".time().", status = '2'"); // Status? Well, status=0 means closed, 1 means open, 2 means pending
$db->dbQ("SELECT * FROM ${table} WHERE name = '$uname'");
$client = $db->dbR();
$mail = new mailStuff;
$mailHead = "From: $display<$email>\r\n";
$mailHead .= "Reply-to: <$email>\r\n";
$subject = "Support Ticket: ID-$client['id']";
$mail->sendMail($uemail, $subject,$message, $mailHead);
echo "<script>alert('All of the information entered was correct, and an email has been sent to $uemail. One of our Tech Support Specialists will view your issue and get back to you shortly. Have a nice day!');</script>";
}


The $mail->sendMail function

function sendMail($to,$subject,$message, $headers) {
if(isset($to) && isset($subject) && isset($message) && isset($headers)) {
mail($to, $subject, $message, $headers);
}
}


The $u variables (uemail, udomain, etc) are set via a form, comprised of 3 textboxes and 1 textarea (textarea being the issue). The variables $display and $email are set via a configuration file. I don't know what the problem is, but I beleive it lies in the headers I'm trying to use to send the email, though it does seem that as the script parses, it just skips the whole part where it's supposed to send the mail and goes straight to the alert. Any help would be appreciated :-)

Thanks!

mordred
05-07-2003, 11:21 PM
Are you sure that the $u variables really contain any useful values? Have you added error_reporting(E_ALL); at the top of your script, that should show immediately if the variables were *not* passed correctly from the form?

Phantom
05-07-2003, 11:37 PM
YAY

Thanks man, really appreciate it :D :D :D

Phantom
05-08-2003, 11:23 PM
Another problem :-(

It's the wierdest thing too. I uploaded my script with the change to add "Bcc: $email\r\n" to the headers, and then, it just stopped sending emails. When I deleted that out of the headers (and minor changes, but I set them back), it still doesn't send the mail. I killed that part of the headers and used PHP's ordinary mail() function, instead of my own, and it's...not working (with error_reporting(E_ALL) on, no errors)

Have any of you run into this problem before?

(edit: Also, rebooting the mail server didn't seem to work either)
(edit2: It seems that it will only send to certain email addresses. Ones that are not on the server, mainly, but it won't send it to a few other email addresses of mine)