我有一个简单的网站,其中有一个联系表单,在用户填写并点击提交后发送一封电子邮件,但这似乎不起作用,
不幸的是,我无法访问邮件服务器本身,因为它是托管的,
如何调试?
<?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 \n\nEmail: $email \n\nMessage: $msg";
$headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . '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);
?>
答案 0 :(得分:1)
您可以检查错误响应(假设您正在使用Pear Mail
类:
if(Pear::isError($mail))
{
die($mail->getMessage());
}