我正在尝试在Symfony应用程序中发送确认电子邮件(订购后)。我的功能如下:
$message_client = \Swift_Message::newInstance()
->setSubject('Bestelling bevestiging - Buvens')
->setFrom('website@buvens.be')
->setTo($order->getEmail())
->setBody(
$this->renderView(
'emails/order_client.html.twig',
array('order' => $order, 'order_products' => $order_products)
),
'text/html'
)
;
try{
$this->get('mailer')->send($message_client);
}
catch(\Exception $ex){
var_dump($ex->getMessage()); die;
}
在我的parameters.yml中,我有:
# This file is auto-generated during the composer install
parameters:
database_host: localhost
database_port: null
database_name: db_live
database_user: db_live
database_password: ************
mailer_transport: mail
mailer_host: mail.myserver.be
mailer_port: 25
mailer_user: website@myserver.be
mailer_password: *************
mailer_auth_mode: login
secret: ************
问题在于,电子邮件中的发件人类似于:
Van:client@s04.mycompany Namens website@myserver.be
并且该邮件是在垃圾邮件文件夹中接收的。