0
我有我的网站正在制作中,有Hostinger,并且参数和配置相同,我不能在生产中发送电子邮件,但是我可以在开发模式下。我改变了参数和配置文件与其他问题中看到的其他设置,但没有成功。无论如何,我得到的错误是:在Symfony2的项目中使用Swiftmailer时出错
连接无法与主机smtp.gmail.com 建立[连接超时#110] 500内部服务器错误 - Swift_TransportException
我parameters.yml文件:
parameters:
...
mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: [email protected]
mailer_password: xxxx
...
我config.yml文件:
# Swiftmailer Configuration
swiftmailer:
transport: gmail
host: smtp.gmail.com
username: [email protected]
password: xxxx
我的控制文件:
public function kontaktuaAction()
{
$kontaktua = new Kontaktua();
$form = $this->createForm(new KontaktuaType(), $kontaktua);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
$message = \Swift_Message::newInstance()
->setSubject($kontaktua->getGaia())
->setTo('[email protected]')
->setFrom($kontaktua->getEmaila())
->setBody($kontaktua->getIzena().'(e)k, email helbidea '.$kontaktua->getEmaila().' duena hurrengo mezu hau'.
' bidali dizu: '.$kontaktua->getMezua());
$this->get('mailer')->send($message);
return $this->redirect($this->generateUrl('kontaktua'));
}
}
return $this->render('TaldeaBundle:Default:kontaktua.html.twig', array(
'form' => $form->createView()
));
}
我都试过,但没有结果。它在生产环境中工作吗? – xaaleja 2014-10-05 13:26:09