![](/img/trans.png)
[英]php mail function error -> Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
[英]WampServer: Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
我在使用 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
這是我的代碼:
聯系人.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
抱歉,如果它是重復的,我的問題與其他問題不同。
嘗試改變這一點
; 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() 函數不支持它。 您需要編寫基於套接字的個人郵件功能或使用現成的解決方案,如 hMailServer 並使用此軟件發送郵件(hMailServer creditnails 應寫入 php.ini)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.