我想用Symfony SwiftMail和Gandi(roundcube)地址发送一封电子邮件。问题是什么都没发生,我不知道为什么。^^
配置yml
swiftmailer:
transport: mail
encryption: ssl
auth_mode: login
host: smtp
username: 'my email'
password: 'my mdp'
parameters.yml
parameters:
mailer_transport: smtp
mailer_host: 127.0.0.1:160
mailer_user: null
mailer_password: null
控制器:
public function contactAction()
{
$mail = "mymail";
$enquiry = new Contact();
$form = $this->createForm(new EnquiryType(), $enquiry);
$request = $this->getRequest();
if ($request->getMethod() == 'POST')
{
$form->bind($request);
$data = $form->getData();
$message = 'Swift_Message::newInstance()
->setContentType('text/html')
->setSubject($data->getSubject())
->setFrom($data->getAdresse())
->setTo($mail)
->setBody($data->getMessage());
$this->get('mailer')->send($message);
return $this->redirect($this->generateUrl('st_contact_homepage'));
}
return $this->render('STCommonBundle:Default:contact.html.twig', array('form' => $form->createView()));
}
你能帮我吗?
谢谢。^^
您的配置似乎是错误的
"host"属性必须是smpt主机名
类似的东西
smpt.yahoo.com
你需要找出
并且传输是smpt
所以很像:
swiftmailer:
transport: smtp
encryption: ssl
auth_mode: login
host: smtp.yahoo.com
username: 'my email'
password: 'my mdp'