Changes
Title
unchanged
Simple Mail Queue
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
mail, queue, mail queue, cron, cronjobs, message queue
Content
changed
[...]
--
-- Structure for table `tbl_email_queue`
--
DROP TABLE IF EXISTS `tbl_email_queue`;
CREATE TABLE IF NOT EXISTS `tbl_email_queue` (
`id` int(11)0) unsigned NOT NULL AUTO_INCREMENT,
`from_name` varchar(64) DEFAULT NULL,
`from_email` varchar(128) NOT NULL,[...]
`subject` varchar(255) NOT NULL,
`message` text NOT NULL,
`max_attempts` int(11)tinyint(3) unsigned NOT NULL DEFAULT '3',
`attempts`
int(11)tinyint(3) unsigned NOT NULL DEFAULT '0',
`success` tinyint(1) NOT NULL DEFAULT '0',
`date_published` datetime DEFAULT NULL,[...]
PRIMARY KEY (`id`),
KEY `to_email` (`to_email`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=
latin1utf8_general_ci;
~~~[...]
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('from_email, to_email, subject, message', 'required'),
array('max_attempts, attempts, success', 'numerical', 'integerOnly' => true),[...]
array('subject', 'length', 'max' => 255),
array('date_published, last_attempt, date_sent', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, from_name, from_email, to_email, subject, message, max_attempts, attempts, success, date_published, last_attempt, date_sent', 'safe', 'on' => 'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
);
}
/**
* @return array customized attribute labels (name=>label)
*/[...]
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('from_name', $this->from_name, true);
$criteria->compare('from_email', $this->from_email, true);
$criteria->compare('to_email', $this->to_email, true);
$criteria->compare('subject', $this->subject, true);
$criteria->compare('message', $this->message, true);
$criteria->compare('max_attempts', $this->max_attempts);
$criteria->compare('attempts', $this->attempts);
$criteria->compare('success', $this->success);
$criteria->compare('date_published', $this->date_published, true);
$criteria->compare('last_attempt', $this->last_attempt, true);
$criteria->compare('date_sent', $this->date_sent, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
}
?>
```
Console Command
------------------[...]