dongtang1909
2013-12-12 03:05
浏览 64
已采纳

php代码不发送电子邮件

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?

<?php
 require_once "Mail.php";

 $from = "B A <info@abc.com>";
 $to = "B B <info@gmail.com>";

    if($subject!=""){
    $subject =$_REQUEST['subject'];
    }else{
    $subject = 'Lighter Contact Form';
    }

    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $msg=$_REQUEST['msg'];

    $port = "25";

    $body = "Name: $name 

Email: $email 

Message: $msg";
    $headers = 'From: '.$name.' <'.$email.'>' . "
" . 'Reply-To: ' . $email;

 $host = "imap.ox.registrar-servers.com";
 $username = "info@abc";
 $password = "password";


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

 $mail = $smtp->send($to, $headers, $body);
?>
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsymx68408 2013-12-12 03:09
    已采纳

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

    if(Pear::isError($mail))
    {
        die($mail->getMessage());
    }
    
    打赏 评论

相关推荐 更多相似问题