我知道有很多关于smtp,1and1托管和Zend Framework的问题。我已经读了几个小时但仍然没有得到任何东西(也许我省略了最重要的一个?)。所以,让我们谈谈:
我正在使用相当常见的配置:
email.configTransport.auth =“login” email.configTransport.username =“my@mail.com” email.configTransport.password =“密码” email.configTransport.host =“smtp.1and1.pl”
然后在bootstrap中我正在设置默认传输:
protected function _initDefaultEmailTransport(){
$configTransport = $this->getOption('email');
$tr = new Zend_Mail_Transport_Smtp($configTransport['configTransport']['host'],
$configTransport['configTransport']);
Zend_Mail::setDefaultTransport($tr);
}
我会很高兴任何想法可能出错。
我看不到可以覆盖的地方。除此之外,我尝试了生产和开发配置。 OpenSSL确实启用了,我已经检查过了。这是我的配置文件。
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutpath = APPLICATION_PATH "/layouts/scripts/"
autoloaderNamespaces[] = "Doctrine"
doctrine.dsn = "mysql://...."
doctrine.data_fixtures_path = APPLICATION_PATH "/../doctrine/data/fixtures"
doctrine.models_path = APPLICATION_PATH "/models"
doctrine.migrations_path = APPLICATION_PATH "/../doctrine/migrations"
doctrine.sql_path = APPLICATION_PATH "/../doctrine/data/sql"
doctrine.yaml_schema_path = APPLICATION_PATH "/../doctrine/schema"
doctrine.generate_models_options.pearStyle = true
doctrine.generate_models_options.generateTableClasses = true
doctrine.generate_models_options.generateBaseClasses = true
doctrine.generate_models_options.baseClassPrefix = "Base_"
doctrine.generate_models_options.baseClassesDirectory =
doctrine.generate_models_options.classPrefixFiles = false
doctrine.generate_models_options.classPrefix = "Application_Model_"
resources.mail.transport.type = "smtp"
resources.mail.transport.host = "smtp.gmail.com"
resources.mail.transport.auth = "login"
resources.mail.transport.ssl = "tls"
resources.mail.transport.username = "username"
resources.mail.transport.password = "pass"
resources.mail.transport.register = true
autoloaderNamespaces[] = "ZC"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
这是完整的错误消息:
Stack trace:
#0 /homepages/46/d339149978/htdocs/library/Zend/Mail/Protocol/Smtp.php(167): Zend_Mail_Protocol_Abstract->_connect('tcp://smtp.gmai...')
#1 /homepages/46/d339149978/htdocs/library/Zend/Mail/Transport/Smtp.php(199): Zend_Mail_Protocol_Smtp->connect()
#2 /homepages/46/d339149978/htdocs/library/Zend/Mail/Transport/Abstract.php(348): Zend_Mail_Transport_Smtp->_sendMail()
#3 /homepages/46/d339149978/htdocs/library/Zend/Mail.php(1178): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#4 /homepages/46/d339149978/htdocs/application/controllers/ContactController.php(97): Zend_Mail->send()
#5 /homepages/46/d339149978/htdocs/application/controllers/ContactController.php(74): ContactController->sendContactMail(Array)
#6 /homepages/46/d339149978/htdocs/library/Zend/Controller/Action.php(513): ContactController->sendAction()
#7 /homepages/46/d339149978/htdocs/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('sendAction')
#8 /homepages/46/d339149978/htdocs/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 /homepages/46/d339149978/htdocs/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 /homepages/46/d339149978/htdocs/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 /homepages/46/d339149978/htdocs/public/index.php(27): Zend_Application->run()
#12 {main}
星期天我发送一封电子邮件给1and1,询问是否有通过SMTP发送电子邮件的问题。今天我收到一个答案,说一切正常,我必须检查我的脚本......
答案 0 :(得分:4)
我花了好几个小时尝试让1and1服务器接受SMTP邮件。它适用于远程测试服务器(使用以下内容:
$mailhost = 'auth.smtp.1and1.co.uk';
$mailconfig = array('auth' => 'login',
'username' => 'myaddress@example.com',
'password' => 'myPassword');
$transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig);
Zend_Mail::setDefaultTransport($transport);
当我在1and1上部署它时,我得到“拒绝连接”。其他论坛认为这是因为1and1不允许在自己的服务器上使用SMTP,因此您必须使用Sendmail()。 然后上面的脚本变成: -
$transport = new Zend_Mail_Transport_Sendmail('-freturn_to_myaddress@example.com');
Zend_Mail::setDefaultTransport($transport);
(注意,我已将回程地址放入)
这适用于1and1服务器。
克里斯
答案 1 :(得分:1)
它可能不是“解决方案”,但它可以帮助您确保手动设置不会产生错误。
resources.mail.transport.type = "smtp"
resources.mail.transport.host = "smtp.gmail.com"
resources.mail.transport.auth = "login"
resources.mail.transport.ssl = "tls"
resources.mail.transport.username = "yourlogin" ; without the @ part
resources.mail.transport.password = "yourpasswd"
resources.mail.transport.register = true
替换yourlogin
& yourpasswd
由您提供,它应该有效。
最后一个选项register
注册您先前设置的默认传输。
如您的评论中所述,如果它在本地运作,则这是一个检查清单:
APPLICATION_ENV
未覆盖您的设置(production
& development
)OpenSSL
(需要通过安全连接连接到Gmail)答案 2 :(得分:0)
我一遍又一遍地反复出现同样的错误“消息:连接被拒绝”,无论我尝试使用什么smtp
“拒绝连接”表示远程服务器拒绝连接,或者本地计算机具有阻止创建连接的防火墙或安全策略。
如果您收到该错误,无论您连接的是哪个SMTP服务器,那么您的托管服务提供商都会阻止该连接。您需要与他们联系询问问题。
请注意,1& 1已成为超过十年的糟糕的托管服务提供商,应该避免使用。即使Dreamhost是最便宜的提供商之一,也能提供更好的服务。