Views Send - mailing logs

Views Send is a great module for mass sending of mails/messages, kind of like newsletter but you can use whole power of views and VBO module, which gives you great flexibility.
There is one thing missing though, evidence of what is sent and to whome, kind of a like some sent items folder in email. So I created this hack to make it work, hope one day this gets better solved and a standard part of module.

this is a node create function that creates data for what is sent and to who


function views_send_evidence($from_name, $from_mail, $to_mail, $subject, $body){
$node = new stdClass(); 
//Main Node Fields
$node->name = $subject;
$node->title = $node->name;
$node->body = '

Poslao:'.$from_name.' '.$from_mail.'

'.$body; $node->type = 'mm_evid'; //This can be any node type $node->created = time(); $node->changed = $node->created; $node->promote = 0; // Display on front page ? 1 : 0 $node->sticky = 0; // Display top of page ? 1 : 0 $node->format = 2; // 1:Filtered HTML, 2: Full HTML $node->status = 1; // Published ? 1 : 0 $node->language = 'hr'; $node->field_mailovi[0]['value'] = $to_mail; if ($node = node_submit($node)) { node_save($node); drupal_set_message(t("Node ".$node->title." added correctly")); } else { drupal_set_message(t("Node ".$node->title." added incorrectly"), "error"); } }

and this is called inside views_send_mail_action_submit as this is where data is still not saved to spool table and where you can get them cleary separated like in a form. Think this code should be called a bit later if possible as you can still click cancell at this point but this data would be saved. Anyway this is how it is for now.


function views_send_mail_action_submit($form, &$form_state) {
//  print_r($form_state);
 // dpm($form_state);  
  
  $display = $form['display']['#value'];
  $values =& $form_state['values'];
  //custom evidence for mass mailings
  $from_name=$form_state['values']['views_send_from_name'];
  $from_mail=$form_state['values']['views_send_from_mail'];
  $to_mail=$form_state['storage']['selection']; 
  $subject=$form_state['values']['views_send_subject']; 
  $body=$form_state['values']['views_send_message'];      
  
  foreach ($to_mail as &$value) {
    $to_list .= $value->realname_realname.' '.$value->users_mail.'
'; } views_send_evidence($from_name, $from_mail, $to_list, $subject, $body); //my function call $return = array(); ...