如何configurationWAMP(localhost)使用Gmail发送电子邮件?

我想从我的本地主机使用mail()函数。 我已经安装了WAMP和一个Gmail帐户。 我知道Gmail的SMTP是smtp.gmail.com,端口是465( 来自gmail的更多信息 )。 我需要在WAMP中configuration所以我可以使用mail()函数?

谢谢!!

Gmail服务器在SSL或TLS下使用SMTP身份validation。 我认为在这种情况下没有办法使用mail()函数,所以你可能想要检查这些替代方法:

  • PEAR ::邮件
  • PHPMailer的
  • •奈特\邮件

他们都支持SSL下的SMTPauthentication。

您需要在您的php.ini中启用php_openssl扩展名。

其他资源:

  • 如何使用SMTPvalidation从PHP脚本发送电子邮件 (使用PEAR::Mail
  • 使用Gmail使用Gmail发送电子邮件 (使用phpMailer
  • 邮寄使用Nette\Mail

[使用hMailServer ]
安装之后,您需要以下configuration才能正确发送来自wampserver的邮件:

 1) When you first open hMailServer Administrator, you need to add a new domain. 2) Click on the "Add Domain ..." button at the Welcome page. 3) Under the domain text field, enter your computer's IP, in this case it should be 127.0.0.1. 4) Click on the Save button. 5) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab 6) Enter "localhost" in the localhost name field. 7) Click on the Save button. 

如果您需要使用另一台计算机的FROM收件人发送邮件,则需要允许从外部到外部帐户进行交付。 要这样做,请按照下列步骤操作:

 1) Go to Settings>Advanced>IP Ranges and double click on "My Computer" which should have IP address of 127.0.0.1 2) Check the Allow Deliveries from External to External accounts checkbox. 3) Save settings using Save button. 

(但是,Windows Live / Hotmail拒绝所有来自dynamicIP的电子邮件,这是大多数住宅电脑使用的。解决方法是使用Gmail帐户)

要使用Gmail帐户:

 1) Go to Settings>Protocols>SMTP and select "Delivery of Email" tab 2) Enter "smtp.gmail.com" in the Remote Host name field. 3) Enter "465" as the port number 4) Check "Server requires authentication" 5) Enter gmail address in the Username 6) Enter gmail password in the password 7) Check "Use SSL" 

(注意,“From”字段不能和gmail一起使用)


* ps在极less数情况下,可能需要在所有require SMTP authentication下解决所有问题:

  • 对于本地:设置>高级> IP范围>“我的电脑”
  • 对于外部:设置>高级> IP范围>“Internet”

如果你用wamp打开php.ini文件,你会发现这两行:

 smtp_server smtp_port 

为您的主机添加服务器和端口号(您可能需要联系他们了解详情)

以下两行不存在:

 auth_username auth_password 

因此,您需要添加它们才能从需要validation的服务器发送邮件。 所以一个例子可能是:

 smtp_server = mail.example.com smtp_port = 26 auth_username = example_username@example.com auth_password = example_password 

我知道在XAMPP我可以configurationsendmail.ini转发本地电子邮件。 需要设置

 smtp_sever smtp_port auth_username auth_password 

这有效的时候使用我自己的服务器,而不是Gmail,所以不能肯定地说你没有问题

在你的服务器上使用stunnel,用gmail发送。 去谷歌上查询。

这很简单。 (适应你的方便的语法)

 public $smtp = array( 'transport' => 'Smtp', 'from' => 'your_email@gmail.com', 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 30, 'username' => 'your_email@gmail.com', 'password' => '*****' ) 

你喜欢Zend库吗?

  $config = array('auth' => 'login', 'ssl' => 'ssl', 'port'=> 465, 'username' => 'XXXX@gmail.com', 'password' => 'XXXXXXX'); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); $mail = new Zend_Mail(); $mail->setBodyText('This is the text of the mail.'); $mail->setFrom('XXXX@gmail.com', 'Some Sender'); $mail->addTo('kazifriend@gmail.com', 'Some Recipient'); $mail->setSubject('TestSubj'); $mail->send($transport); 

这是我在本地主机服务器设置,我可以看到收到邮件到我的邮箱。

我很积极,它也需要SMTPauthentication凭证。

梨:邮件工作为我从Gmail发送电子邮件。 此外,说明: 如何使用SMTP身份validation (使用PEAR :: Mail) 从PHP脚本发送电子邮件帮助很大。 谢谢,CMS!