我想用mail()函数从我的本地主机。我有WAMP安装和Gmail帐户。我知道,Gmail中的SMTP是smtp.gmail.com,端口为465(more info from gmail)。我需要在WAMP配置,所以我可以使用邮件()函数是什么?
谢谢!!
Gmail的服务器使用SMTP验证下SSL或TLS。我认为这是没有办法使用根据该情况mail()
功能,所以你可能要检查这些替代品:
他们SSL下都支持SMTP认证。
你需要让你的php.ini的php_openssl
扩展。
其他资源:
PEAR::Mail
)Nette\Mail
我回答说,在这里:(WAMP/XAMP) send Mail using SMTP localhost(作品不仅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
这是很简单的。 (适应的语法为您提供方便)
public $smtp = array(
'transport' => 'Smtp',
'from' => '[email protected]',
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '[email protected]',
'password' => '*****'
)
作为一种替代的PHPMailer,梨的邮件和其他人,你可以使用Zend's library
$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);
这是我设立在本地主机服务器,我可以看到收到的邮件到我的邮箱。
我知道我的XAMPP可以配置sendmail.ini转发本地电子邮件。需要设置
smtp_sever
smtp_port
auth_username
auth_password
这个用我自己的服务器时的作品,不属于Gmail所以不能肯定地说你有任何问题
使用您的服务器上的安全通道,以使用Gmail发送。谷歌一下。
我敢肯定它需要SMTP认证证书也是如此。
PEAR: Mail工作对我来说,从Gmail发送电子邮件。此外,指示:How to Send Email from a PHP Script Using SMTP Authentication(使用PEAR ::邮件)帮助很大。谢谢,CMS!