The situation is this. I have a page where people enter some data and when they hit submit, it does two things. 1) It sends the results to the designated e-mail address 2) It sends an AutoReply to the person who filled out the form.
I have an SMTP host that requires authentication, so my friend explained that I had to use PEAR, but he pretty much set it all up for me. So anyway, here's the code:
<?php
require_once "Mail.php";
$smtp = Mail::factory('smtp', array ('host' => 'mail.dijitalmedia.com',
'auth' => true,
'username' => 'user@domain.com' ,
'password' => 'password'));
$to = 'info@smartofficeadvisors.com' ;
$from = ' info@smartofficeadvisors.com' ;
$name = $_REQUEST['Name'] ;
$subject = "Dance Card Results";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$fields = array();
$fields{"Name"} = "Name";
$fields{"industry"} = "Industry";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$subject2 = "Thank you for contacting us";
$to2 = $_REQUEST['Email'] ;
$autoreply = "Thank you for contacting us.
The winner of the chair will be notified at this e-mail address on or after October 6, 2006. If you have any more questions, please consult our website at http://www.smartofficeadvisors.com";
$headers2 = array ('From' => 'info@smartofficeadvisors.com',
'To' => $to2,
'Subject' => $subject2);
if($from == '') {print "You have not entered an email, please go back and try again";}
else
{
if($name == '') {print "You have not entered a name, please go back and try again";}
else
{
$send = $smtp->send($to, $headers, $body);
$headers2['To'] = $from;
$send2 = $smtp->send($to2, $headers2, $autoreply);
if(PEAR::isError($send))
{header( "Location: http://www.smartofficeadvisors.com/thankyou.php " );}
else
{print "We encountered an error sending your mail, please notify ithelp@smartofficeadvisors.com"; }
}
}
?>
That's the script I'm using exactly, except for the user/pass for the smtp which I made generic intentionally.
With the above script, I get the:
"We encountered an error sending your mail, please notify..."
And the autoreply does work, but I can't get the results of the form.
Thanks Again!
J. Gohil