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());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条