2009-03-01 177 views

回答

27

Gmail服务器在SSL或TLS下使用SMTP身份验证。我认为这是没有办法用mail()作用下,由于情况,所以你可能要检查这些替代品:

他们都支持SMTP auth在SSL下。

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

其他资源:

+0

非常感谢! – Jonathan 2009-03-01 23:13:13

+1

你能告诉我确切位置在哪里放置 $ host =“ssl://smtp.gmail.com”; $ port = 465; 。? 谢谢 – 2010-05-13 10:47:45

2

我知道XAMPP

  • Mailing我可以配置sendmail.ini转发本地电子邮件。 需要设置

    smtp_sever 
    smtp_port 
    auth_username 
    auth_password 
    

    这个用我自己的服务器时的作品,不属于Gmail所以不能肯定地说你有任何问题

  • 11

    如果你打开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 
    
    +1

    未经测试,但这可能是错误的。如上所述,PHP没有这样的指令(除`smtp_port`外)。另请参阅http://stackoverflow.com/a/21891895/3827190作为参考。 – Kubo2 2015-12-29 17:53:55

    2

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

    2

    这很简单。(Adapt语法为您的方便)

    public $smtp = array(
        'transport' => 'Smtp', 
        'from' => '[email protected]', 
        'host' => 'ssl://smtp.gmail.com', 
        'port' => 465, 
        'timeout' => 30, 
        'username' => '[email protected]', 
        'password' => '*****' 
    ) 
    
    2

    你喜欢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服务器上设置的,我能够看到收到的邮件到我的邮箱。

    13

    [使用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帐户)

    要使用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下勾去掉一切:

    • 地方:设置>高级> IP系列> “我的电脑”
    • 外部:设置>高级> IP范围>“Internet”
    相关问题