使用jquery显示表单时未发送邮件/mime电子邮件



我有一个相对基本的电子邮件表单,我打算使用mail mime将其发送给收件人。过去,当表单显示在自己的页面(即联系人页面)上时,这种方法对我很有效。

在这里,我使用jquery来显示一个隐藏的div,其中包含我在主页中的表单。问题是,尽管我的验证通过了,但电子邮件并没有被发送。我不知道为什么,希望这里有人能帮我!

相关php如下:

$path = get_include_path() . PATH_SEPARATOR . '/home/host/php';
set_include_path($path);
include('Mail.php');
include('Mail/mime.php');
$recipient_email = 'somebody@somewhere.com';
//validations are here
//send the email
$name = $_POST['name'];
$visitor_email = $_POST['from'];
$subject = $_POST['subject'];
$user_message = $_POST['message'];
$to = $recipient_email;
$from = $visitor_email;
$text = "From: $name n Subject: $subject n Message $user_message";
$message = new Mail_mime(); 
$message->setTXTBody($text); 
$body = $message->get();
$extraheaders = array("From"=>$name, "To"=>$recipient_email, "Subject"=>$subject, "Reply-To"=>$visitor_email);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
echo "Success";

显示表单的jquery如下所示:

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};
$(document).ready(function() {
$('#tellfriend').hide();
$('li a.email, #tellfriend a.close').click(function() {
$("#tellfriend").fadeToggle('slow');
});
}); 

我的一个想法(我会尝试一下)是,因为当点击链接显示表单时,链接会附加到URL上,所以它可能会影响我的表单操作?不确定。。感谢您的帮助!

我按照之前在Stack Overflow HERE 上发现的问题解决了我的问题

事实证明,我必须指定一个传出邮件服务器才能发送表单。尽管如此,奇怪的是,我过去曾让它发挥作用,而我不需要遵循这样的步骤。

最新更新