/** * Adds a new mail notification into the system or send an email immediately. * * Example: * <code> * <?php * $mailer = FD::getInstance( 'Mailer' ); * $data = new SocialMailerData(); * $data->set( 'title' , 'Some title' ); * $data->set( 'template' , 'email.template.file' ); * $data->set( 'recipient_name' , 'Recipient' ); * $data->set( 'recipient_email', '*****@*****.**' ); * $data->set( 'html' , true ); * * // Returns a bool value. True if success. * $state = $mailer->create( $data ); * ?> * </code> * * @since 1.0 * @access public * @param SocialMailerData The required mailer data object. * * @return boolean True on success, false otherwise */ public function create(SocialMailerData $mailData) { // Convert the mail data to an array. $data = $mailData->toArray(); $mailer = FD::table('Mailer'); $mailer->bind($data); // If mail object is configured to send immediately, we shouldn't store it. if ($mailer->priority == SOCIAL_MAILER_PRIORITY_IMMEDIATE) { // If environment is development, then we store this for checking purposes if (FD::config()->get('general.environment') === 'development') { $mailer->store(); } // Send the mail immediately. $state = $this->send(array($mailer)); return $state; } return $mailer->store(); }