drfqfuhej48511519 2013-09-25 14:19
浏览 270
已采纳

电子邮件发送Localhost

I'm wondering if it is possible to send an email from a localhost? I've tried something but it didn't worked and I thought maybe it wont work in a localhost. Here's the code:

           // Send the email:
            $message = " To activate your account, please click on this link:

";
            $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation";
            mail($Email, 'Registration Confirmation', $message, 'From: ismaakeel@gmail.com');

            // Flush the buffered output.


            // Finish the page:
            echo '<div class="success">Thank you forregistering! A confirmation email has been sent to '.$Email.' Please click on the Activation Link to Activate your account </div>';

And here's the connection:

        /*Define constant to connect to database */
        DEFINE('DATABASE_USER', 'root');
        DEFINE('DATABASE_PASSWORD', 'buena');
        DEFINE('DATABASE_HOST', 'localhost');
        DEFINE('DATABASE_NAME', 'forum');
        /*Default time zone ,to be able to send mail */
        date_default_timezone_set('UTC');

        /*You might not need this */
        ini_set('SMTP', "mail.myt.mu"); // Overide The Default Php.ini settings for sending mail


        //This is the address that will appear coming from ( Sender )
        define('EMAIL', 'ismaakeel@gmail.com');

        /*Define the root url where the script will be found such as http://website.com or http://website.com/Folder/ */
        DEFINE('WEBSITE_URL', 'http://localhost');


       // Make the connection:
      $dbc = @mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD,
DATABASE_NAME);

       if (!$dbc) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
       }

Is there anything wrong? Or missing?

  • 写回答

3条回答 默认 最新

  • dqgg25493 2013-09-25 14:48
    关注

    Your code is fine, the problem is the mechanism through which PHP sends the email. In windows there is no out-of-the-box solution for PHP's mail() function to use to send the email contrast to *NIX systems which come shipped with mostly sendmail.

    In any case it is possible to implement such a mechanism in Windows to allow the mail() function to work seamlessly. As quick as it is to do s, I won't go into how to do it here. Please refer to this clear step-by-step post and you'll be up and running in no time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。