$testEmailParams = _civicrm_api3_generic_replace_base_params($params);
$testEmailParams['is_test'] = 1;
+ $testEmailParams['status'] = 'Scheduled';
+ $testEmailParams['scheduled_date'] = CRM_Utils_Date::processDate(date('Y-m-d'), date('H:i:s'));
$job = civicrm_api3('MailingJob', 'create', $testEmailParams);
$testEmailParams['job_id'] = $job['id'];
- $testEmailParams['emails'] = explode(',', $testEmailParams['test_email']);
+ $testEmailParams['emails'] = array_key_exists('test_email', $testEmailParams) ? explode(',', $testEmailParams['test_email']) : NULL;
if (!empty($params['test_email'])) {
$query = CRM_Utils_SQL_Select::from('civicrm_email e')
->select(array('e.id', 'e.contact_id', 'e.email'))