Reputation: 868
I created a contact form in Symfony2. I would like to send it via email and also i want to save the content in the database via Symfony2, for this i created a form. The saving into the database works fine but I never get an email on the production server.
public function createAction(Request $request) {
$entity = new Contact();
$form = $this -> createCreateForm($entity);
$form -> handleRequest($request);
$message = \Swift_Message::newInstance() -> setSubject('Hello Email') -> setFrom('[email protected]') -> setTo('[email protected]') -> setBody($this -> renderView('DbeDonaciBundle:Contact:email.html.twig', array('entity' => $entity)));
$this -> get('mailer') -> send($message);
$em = $this -> getDoctrine() -> getManager();
$em -> persist($entity);
$em -> flush();
$this -> get('session') -> getFlashBag() -> add('messageSent', 'Die Nachricht wurde erfolgreich abgeschickt. Wir werden uns sobald als möglich bei dir melden!');
return $this -> render('DbeDonaciBundle:Aboutus:index.html.twig', array('entity' => $entity, 'form' => $form -> createView(), ));
}
Locally this seems to work, if I access the message block in the developer toolbar I have an email ready:
Mailer default (default mailer)
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8
MIME-Version: 1.0
Date: Tue, 04 Mar 2014 10:54:07 +0100
Message-ID: <725cbd36eaafdc75ede3eeb016a60b1d@localhost>
From: [email protected]
Subject: Hello Email
To: [email protected]
A contact enquiry was made by asdf at 2014-03-04 10:54.
Reply-To: [email protected]
Subject: asdf
Body:
Name: asdf
E-Mail: [email protected]
Message: asdf
Website: asdf
Also there is no e-mail in the spool if I execute:
php app/console swiftmailer:spool:send
Here is the adjusted configfile with mailjet:
mailer_transport: smtp
mailer_host: in.mailjet.com
mailer_user: 3d32164c00c29asdflkjabf2d1e45b
mailer_password: 342f84sdaj7a3d374eb85523dfad246
locale: en
secret: 34af84cbbb7a3d12li552cfgad246
Any ideas? Thanks in advance for your help guys!
Upvotes: 0
Views: 797
Reputation: 1783
it should be relative to smtp server : if symfony debug shows you the mail, it's definetly this.
Try using a dedicated smtp service such as mailjet ( www.mailjet.com ) to handle your emails sending .
Upvotes: 1