Php 联系人表单发送错误

Php 联系人表单发送错误,php,html,phpmailer,Php,Html,Phpmailer,我正在使用一个模板,只是想让我的联系表正常工作(试着看看它是如何工作的,发送消息等等)。填写我的联系人表单,然后点击“提交”时,会弹出一个错误,而不是成功完成: 由于出现意外错误,无法发送电子邮件。请稍后再试 原因: 无法实例化邮件函数 这是我的HTML联系人表单: <div class="col_half col_last"> <div class="fancy-title title-dotted-border test-john&

我正在使用一个模板,只是想让我的联系表正常工作(试着看看它是如何工作的,发送消息等等)。填写我的联系人表单,然后点击“提交”时,会弹出一个错误,而不是成功完成:

由于出现意外错误,无法发送电子邮件。请稍后再试

原因: 无法实例化邮件函数

这是我的HTML联系人表单:

<div class="col_half col_last">

    <div class="fancy-title title-dotted-border test-john">
        <h3>Send us an Email</h3>
    </div>

    <div class="contact-widget">

        <div class="contact-form-result"></div>

        <form class="nobottommargin" id="template-contactform" name="template-contactform" action="include/sendemail.php" method="post">

        <div class="form-process"></div>

        <div class="col_one_third">
            <label for="template-contactform-name">Name <small>*</small></label>
            <input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="sm-form-control required" />
        </div>

        <div class="col_one_third">
            <label for="template-contactform-email">Email <small>*</small></label>
            <input type="email" id="template-contactform-email" name="template-contactform-email" value="" class="required email sm-form-control" />
        </div>

        <div class="col_one_third col_last">
            <label for="template-contactform-phone">Phone</label>
            <input type="text" id="template-contactform-phone" name="template-contactform-phone" value="" class="sm-form-control" />
        </div>

        <div class="clear"></div>

        <div class="col_full">
            <label for="template-contactform-subject">Subject <small>*</small></label>
            <input type="text" id="template-contactform-subject" name="template-contactform-subject" value="" class="required sm-form-control" />
        </div>

        <div class="clear"></div>

        <div class="col_full">
            <label for="template-contactform-message">Message <small>*</small></label>
            <textarea class="required sm-form-control" id="template-contactform-message" name="template-contactform-message" rows="6" cols="30"></textarea>
        </div>

        <div class="col_full hidden">
            <input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control" />
        </div>

        <div class="col_full">
            <button name="submit" type="submit" id="submit-button" tabindex="5" value="Submit" class="button button-3d nomargin">Submit Comment</button>
        </div>

        </form>
    </div>

</div>

这给了我更多的问题。
mail.yourdomain.com
中的
邮件是什么?是cPanel、我的电子邮件的用户/通行证吗?

以下是我在Bluehost上的设置方式:

function mailerExpressBlueHost(array $mailInputs){

         require_once '../includes/phpmailer/PHPMailerAutoload.php';

         $mail = new PHPMailer();
         $mail->IsMail();

         $mail->SetFrom('skipper@yourdomain.com'); // make sure this is an andress 
                                                 // on your domain        
         $mail->IsHTML(true);
         $mail->addAddress($mailInputs['addAddress']);    
         $body = $mailInputs['body'] ;              
         $mail->isHTML(true);
         $mail->Subject = $mailInputs['subject'] ;
         $mail->Body    = $body;

         if(!$mail->send()) {
            return 'Message could not be sent.' . 'Mailer Error: ' . $mail->ErrorInfo;  
         } else {
            return 'Message has been sent';
         }

          $mail->ClearAddresses();
}

您是在本地服务器上尝试此操作吗?我认为您需要在PHPMail$mail实例上设置其他属性,除非出于安全考虑而忽略这些属性。@DCR No(在我的实时托管站点| | Magnus Eriksson上)-这是否意味着我需要将表单中的值更改为“POST”而不是“SUBMIT”?|兰登:我没有成功,所以不完全确定那意味着什么,我说错了,看错了线。删除了我的评论。可能,我会建议你无论如何不要使用
mail()
,所以无论如何都值得一试。
<?php
/**
 * PHPMailer SPL autoloader.
 * PHP Version 5
 * @package PHPMailer
 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
 * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
 * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
 * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
 * @author Brent R. Matzelle (original founder)
 * @copyright 2012 - 2014 Marcus Bointon
 * @copyright 2010 - 2012 Jim Jagielski
 * @copyright 2004 - 2009 Andy Prevost
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 * @note This program is distributed in the hope that it will be useful - WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 */

/**
 * PHPMailer SPL autoloader.
 * @param string $classname The name of the class to load
 */
function PHPMailerAutoload($classname)
{
    //Can't use __DIR__ as it's only in PHP 5.3+
    $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
    if (is_readable($filename)) {
        require $filename;
    }
}

if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
    //SPL autoloading was introduced in PHP 5.1.2
    if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
        spl_autoload_register('PHPMailerAutoload', true, true);
    } else {
        spl_autoload_register('PHPMailerAutoload');
    }
} else {
    /**
     * Fall back to traditional autoload for old PHP versions
     * @param string $classname The name of the class to load
     */
    function __autoload($classname)
    {
        PHPMailerAutoload($classname);
    }
}
$mail->IsSMTP();
$mail->Host = "mail.yourdomain.com";
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Port = 26;
$mail->Username = "yourname@yourdomain.com";
$mail->Password = "yourpassword";
function mailerExpressBlueHost(array $mailInputs){

         require_once '../includes/phpmailer/PHPMailerAutoload.php';

         $mail = new PHPMailer();
         $mail->IsMail();

         $mail->SetFrom('skipper@yourdomain.com'); // make sure this is an andress 
                                                 // on your domain        
         $mail->IsHTML(true);
         $mail->addAddress($mailInputs['addAddress']);    
         $body = $mailInputs['body'] ;              
         $mail->isHTML(true);
         $mail->Subject = $mailInputs['subject'] ;
         $mail->Body    = $body;

         if(!$mail->send()) {
            return 'Message could not be sent.' . 'Mailer Error: ' . $mail->ErrorInfo;  
         } else {
            return 'Message has been sent';
         }

          $mail->ClearAddresses();
}