html - php code not sending email


I have a simple website with a contact form which sends out an email after the user fills out and clicks on submit, however this doesn't seem to be working,

Unfortunately I don't have access to the mail server itself as it is hosted,

How do I debug this?

 require_once "Mail.php";

 $from = "B A <[email protected]>";
 $to = "B B <[email protected]>";

    $subject =$_REQUEST['subject'];
    $subject = 'Lighter Contact Form';


    $port = "25";

    $body = "Name: $name \n\nEmail: $email \n\nMessage: $msg";
    $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;

 $host = "";
 $username = "[email protected]";
 $password = "password";

 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     'auth' => true,
     'username' => $username,
     'password' => $password));

 $mail = $smtp->send($to, $headers, $body);



You could check for an error response (assuming you are using the PearMail class:


People are also looking for solutions to the problem: file get contents - PHP file_get_contents skipping characters


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.