PHPMailer不在000webhost上工作

www*_*139 2 php email xampp phpmailer

这段代码似乎在我的mac localhost上的Xampp中工作,但它似乎不适用于我的免费000webhost帐户.我已经尝试摆脱SSL,但它没有帮助.请记住,此程序从外部表单获取变量.

 <?php
    $subject = htmlentities($_POST['subject']);
    $email = $_POST['email'];
    $message = htmlentities($_POST['message']);




    require_once 'PHPMailer/PHPMailerAutoload.php';

    $m = new PHPMailer;

    $m->isSMTP();
    $m->SMTPAuth = true;
    //$m->SMTPDebug = 1;
    $m->Host = 'smtp.gmail.com';
    $m->Username = 'email-adress@gmail.com';
    $m->Password = 'password';
    $m->SMTPSecure = 'ssl';
    $m->Port = 465;

    $m->From = 'email-adress@gmail.com';
    $m->FromName = 'William Green';
    $m->addReplyTo('email-adress@gmail.com', 'William Green');

    //$m->addCC('email2-address@gmail.com', 'Willliam green');


    ########################################
    //email code
    //$recipient = strip_tags($_POST['mailRecipient']);
    //$name = strip_tags($_POST['recipientsName']);


    $m->addAddress($email, $email);



    //$m->Subject = strip_tags($_POST['mailSubject']);
    //$m->Body = strip_tags($_POST['mailBody']);
    $m->Subject = $subject;
    $m->Body = $message;


   //$m->AltBody = 'plain text version!';


    ###########################################





    //var_dump($m->send());
    if ($m->send())
    {
    echo '<h1 class="good">Email Sent!</h1>';
    }
    else
    {
    echo '<h1 class="bad">Email Not Sent!</h1>';
    }


    ?>
Run Code Online (Sandbox Code Playgroud)

Fun*_*ner 7

"但它似乎不适用于我的免费000webhost帐户"

答:他们提供免费托管的SMTP.请改用PHP的mail()功能.

注意x他们网站上的SMTP服务器旁边的红色=> http://www.000webhost.com/

在此输入图像描述

使用mail()支付它以使用SMTP.

您可以在他们的网站上进行,也可以在控制面板中进行升级.

编辑(2016年9月16日):这个答案是在他们修改网站之前发布的.您可以在此处查看可用于免费/付费服务的可用选项的URL,网址为https://www.000webhost.com/premium-web-hosting

这也适用于与数据库的远程连接.

这个答案是针对我今天看到的与我的编辑有关的问题编辑的.