php从本地主机发送邮件 [英] php send mail from localhost

查看:137
本文介绍了php从本地主机发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的php。我正在尝试使用此代码从php发送邮件。

 <?php 

$ ='sohildesai.xxxx@gmail.com';
$ subject ='主题';
$ message ='hello';
$ headers ='From:sohildesai.xxxx@yahoo.in'。 \\\\。
'回复:dhamaal_xxxx@yahoo.in'。 \\\\。
'X-Mailer:PHP /'。 phpversion();

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

?>

我有更改php.ini设置

  [邮件功能] 
;仅适用于Win32
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

;仅适用于Win32
; http://php.net/sendmail-from
sendmail_from = sohildesai.xxxx@gmail.com

&安培;在sendmail.ini中

 #免费邮件服务示例
帐户Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from sohildesai.xxxx@gmail.com
auth on
用户sohildesai.xxxx@gmail.com
密码xxxxxxxxx

#设置默认帐户
帐户默认值:Gmail

现在代码运行成功但我没有收到任何邮件。

解决方案

您必须更改php.ini文件:

  [邮件功能] 
;仅适用于Win32
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

;仅适用于Win32
; http://php.net/sendmail-from
sendmail_from = you @ yourdomain

它如果设置了localhost,将无法正常工作,因此更改为您的邮件服务器。


I am new at php. I was trying to send mail from php using this code.

<?php

    $to      = 'sohildesai.xxxx@gmail.com';
    $subject = 'The subject';
    $message = 'hello';
    $headers = 'From: sohildesai.xxxx@yahoo.in' . "\r\n" .
        'Reply-To: dhamaal_xxxx@yahoo.in' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

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

?>

I have change settings in php.ini

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

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = sohildesai.xxxx@gmail.com

& in sendmail.ini

# A freemail service example
account Gmail
tls on
tls_certcheck off
host smtp.gmail.com
from sohildesai.xxxx@gmail.com
auth on
user sohildesai.xxxx@gmail.com
password xxxxxxxxx

# Set a default account
account default : Gmail

Now code runs successfully but I am not getting any mail.

解决方案

You must change the php.ini file:

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

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

It won't work if localhost is set, for that reason change to your mail server.

这篇关于php从本地主机发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆