首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sendmail.exe在发送邮件时打开

sendmail.exe在发送邮件时打开
EN

Stack Overflow用户
提问于 2014-07-01 15:45:08
回答 3查看 8.5K关注 0票数 3

实际上,我在使用sendmail方面还是新手,但是我已经读了很多关于这方面的文章,并且只是重定向我使用PHPmailer、迅捷邮件等等.但如果不了解基本知识,就很难理解。所以我决定尝试简单,这就是我所拥有的。

我已经配置了我的php.ini:

代码语言:javascript
复制
[mail function]
smtp_port = 465
sendmail_path="C:\wamp\sendmail\sendmail.exe -t"
mail.add_x_header = On

我的sendmail.ini:

代码语言:javascript
复制
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=mygmail@gmail.com
auth_password=mypassword
hostname=localhost

我有这个PHP代码:

代码语言:javascript
复制
$to      = 'mygmail@gmail.com';
$message = $_POST['message'];
$email = $_POST['email'];
$contact_num = $_POST['contact_number'];
$headers = 'From:'.'$email' . "\r\n" .'$contact' . "\r\n" .
'Reply-To: mygmail@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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

但是,当我单击submit按钮时,sendmail.exe就会出现,什么也不会发生。当我检查error.log时,上面写着:

代码语言:javascript
复制
14/07/01 23:23:48 : Connection Closed Gracefully.
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-09-02 19:42:06

这个部分是post: Sendmail Wamp Php的副本和粘贴

问题是sendmail必须作为管理员运行。这是帮助任何一个人解决我的问题的办法。

  1. 右键单击sendmail.exe
  2. 属性
  3. 兼容性
  4. 更改所有用户的配置
  5. 作为Windows 3执行
  6. 作为管理员执行 如果您使用gmail,则需要创建新密码“您的应用程序专用密码”。

如果这还不起作用(我的答案)

确保服务器(或IDE)以admin的身份运行,方法之一是:

1)右键单击程序(例如,服务器、ide、命令提示符),然后单击“以管理方式运行”。

2)或右键单击“program> properties> compatiblity>”执行管理。

例如,如果您在构建的服务器中使用PHP,请以admin方式运行命令提示符,然后使用

代码语言:javascript
复制
C:\wamp\bin\php\php5.5.12\php.exe -S localhost:80 -t C:\Users\path\to\rootFolder

当然,更改文件路径以满足您的需要。

编辑:这很可能是您进入https://bugs.php.net/bug.php?id=44994的错误

票数 3
EN

Stack Overflow用户

发布于 2016-01-14 06:47:12

解决方案是设置sendmail.ini和php.ini

您需要与您的isp通信,以了解什么是开放的smtp服务器,他们大多数都有一个,这是类似于smtp.yourisp.com的大多数时间。

您还可以使用自己的电子邮件服务器或现有的电子邮件地址来设置smtp --这将需要额外的设置,例如特定的smtp服务器、端口号、迫使sendmail成为实际邮件、用户名、密码和大多数情况下的ssl。

php.ini

代码语言:javascript
复制
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury  SMTP = smtp.yourisp.mu  smtp_port = 25

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

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly. ; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.   ; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder) sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder ;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

确保php和sendmail作为管理员运行似乎是个好主意,但这并没有解决我的问题。

sendmail.ini中的解决方案

代码语言:javascript
复制
smtp_server = smtp.yourisp.com

; smtp port (normally 25)

smtp_port=25

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=none

不要使用导致我的错误的smtp_ssl = auto,只需根据您服务器的规范将其设置为ssl或none

票数 1
EN

Stack Overflow用户

发布于 2017-02-02 23:28:57

确保以管理员身份运行XAMPP。通过右键单击它并单击“以管理员身份运行”,就可以做到这一点。帮我修好了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24514432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档