我对WampServer有一个问题,我试着创建一个联系人表单,但是它不起作用。BIOS不再识别我的2GB内存芯片,所以我的系统认为它是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>mail.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抱歉,如果是复制的话,我的问题就不一样了。
发布于 2016-02-07 04:13:56
试着改变这个
; 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我的变体之一对你来说应该没问题。
但是我不建议使用mail()函数,尤其是对于Wamp (套接字将是一个很好的解决方案)。
更新
您是否真的在mail()中使用Gmail smtp服务,或者仅仅发布Gmail?对于使用Gmail服务,您需要身份验证(password+username),但是mail()函数不支持它。您需要编写基于套接字的个人邮件功能,或者使用现成的解决方案(如hMailServer ),并使用此软件发送邮件(hMailServer信用卡应该写入php.ini)。
https://stackoverflow.com/questions/35249439
复制相似问题