Page 1 of 1
scripts that can test if our server can send php mail
Posted: Wed Jul 25, 2007 12:57 am
by bloodl
Hi
My 3 month issues is that so far I have not gotten any php mail forms to work on our server. We think we have tried everything, but we must be wrong. Are there any scripts around that I can run on the server that will just simply test if our mail works ? A script that doesn't need to be linked to external or local files ? If anyone knows of any, that would be GREAT!
I just can't figure out where the break is. When the form is filled in and completed, it never stops saying "waiting for
http://www.mywebsite.com..." and I have never seen any error messages. Is that a clue? I am using $_POST and not $HTTP_POST_VARS, and we think we have set up the server SMPT settings correctly. The vars are coming from flash which has worked on other servers with the same php script!
I am totally confused, and frightened
If anyone knows about any scripts that can test if our server is configured correctly, please show some love this way.
Cheers,
Doug
Posted: Wed Jul 25, 2007 3:15 am
by miro_igov
Posting the code here may help solving the issue. You can check if mail() returns true or false. If true and no email is received the issue is not in php.
hmmmm..
Posted: Wed Jul 25, 2007 3:22 am
by bloodl
Here is the code, I hope its helpful:
Code: Select all
<?php
$adminaddress = "someone@website.com.au";
$siteaddress ="www.website.com.au";
$sitename = "SiteName";
//Gets the date and time from your server
//$date = date("m/d/Y H:i:s");
// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
// Gets the POST Headers - the Flash variables
$action = $_POST['action'] ;
$firstname = $_POST['firstname'] ;
$lastname = $_POST['lastname'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$time = $_POST['time'] ;
$how = $_POST['how'] ;
$promo = $_POST['promo'] ;
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action == "send") {
//
mail ("$adminaddress","Website Contact",
"A visitor at $sitename has left the following information\n
------------------------------
First Name: $firstname
Last Name: $lastname
Time: $time
Phone: $phone
Email: $email
Promo: $promo
How: $how
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress" ) ;
//This sends a confirmation to your visitor
mail ("$email","Thank You for visiting $sitename",
"Hi $firstname,
Thank you for your interest in $sitename!
We will get back to you as soon as possible.
Cheers,
$sitename
------------------------------
Phone: (02) 1234567899
$siteaddress","FROM:$adminaddress") ;
//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Thank you.";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo $send_answer;
} //
?>
<?php
if (@mail($to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>
Cheers,
Doug
Posted: Wed Jul 25, 2007 3:34 am
by miro_igov
Why you suppress the error displaying with @mail() ? Where are $to, $subject , $message defined?
What is the content of the $action var? Try echo $action;
I thought that code would help...
Posted: Wed Jul 25, 2007 6:27 pm
by bloodl
You mean the bottom part of the code with the echo's to determine if the mail was sent?
Code: Select all
<?php
if (@mail($to, $subject, $message)) {
echo('<p>Mail sent successfully.</p>');
} else {
echo('<p>Mail could not be sent.</p>');
}
?>
I found that on another web site, and I thought it might help me determine if the mail is sending. Is this code helpful to me, if it isn't, ill just ditch it.
In regards to $action, here is the script in flash that sends the vars:
Code: Select all
loadVariablesNum(mailform, 0);
answer = confirm;
firstname = "";
lastname = "";
email = "";
phone = "";
time = "";
how = "";
promo = "";
So I take it the flash variable arrive in the same order, and that $action must be the answer=confirm in php.
Is there anything else that looks sus?
found one more snippet
Posted: Wed Jul 25, 2007 7:27 pm
by bloodl
Found a bit more code:
Code: Select all
mailform = "http://www.mysite.com.au/mailform.php";
confirm = "Form Submitted.";
action = "send";
Cheers,
Doug
Posted: Thu Jul 26, 2007 7:51 am
by miro_igov
I don't believe this is PHP, PHP variables start with $
correct
Posted: Thu Jul 26, 2007 9:47 pm
by bloodl
Sorry, yes this is flash, this code is what shoots the vars out to the php
Fixed it
Posted: Thu Nov 22, 2007 7:31 pm
by bloodl
Okay.. its a few months later
The issues is fixed. It was smtp issues - if anyone else is having issues with sending mail using php, investigate smtp clearance. I think a symptom of this was not receiving any error messages
Thanks for everyones help anyway, I appreciate it
Cheers,
Doug