doumiebiao6827 2011-08-16 11:37
浏览 13
已采纳

从php发送电子邮件

I am designing a PHP page to send an email. An error is occurring. Please check my code carefully and let me know the error in my code.

This is the output which is generated when i run my program:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

so pls help me to set smtp configuration.

  • 写回答

3条回答 默认 最新

  • douzhou7124 2011-08-16 11:41
    关注

    change $header to $headers, you've got $headers = "From: $from "; and using $header

    mail($to, $subject, $message,$headers);

    so whole code would look like

    <?php 
        //change this to your email. 
        $to = "kuntal.pushpendra@gmail.com"; 
        $from = "puskun.pericent@gmail.com"; 
        $subject = "Hello! This is HTML email"; 
        $message = "hello";
        $headers  = "From: $from
    "; 
        $headers .= "Content-type: text/html
    "; 
        mail($to, $subject, $message,$headers); 
    
        echo "Message has been sent....!"; 
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序