Page 1 of 1

PHP mail not working :P Been trying to fix it for over a mon

Posted: Thu Jun 21, 2007 12:43 am
by bloodl
The Ninja Space Goat | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I am trying to get my clients email up and working.  It sends the vars from flash, and I never hear a peep out of the php.  No errors, and no emails !
The vars are correct on both sides, and apparently this form works on other sites.

my php.ini is set up:

[mail function]
; For Win32 only.
SMTP = mail.mydomain.com
smtp_port = 25

; For Win32 only.
sendmail_from = theboss@myworkplace.com

If anyone can see the dodge within this code, can you plez help me out?

Code: Select all

<? 

$adminaddress = "milk@visuality.com.au";
$siteaddress ="www.visuality.com.au";
$sitename = "Visuality";

//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;
} //


?>
Cheers,
Doug


The Ninja Space Goat | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Jun 21, 2007 12:48 am
by Chris Corbyn
Is the server a windows server?

Also, when you run mail() make sure you check it returns true:

Code: Select all

if (mail( ... )) {
   echo "Mail sent";
}
else {
    echo "Not sent";
}
Usig mail() in the straight-forward way you are will almost definitely get you stuck in junk filters too due to bad headers. Take a look at Swift Mailer as an alternative which deals with the message structure for you: http://www.swiftmailer.org/ ;)

Thanks for such a fast reply!

Posted: Thu Jun 21, 2007 2:09 am
by bloodl
Yes it's windows server 2003, running IIS 6, and PHP5.

I am in general an action scripter - could you ilaborate on the 1st line of codeyou suggested ?
if (mail( ... )) {
Thanks a million[/quote]

Thanks for such a fast reply!

Posted: Thu Jun 21, 2007 2:12 am
by bloodl
Yes it's windows server 2003, running IIS 6, and PHP5.

I am in general an action scripter - could you ilaborate on the 1st line of codeyou suggested ?
if (mail( ... )) {
Thanks a million

Posted: Thu Jun 21, 2007 2:21 am
by Luke
May I ask what in the world the poll had to do with any of this? :?

Posted: Thu Jun 21, 2007 2:36 am
by bloodl
The Ninja Space Goat wrote:May I ask what in the world the poll had to do with any of this? :?
I am an aspiring e-commerce merchant

Cheers,
Doug

Re: Thanks for such a fast reply!

Posted: Thu Jun 21, 2007 6:20 am
by Chris Corbyn
bloodl wrote:Yes it's windows server 2003, running IIS 6, and PHP5.

I am in general an action scripter - could you ilaborate on the 1st line of codeyou suggested ?
if (mail( ... )) {
Thanks a million
[/quote]

It was pseudo code suggesting that you wrap your call to mail() in an if() statement like I have done. mail() returns the success status when it's done, so if it returns false you know that mail() is not working, otherwise, you mail is being blocked as junk.

fixed

Posted: Thu Nov 22, 2007 7:30 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