【问题标题】:Mail/mime email not sent when displaying form with jquery使用 jquery 显示表单时未发送邮件/mime 电子邮件
【发布时间】:2015-06-16 10:36:43
【问题描述】:

我有一个相对基本的电子邮件表单,我打算使用邮件 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 上,所以它可能会影响我的表单操作?不确定..任何帮助表示赞赏!

【问题讨论】:

    标签: php jquery email mime


    【解决方案1】:

    按照我最终在 Stack Overflow HERE987654321@ 上找到的上一个问题,我能够解决我的问题

    事实证明,我必须指定一个外发邮件服务器才能将表单发送出去。不过,奇怪的是,我在过去不需要遵循这些步骤就可以使用它。

    【讨论】:

      猜你喜欢
      • 2013-02-10
      • 1970-01-01
      • 2016-06-25
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      • 2012-12-29
      • 2022-11-11
      相关资源
      最近更新 更多