clg897 Posted January 11, 2010 Share Posted January 11, 2010 Hey everyone, I'm trying to create some forms for my father's website for his company. The forms are created but I am trying to get them to send using PHP. My father has GoDaddy hosting which allows you to enter an e-mail address for any forms on the website to go to. The only problem is that I am already using that for a separate form on the site so I have had to create a new PHP file. Going into this I knew absolutely nothing about PHP and I'm struggling to figure this out. I found an example PHP mail script online that I modeled my file after. It will send e-mails to my personal Live e-mail address and to my university's MS Exchange e-mail address, although that one didn't always work. My father's company uses MS Exchange as well and they are not receiving anything I send to them during my testing. I have been looking online forever but nothing is working. I found some website that talked about my issue and mentioned something with php.ini files. The code I put in, which the website suggested, was: [mail function] ; Setup for Linux systems sendmail_path = /usr/sbin/sendmail -t sendmail_from = donotreply@foo.com That is the only code in the php.ini file I created. The server has PHP 4 and is a Linux server. Here's the code for the forms: <?php $to = "clg897@foo.com, christopher.ganim@foo.edu" ; $from = "donotreply@foo.com \r\n" ; $name = $_REQUEST['EmployerName'] ; $headers = "From: $from \r\n"; $company = $_REQUEST['EmployerCompany']; $subject = "Online Request - Add New Employee (" . $company . ")"; $senderemail = $_REQUEST['EmployerEmail'] ; $fields = array(); $fields{"EmployerName"} = "Employer Name"; $fields{"EmployerCompany"} = "Employer Company"; $fields{"EmployerEmail"} = "Employer Email"; $fields{"EmployerPhone"} = "Employer Phone"; $fields{"EmployeeName"} = "Employee Name"; $fields{"EmployeeStreetAddress"} = "Employee Address"; $fields{"EmployeeCity"} = "Employee City"; $fields{"EmployeeState"} = "Employee State"; $fields{"EmployeeZip"} = "Employee Zip"; $fields{"EmployeeSSN"} = "Employee SSN"; $fields{"EmployeeDOB"} = "Employee DOB"; $fields{"EmployeeBusinessPhone"} = "Employee Business Phone"; $fields{"EmployeeHomePhone"} = "Employee Home Phone"; $fields{"EmployeeEmail"} = "Employee Email"; $fields{"EmployeeStartDate"} = "Employee Start Date"; $fields{"EmployeeSalary"} = "Employee Salary"; $fields{"EmployeeTitle"} = "Employee Title"; $fields{"EmployeeCovStatus"} = "Employee Coverage Status"; $fields{"Comments"} = "Comments"; $body = "The following information was submitted by " . $name . " (" . $senderemail . ") using our online form:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: $from \r\n"; $subject2 = "Add New Employee Request Received"; $autoreply = "Thank you for your online submission. This e-mail is automatically generated to confirm that we have received the information you provided online. A copy of what you have submitted is below.\n\nPlease do not reply to this e-mail. If you have any questions or find any mistakes, please call the Ganim Group at (203) 335-0851 or go to http://www.ganimgroup.com/contactus.html.\n\n"; ; foreach($fields as $a => $b){ $autoreply .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } if($from == '') {print "You have not entered an email, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($senderemail, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.foo.com" );} else {print "There was an error processing your request. If this is the first time you have encountered this error, please try again. Otherwise, contact the Ganim Group at (203) 335-0851. We are sorry for the inconvenience."; } } ?> Am I doing something wrong? Any help would be greatly appreciated. I have been trying to figure this out forever. Quote Link to comment Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 The syntax for accessing array indexes is $arrayname[$indexname] not $arrayname{$indexname}. Quote Link to comment Share on other sites More sharing options...
cpace1983 Posted January 31, 2010 Share Posted January 31, 2010 Is Exchange not receiving the emails, or are they being marked/filtered as spam? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.