Hi all.. I think it's a strange behavior: if I send email inside an action it will be sent. If I try to send it inside the save function in a form class, the email doesn't arrive (I've seen in the sendmail queue and it is empty). To explain what i'm trying to do: i want to send an email everytime a post is created or edited, so the better thing to do it is to send through the save function of the Post Form class.

This is the not working code (but it gives no errors, everything seem fine):
<!-- /lib/form/doctrine/PostForm.class.php -->
public function doSave($con = null) {
    parent::doSave($con);
        $post=$this->getObject();
        $mail = sfContext::getInstance()->getMailer()->compose();
        $mail->setFrom("i...@teapartyitalia.it", 'Tea Party Italia');
              $to = array(
                          'myaddr...@yahoo.com',
                          'myaddr...@gmail.com',
                        );
        $mail->setTo($to);
        $mail->setSubject("prova");
        $mail->setBody("Mail inviata da form");
        // send the email
        sfContext::getInstance();
}

This my working function (it sends the email) in the actions.class.php:
public function executeTestMail(sfWebRequest $request){
                 $mail = $this->getMailer()->compose();
                  // definition of the required parameters
                  $mail->setFrom("i...@teapartyitalia.it", 'Tea Party Italia');
              $to = array(
                          'myaddr...@yahoo.com',
                          'myaddr...@gmail.com',
                        );
                  $mail->setTo($to);
                  $mail->setSubject("prova");
                  $mail->setBody("Mail inviata da testMail");
                  // send the email
                  $this->getMailer()->send($mail);
        $this->redirect('/');
  }

They are quite the same.. why the hell the first doesn't work?
I'm going mad, thank you in advance,
Cosimo

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to