我想从我的本地主机使用mail()函数。我安装了WAMP和一个Gmail帐户。我知道Gmail的SMTP是smtp.gmail.com,端口是465(more info from gmail)。 我需要在WAMP中进行配置,以便使用mail()函数?如何配置WAMP(localhost)使用Gmail发送电子邮件?
谢谢!
我想从我的本地主机使用mail()函数。我安装了WAMP和一个Gmail帐户。我知道Gmail的SMTP是smtp.gmail.com,端口是465(more info from gmail)。 我需要在WAMP中进行配置,以便使用mail()函数?如何配置WAMP(localhost)使用Gmail发送电子邮件?
谢谢!
Gmail服务器在SSL或TLS下使用SMTP身份验证。我认为这是没有办法用mail()
作用下,由于情况,所以你可能要检查这些替代品:
他们都支持SMTP auth在SSL下。
您需要在您的php.ini中启用php_openssl
扩展名。
其他资源:
PEAR::Mail
)Nette\Mail
我很积极,它也需要SMTP认证证书。
我知道XAMPP
smtp_sever
smtp_port
auth_username
auth_password
这个用我自己的服务器时的作品,不属于Gmail所以不能肯定地说你有任何问题
如果你打开WAMP php.ini文件,你会发现这两条线:
smtp_server
smtp_port
添加服务器和端口号为您的主机(您可能需要与他们联系,了解详细信息)
下面两行没有存在:
auth_username
auth_password
因此,您需要添加它们才能够从需要验证的服务器发送邮件。所以一个例子可能是:
smtp_server = mail.example.com
smtp_port = 26
auth_username = [email protected]
auth_password = example_password
未经测试,但这可能是错误的。如上所述,PHP没有这样的指令(除`smtp_port`外)。另请参阅http://stackoverflow.com/a/21891895/3827190作为参考。 – Kubo2 2015-12-29 17:53:55
在你的服务器上使用stunnel,用gmail发送。去谷歌上查询。
PEAR: Mail曾经为我发送Gmail邮件。另外,说明:How to Send Email from a PHP Script Using SMTP Authentication(使用PEAR :: Mail)的帮助很大。谢谢,CMS!
这很简单。(Adapt语法为您的方便)
public $smtp = array(
'transport' => 'Smtp',
'from' => '[email protected]',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '[email protected]',
'password' => '*****'
)
你喜欢Zend库吗?
$config = array('auth' => 'login',
'ssl' => 'ssl',
'port'=> 465,
'username' => '[email protected]',
'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('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubj');
$mail->send($transport);
这是我在localhost服务器上设置的,我能够看到收到的邮件到我的邮箱。
[使用hMailServer]
安装后,您需要以下配置正确地从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.
如果需要使用发送邮件从另一台计算机的收件人,你需要允许从外部到外部账户交付。要做到这一点,请按照下列步骤操作:
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的否认从动态IP,大多数住宅的电脑使用的是哪个未来的所有电子邮件的解决方法是使用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"
(注 “从” 与Gmail场犯规功能)
* p.s。在极少数情况下,有可能需要在require SMTP authentication
下勾去掉一切:
非常感谢! – Jonathan 2009-03-01 23:13:13
你能告诉我确切位置在哪里放置 $ host =“ssl://smtp.gmail.com”; $ port = 465; 。? 谢谢 – 2010-05-13 10:47:45