【问题标题】:WampServer: Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command firstWampServer:警告:mail():SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令
【发布时间】:2016-05-16 22:09:07
【问题描述】:

我在使用 WampServer 时遇到问题,我尝试创建一个联系表单,但它不起作用。 BIOS 停止识别我的 2GB RAM 芯片,所以我的系统认为它是 32 位而不是 64 位。这是PHP错误表:

( ! ) Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. 8sm9902426ioe.8 - gsmtp in C:\Users\miner\Desktop\Configuration Creator\www\contact\mail.php on line 10
Call Stack
#   Time    Memory  Function    Location
1   0.0004  245672  {main}( )   ..\mail.php:0
2   0.0004  246648  mail ( )    ..\mail.php:10

这是我的代码:

contact.html

<form action="mail.php" method="POST">
    <input type="text" class="form-control" name="name" placeholder="Name">
    <div class="padded-bottom"></div>
    <input type="text" class="form-control" name="email" placeholder="Email">
    <div class="padded-bottom"></div>
    <input type="text" class="form-control" name="subject" placeholder="Subject">
    <div class="padded-bottom"></div>
    <textarea type="text" class="form-control no-resize paragraph" rows="8" name="message" placeholder="Message"></textarea>
    <div class="padded-bottom"></div>
    <button type="submit" class="btn btn-default">Submit</button> <button type="reset" class="btn btn-default">Clear Form</button>
</form>

邮件.php

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$from = 'From: '. $name; 
$to = 'email@example.com'; 
$subject = $subject;
$body = "From: $name\n Email: $email\n Message:\n $message";     
if (mail ($to, $subject, $body, $from)) { 
    echo '<p>Your message has been sent!</p>';
} else { 
    echo '<p>Something went wrong. Please manually <a href="mailto:email@example.com">email me</a> and include a screenshot/copy of the log above.</p>'; 
}
?>

最后是 php.ini

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

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

对不起,如果它是重复的,我的问题与其他问题不同。

【问题讨论】:

    标签: php email


    【解决方案1】:

    尝试改变这一点

    ; http://php.net/smtp
    SMTP = smtp.gmail.com
    ; http://php.net/smtp-port
    smtp_port = 587
    

    对此(变体 #1):

    ; http://php.net/smtp
    SMTP = ssl://smtp.gmail.com
    ; http://php.net/smtp-port
    smtp_port = 465
    

    或者到这个(变体#2):

    ; http://php.net/smtp
    SMTP = tls://smtp.gmail.com
    ; http://php.net/smtp-port
    smtp_port = 587
    

    我的一个变种应该适合你。

    但我不建议在 Wamp 中使用 mail() 函数(套接字将是很好的解决方案)。

    更新

    您真的将 Gmail smtp-service 与 mail() 一起使用,还是仅作为示例发布 Gmail?要使用 Gmail smtp-service,您需要身份验证(密码+用户名),但 mail() 函数不支持它。您需要编写基于sockets的个人邮件功能或使用现成的解决方案,如hMailServer并使用此软件发送邮件(hMailServer creditnails应该写入php.ini)。

    【讨论】:

    • (!) 更改 php.ini 后别忘了重启 Wamp
    • 我不久前用同样的东西工作,只是系统架构不同。 stackoverflow.com/users/5757238/vika-marquez我找不到你的用户名,所以我必须链接你的个人资料。
    • 因为mail() 不支持授权(用户名+密码)。再次查看我的更新,我已经写了你需要做什么。或者你需要编写基于sockets的个人邮件功能,或者你需要使用像hMailServer这样的软件(hMailServer的creditnails应该添加到php.ini中)
    猜你喜欢
    • 1970-01-01
    • 2011-07-13
    • 2014-06-27
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    相关资源
    最近更新 更多