duanbairan4235 2013-05-06 11:11
浏览 61
已采纳

从php代码发送电子邮件

I want to send an e-mail using a php code,I am using wampserver.

an error appear :

 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() in C:\wamp\www\Newsletter1\index.php on line 29

My file php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = myEmail@gmail.com

Is there any more configuration to do?

Update

I'am using the mail function to send a newsletter to subscriber and I am testing now locally then I will test the code on production environment

  • 写回答

4条回答 默认 最新

  • douxiao0400 2013-05-06 11:13
    关注

    You need a SMTP mailserver daemon running on localhost. If you are using a unix host and you don't want to setup a full SMTP agent, try removing the SMTP config part, thus directly using sendmail. From the docs:

    The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).

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

报告相同问题?

悬赏问题

  • ¥15 自定义 thinkphp 命令行,一直报错,如何解决?
  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题