PHPMAILER Not sending and not giving error(PHPMAILER 不发送也不给出错误)
                            本文介绍了PHPMAILER 不发送也不给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
我正在尝试让用户填写联系表格,然后将其发送到我的电子邮件中.但由于某种原因它不起作用.我只是得到一个空白页,没有错误消息或任何文本和电子邮件也没有发送.
I am trying to let users fill out a contact form, which will then be sent to my email. But its not working for some reason. I just get a blank page with no error message or any text and email is also not sent.
if (isset($_POST['submit']))
{
    include_once('class.phpmailer.php');
    $name = strip_tags($_POST['full_name']);
    $email = strip_tags ($_POST['email']);
    $msg = strip_tags ($_POST['description']);
    $subject = "Contact Form from DigitDevs Website";
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->CharSet = 'UTF-8';
    $mail->Host       = "mail.example.com"; // SMTP server example
    //$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->Port       = 26;                    // set the SMTP port for the GMAIL server
    $mail->Username   = "info@example.com"; // SMTP account username example
    $mail->Password   = "password";        // SMTP account password example
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->AddAddress('info@example.com', 'Information'); 
    $mail->AddReplyTo($email, 'Wale');
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->Body    =  $msg;
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    if(!$mail->Send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    exit;
}
echo 'Message has been sent';
推荐答案
你需要调用:
$mail = new PHPMailer(true); // with true in the parenthesis
来自文档:
true 参数意味着它会在错误时抛出异常,这是我们需要的赶上.
The
trueparam means it will throw exceptions on errors, which we need to catch.
这篇关于PHPMAILER 不发送也不给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:PHPMAILER 不发送也不给出错误
 
				
         
 
            
        
             猜你喜欢
        
	     - 带有通配符的 Laravel 验证器 2021-01-01
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
 
				 
				 
				 
				