An7hony Posted July 16, 2010 Share Posted July 16, 2010 Hi this is killing me, the email form works on all hosts except fasthost. I have checked that the from email is hosted with fasthost and it is. I have changed the script to: ini_set("sendmail_from", $from); mail( "$to", "candidate application", $message, "From: \"-f\".$from"); But the emails dont send? Any help is really really appreciated Thanks <?php $from = "our@fasthosteddomain.com"; $message .= "You have an General job application from: "; $message .= $firstname; $message .= " "; $message .= $surname; $message .= "\n"; $message .= "\n"; $message .= "Looking for: "; $message .= $typeofwork; $message .= "\n"; $message .= "\n"; $message .= "Job Type: "; $message .= $jobtype; $message .= "\n"; $message .= "\n"; $message .= "Transport: "; $message .= $transport; $message .= "\n"; $message .= "\n"; $message .= "Please login to http://www.ourdomain.com/admin to view their details"; $message .= "\n"; $message .= "\n"; $message .= "Their Telephone number is: "; $message .= $telephone; $message .= "\n"; $message .= "\n"; $message .= "Their email address is: "; $message .= $email; $message .= "\n"; $message .= "\n"; $message .= "Cover Letter:"; $message .= "\n"; $message .= $coverletter; $message .= "\n"; $message .= "\n"; $message .= "If CV attached: http://www.ourdomain.com/cvs/".$fileName; ini_set("sendmail_from", $from); mail( "$to", "candidate application", $message, "From: \"-f\".$from"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/ Share on other sites More sharing options...
trq Posted July 16, 2010 Share Posted July 16, 2010 The only variable defined within that script is $from, where exactly are the rest defined? If your expecting them to be automatically sent by your form, that feature / bug was disabled in default php installations almost 10 years ago. You'll want to look at the $_POST array. Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1086999 Share on other sites More sharing options...
An7hony Posted July 16, 2010 Author Share Posted July 16, 2010 sorry the rest of it goes like this <?php if($_POST['to']==""){ $to = ""; echo '<div class="error">Please select a <strong>Branch</strong></div>'; }else{ $to = $_POST['to']; } if($_POST['firstname']==""){ $firstname = ""; echo '<div class="error">Please fill in your <strong>First name</strong></div>'; }else{ $firstname = $_POST['firstname']; } if($_POST['surname']==""){ $surname = ""; echo '<div class="error">Please fill in your <strong>Surname</strong></div>'; }else{ $surname = $_POST['surname']; } ?> Then gets inserted into a mysql database and then runs into the script in the first post. Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1087069 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 The function call parameters appear hosed. What is this "From: \"-f\".$from"? It doesn't seem to be a proper header, nor a proper optional 5th parameter. Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1087075 Share on other sites More sharing options...
An7hony Posted July 16, 2010 Author Share Posted July 16, 2010 I read it on the fasthost knowledge base http://www.fasthosts.co.uk/knowledge-base/?article_id=65 Use the PHP mail function and set the mail from using the following line of code - replacing $email_from with the correct domain name. * ini_set("sendmail_from", " $email_from "); You need to add a fifth "-f" parameter to the sendmail function. This will set the name of the from address. * mail($email_to, $email_subject, $email_message, $headers, '-f'.$email_from); Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1087097 Share on other sites More sharing options...
Pikachu2000 Posted July 16, 2010 Share Posted July 16, 2010 Compare that to what you have in there. It's not quite the same. If the variables were echoed, it would look like this. Note the last parameter in the below should be a valid header, where currently it is not. After that would be the additional, 5th parameter: "-f $email_from" mail('recipient@email.com', 'candidate application', '[message body would be here]', 'From: -f our@fasthosteddomain.com'); Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1087102 Share on other sites More sharing options...
An7hony Posted July 16, 2010 Author Share Posted July 16, 2010 ah got you. Thanks for your help, Its much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/207922-cant-get-php-email-form-to-work-on-fasthost/#findComment-1087105 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.