Codigo para configurar variables generales y enviar mails
Versión 1 (Guillermo Zdanowicz, 04/09/2011 12:31)
| 1 | 1 | Guillermo Zdanowicz | h1. Codigo para configurar variables generales y enviar mails |
|---|---|---|---|
| 2 | 1 | Guillermo Zdanowicz | |
| 3 | 1 | Guillermo Zdanowicz | en el app del la aplicacion /app/miaplicacion/config/app.yml |
| 4 | 1 | Guillermo Zdanowicz | |
| 5 | 1 | Guillermo Zdanowicz | all: |
| 6 | 1 | Guillermo Zdanowicz | envio_mail: |
| 7 | 1 | Guillermo Zdanowicz | contacto: contacto@guiaextremadura.es |
| 8 | 1 | Guillermo Zdanowicz | |
| 9 | 1 | Guillermo Zdanowicz | En el action del modulo que se envia mail |
| 10 | 1 | Guillermo Zdanowicz | |
| 11 | 1 | Guillermo Zdanowicz | protected function processForm(sfWebRequest $request, sfForm $form) |
| 12 | 1 | Guillermo Zdanowicz | { |
| 13 | 1 | Guillermo Zdanowicz | $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); |
| 14 | 1 | Guillermo Zdanowicz | if ($form->isValid()) |
| 15 | 1 | Guillermo Zdanowicz | { |
| 16 | 1 | Guillermo Zdanowicz | $contacto = $form->save(); |
| 17 | 1 | Guillermo Zdanowicz | |
| 18 | 1 | Guillermo Zdanowicz | |
| 19 | 1 | Guillermo Zdanowicz | |
| 20 | 1 | Guillermo Zdanowicz | $email_usuario=$contacto->getEmail(); |
| 21 | 1 | Guillermo Zdanowicz | $subject = "Formulario de Contacto: "; |
| 22 | 1 | Guillermo Zdanowicz | |
| 23 | 1 | Guillermo Zdanowicz | $message = $this->getMailer()->compose(); |
| 24 | 1 | Guillermo Zdanowicz | $message->setSubject($subject); |
| 25 | 1 | Guillermo Zdanowicz | $message->setTo($email_usuario); |
| 26 | 1 | Guillermo Zdanowicz | $message->setFrom(sfConfig::get('app_envio_mail_contacto')); |
| 27 | 1 | Guillermo Zdanowicz | $arrImages = array(); |
| 28 | 1 | Guillermo Zdanowicz | $arrImages['logo'] = $message->embed(Swift_Image::fromPath(sfConfig::get('sf_web_dir').'/images/mail/logo_cabecera.jpg')); |
| 29 | 1 | Guillermo Zdanowicz | $arrImages['linea'] = $message->embed(Swift_Image::fromPath(sfConfig::get('sf_web_dir').'/images/mail/linea.jpg')); |
| 30 | 1 | Guillermo Zdanowicz | $arrImages['logo_firma'] = $message->embed(Swift_Image::fromPath(sfConfig::get('sf_web_dir').'/images/mail/logo_firma.jpg')); |
| 31 | 1 | Guillermo Zdanowicz | $mensajeCuerpo = $this->getPartial('formMailContacto', array('form' => $this->form, 'arrImages' => $arrImages)); //, array('form' => $this->form,'arrImages' => $arrImages) |
| 32 | 1 | Guillermo Zdanowicz | $message->setBody($mensajeCuerpo, 'text/html'); |
| 33 | 1 | Guillermo Zdanowicz | $this->getMailer()->send($message); |
| 34 | 1 | Guillermo Zdanowicz | |
| 35 | 1 | Guillermo Zdanowicz | $this->redirect('formContacto/thankyou?'.http_build_query($this->form->getValues())); |
| 36 | 1 | Guillermo Zdanowicz | } |
| 37 | 1 | Guillermo Zdanowicz | } |