It could be a misconfiguration with the mail server. If you cannot get it to work with either PHP nor ASP, then this the case and you should contact your host immediately.
Hope this helps.
Printable View
Hi, Rob!
I think I have the prob! Try this code instead, this might resolve all problems!
Was this code helpfull?PHP Code:<?php
// Are we going to send user to another location? True/False
$send_to_newPage = false;
$to = "Rob <mymail@gmail.com>";
$name = $_POST['first_name'] . " " . $_POST['last_name'];
$email = $_POST['email'];
$subject = $_POST['attn'];
$message = $_POST['text_box'];
$headers[] = "From: " . $name . " <" . $email . ">";
$headers[] = "MIME-Version: 1.0";
$headers[] = "Date: " . gmdate('D, d M Y H:i:s T', time() );
$subject = stripslashes($subject);
$body = stripslashes($message);
if( $send_to_newPage )
{
if( mail($to, $subject, $body, implode("\r\n", $headers)) )
{
header("Location: thanks.htm"); //Sends to New Page
}
else
{
echo "<p>An Error Occured, Please Resend<p>";
}
}
else
{
if( mail($to, $subject, $body, implode("\r\n", $headers)) )
{
echo "Mail (" . $subject . "), was successfully sent.";
}
else
{
echo "The email (" . $subject . ") could not be sent.";
}
}
$name = stripslashes($name);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>I.D. Tagem...Thanks!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- meta http-equiv="refresh" content="0;url=thanks.htm" -->
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<b>Thank you <?php echo $name; ?></b>
<br>Your message has been sent
<p><a href="<?php print $continue; ?>">Click here to continue</a></p>
</center>
</div>
</body>
</html>
Best regards,
mbrodin
Nope same error as before :(.
I tried calling up Godaddy.com, and they recommended I spend an extra five bucks a month to have my own server instead of using the shared network that I have now. I figured it was all BS! ..Are they right, or just trying to get me to pony up more money?
Rob
Probably the latter. Anyways; as a test, try the following code to see if you get an email.Quote:
Are they right, or just trying to get me to pony up more money?
That will show a blank page when you go to it; but after executing the script, wait a few seconds or so (for server lag) and then check your email. If you still get an error, or no error but no email then it is a problem with the mail server.Code:<?php
$to = 'you@domain.com'; //change to point to your email address
mail($to, 'Test Message From PHP Script', 'This is a test');
?>
Hope this helps.
Tried it and I get no error and no mail. I let it sit for about ten minutes, reloaded the page, tried again and waited for about ten minutes. Changed the email address to another one and did the same, still nothing.
So if there is a problem with the mail server, how would I word it so that Godaddy.com doesn't point me to a "different more costly plan" ;)?
Also heres my PHP details, if anyone is interested...
PHP page 1
PHP page 2
And PHP page 3
Rob
No, linux cant use ASP because MS doesn't release any software for linux. A rule of thumb is to create scripts that work regardless of the OS it's run on, so PHP is always a better option than ASP.
Do you have a mail server at localhost, and what kind?
EDIT: tell them their mail server might be busted, you only noticed when testing a script you were writing for a freind.
However, you can get Chili-ASP or Apache::ASP and it will run ASP and ASP.net scripts. Just depends on the distro of Linux and whether you run Apache web server or not.
If you look at the phpinfo in the links posted above, it shows that it is "supposedly" set up at localhost; however, this may not be the case (if they didn't set up the server correctly). Anyways, tell them to check all of the settings on the mail server because you are unable to send emails using a simple PHP script.Quote:
Do you have a mail server at localhost, and what kind?
Ok I gave them a call and they said everything "looked" ok on there end. They took a look at the email.php file, I created, and said to create another email server address and use that to test. And after an hour, and it doesn't work, to call them back.
I also came across a section of my account that says "You currently have no SMTP Relay accounts. Click here to purchase one." I wouldn't need one of these would I?!? I hope not, since it's another five dollars extra a month :(. I also have no "Email Forwarding", but don't believe that will solve my problem.
I'll try testing it after an hour and post any results...
Rob
If you want a big more info on configuration, you can run this code--
and this for a couple more precise checks:PHP Code:<?php phpinfo(); ?>
The first will check the server configuration and allow you to check all the setup. It will likely show whether mail is enabled or not.PHP Code:<?php
if (function_exists('mail')) {
echo "mail() function exists!\n";
if (mail('your@email.com', 'Test Message From PHP Script', 'This is a test')) {
echo "Successfully sent, or so the server thinks...";
}
else {
echo "Sending the email failed.";
}
}
else echo "mail() doesn't exist";
?>
The second will check first if the function mail() even exists and if so attempt to send an email. When it attempts this, it will check if the mail worked or not (according to the script), then tell you what it thinks happened. If it says it failed, then that makes sense. If it does say it worked, however, something else is probably going on.
Nope still nothing. Not really wanting to go back through Godaddy.com's tech support. And try to explain over and over again what I want to do. And get a "I'm not sure I follow you." type answer. Or "That will cost you .... dollars, can I sign you up!"... *sigh*
As for the first one djr33, I've already done that. Look above, I posted links to pictures of the output of the PHP info.
And as for the second I get:
This can't be good right, lol? Don't know what to tell Godaddy.com, that will get through their heads to turn this on, or make it happen without costing me more money :(.Code:mail() doesn't exist
So it looks like I might have to pay for the SMTP account on additional to my server and hosting costs :mad:?!?
Rob