我想从本地主机服务器发送电子邮件。我在这里使用wamp server和sendmail选项。但我没有得到任何错误: -
但没有邮件发送给用户的电子邮件
if (!$result)
{
die (mysql_error());
}
if ($result == 1)
{
$rows = mysql_fetch_array($sql);
$password = $rows['pwd'];
$email = $rows['user_email'];
$subject ="Password request";
$header = "FROM: sazalach@gmail.com";
$body = "Your password is " . $password;
mail ($email, $subject, $header, $body);
print("an email containning the password has been sent to you");
}else
{
echo ("No such user exists in the system. Please try again");
}
以下是sendmail配置:
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
; 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=auto
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
;default_domain=mydomain.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
;debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=sazalach@gmail.com
auth_password=
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.
以下配置位于php.ini文件中
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"