I'm new on Symfony.. I would send an email with swift mailer but i don't understand if this service is enabled from FOSUserbundle or not..
I write this code in Controller:
$this->get('mailer')->send($message);
$mailer = Swift_Mailer::newInstance();
$message = Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('----@---.com')
->setTo('----@---.com')
->setBody('You should see me from the profiler!')
;
// Pass a variable name to the send() method
if (!$mailer->send($message, $failures))
{
var_dump($failures);
}
IN config.yml i have this for FOSUserBundle
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
# Routing
be_simple_i18n_routing: ~
# FOSUserBundle Configuration
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Dt\EcBundle\Entity\User
profile:
form:
type: dt_ec_profile
registration:
confirmation:
enabled: true
form:
type: dt_ec_registration
from_email:
address: -----@----.com
sender_name: consulent
service:
mailer: fos_user.mailer.twig_swift
resetting:
email:
template: DtEcBundle:User:resetting.email.html.twig
How can i do for send and email? Thanks
Edit with parameters.yml
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: -----
database_port: null
database_name: ------
database_user: root
database_password: -------
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: it
secret: ThisTokenIsNotSoSecretChangeIt
domain: -----
opentok_key: ----
opentok_secret: -----