Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.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 SMTP自定义联系人表单_Php_Forms_Email_Smtp - Fatal编程技术网

PHP SMTP自定义联系人表单

PHP SMTP自定义联系人表单,php,forms,email,smtp,Php,Forms,Email,Smtp,我有这个表单,可以在本地发送,但是当我将它上传到hostgator时,会收到以下错误消息 邮件程序错误:无法实例化邮件功能 我的php代码是 <?php if(isset($_POST['submit'])){ require 'PHPMailer/PHPMailerAutoload.php'; // Send mail $mail = new PHPMailer(); // Data received from POST request $

我有这个表单,可以在本地发送,但是当我将它上传到hostgator时,会收到以下错误消息

邮件程序错误:无法实例化邮件功能

我的php代码是

<?php

if(isset($_POST['submit'])){

    require 'PHPMailer/PHPMailerAutoload.php';

    // Send mail
    $mail = new PHPMailer();

    // Data received from POST request
    $name = stripcslashes($_POST['tbName']);
    $emailAddr = stripcslashes($_POST['tbEmail']);
    $company = stripcslashes($_POST['tbCompany']);
    $comment = stripcslashes($_POST['taMessage']);
    $subject = stripcslashes($_POST['tbSubject']);  

    // SMTP Configuration
    $mail->SMTPAuth = true; 
    $mail->Host = "gator3209.hostgator.com"; // SMTP server
    $mail->Username = "****@*****.com";
    $mail->Password = "***********";
    $mail->SMTPSecure = 'tls';   
    $mail->Port = 25; 

    $mail->AddAddress('****@*****.com');
    $mail->From = "****@*****.com";
    $mail->FromName = "Website Contact Form - " . $name;
    $mail->Subject = $subject;

    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';    
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->MsgHTML("Name:" . $name . "<br /><br />Email:" . $emailAddr. "<br /><br />Company:" . $company. "<br /><br />Subject:" . $subject. "<br /><br />" . $comment);

    $message = NULL;
    if(!$mail->Send()) {
        $message = "Mailer Error: " . $mail->ErrorInfo;
    } else {
        $message = "Message sent!";
    }

}
?>

我已经和我的主机谈过了,他们说它不支持处理这些事情,但是说我的端口和主机是正确的


所以现在我很困惑。有什么明显的我遗漏的吗?

只是想让你知道如果有人发现了这个,我的问题是我遗漏了$mail->IsSMTP();从我的配置

SMTP配置部分应如下所示

<?php

if(isset($_POST['submit'])){

    require 'PHPMailer/PHPMailerAutoload.php';

    // Send mail
    $mail = new PHPMailer();

    // Data received from POST request
    $name = stripcslashes($_POST['tbName']);
    $emailAddr = stripcslashes($_POST['tbEmail']);
    $company = stripcslashes($_POST['tbCompany']);
    $comment = stripcslashes($_POST['taMessage']);
    $subject = stripcslashes($_POST['tbSubject']);  

    // SMTP Configuration
    $mail->SMTPAuth = true; 
    $mail->IsSMTP();
    $mail->Host = "gator3209.hostgator.com"; // SMTP server
    $mail->Username = "****@*****.com";
    $mail->Password = "***********";
    $mail->SMTPSecure = 'tls';   
    $mail->Port = 25; 

    $mail->AddAddress('****@*****.com');
    $mail->From = "****@*****.com";
    $mail->FromName = "Website Contact Form - " . $name;
    $mail->Subject = $subject;

    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';    
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->MsgHTML("Name:" . $name . "<br /><br />Email:" . $emailAddr. "<br /><br />Company:" . $company. "<br /><br />Subject:" . $subject. "<br /><br />" . $comment);

    $message = NULL;
    if(!$mail->Send()) {
        $message = "Mailer Error: " . $mail->ErrorInfo;
    } else {
        $message = "Message sent!";
    }

}
?>

为了让你知道如果有人发现了这个,我的问题是我丢失了$mail->IsSMTP();从我的配置

SMTP配置部分应如下所示

<?php

if(isset($_POST['submit'])){

    require 'PHPMailer/PHPMailerAutoload.php';

    // Send mail
    $mail = new PHPMailer();

    // Data received from POST request
    $name = stripcslashes($_POST['tbName']);
    $emailAddr = stripcslashes($_POST['tbEmail']);
    $company = stripcslashes($_POST['tbCompany']);
    $comment = stripcslashes($_POST['taMessage']);
    $subject = stripcslashes($_POST['tbSubject']);  

    // SMTP Configuration
    $mail->SMTPAuth = true; 
    $mail->IsSMTP();
    $mail->Host = "gator3209.hostgator.com"; // SMTP server
    $mail->Username = "****@*****.com";
    $mail->Password = "***********";
    $mail->SMTPSecure = 'tls';   
    $mail->Port = 25; 

    $mail->AddAddress('****@*****.com');
    $mail->From = "****@*****.com";
    $mail->FromName = "Website Contact Form - " . $name;
    $mail->Subject = $subject;

    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';    
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->MsgHTML("Name:" . $name . "<br /><br />Email:" . $emailAddr. "<br /><br />Company:" . $company. "<br /><br />Subject:" . $subject. "<br /><br />" . $comment);

    $message = NULL;
    if(!$mail->Send()) {
        $message = "Mailer Error: " . $mail->ErrorInfo;
    } else {
        $message = "Message sent!";
    }

}
?>


您的主机提供商可能会阻止邮件功能。联系他们的支持以确保它未被阻止。我似乎丢失了$mail->IsSMTP();从我的SMTP配置部分。为链接干杯。帮助我找到问题。不客气:-)您的主机提供商可能会阻止邮件功能。联系他们的支持以确保它未被阻止。我似乎丢失了$mail->IsSMTP();从我的SMTP配置部分。为链接干杯。帮我找到了问题。不客气:-)