Jump to content

cant get php email form to work on fasthost


An7hony

Recommended Posts

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 = "[email protected]";

  $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");
  
  }
  }
?>

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.

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.

 

 

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);

 

 

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('[email protected]', 'candidate application', '[message body would be here]', 'From: -f [email protected]');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.