Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用jquery显示表单时未发送邮件/mime电子邮件_Php_Jquery_Email_Mime - Fatal编程技术网

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

Php 使用jquery显示表单时未发送邮件/mime电子邮件,php,jquery,email,mime,Php,Jquery,Email,Mime,我有一个相对基本的电子邮件表单,我打算使用邮件mime向收件人发送电子邮件。过去,当表单显示在自己的页面(即联系人页面)上时,这种方法对我很有效 在这里,我使用jquery显示一个隐藏的div,其中包含来自主页的表单。问题是,虽然我的验证通过了,但电子邮件没有被发送。我不知道为什么,希望这里有人能帮助我 相关php如下所示: $path = get_include_path() . PATH_SEPARATOR . '/home/host/php'; set_include_path($path

我有一个相对基本的电子邮件表单,我打算使用邮件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中,因此可能会影响表单操作,我将对此进行实验?不确定。。感谢您的帮助

我通过遵循我最终在堆栈溢出上发现的一个问题来解决我的问题

事实证明,为了发送表单,我必须指定一个发送邮件服务器。不过,奇怪的是,我过去一直让它在我不需要遵循这些步骤的情况下工作