Bump – this feature is important! We are still struggling with feeding the false positive spam messages back into our contact system. Responses from the dev that say that Flamingo doesn’t handle the spam filters are not helpful, as Flamingo is the plugin where we have to deal with the filtered messages – not CF7.
A workaround to re-send messages marked as ‘not spam’ to the admin emails, until the plugin can be updated – modify the includes\class-inbound-message.php file – replace the function unspam with the following:
public function unspam() {
if ( ! $this->spam ) {
return;
}
$this->akismet_submit_ham();
$this->spam = false;
// new code inserted here ----------------
$message = "This message was marked as 'Not Spam'";
// build message from the $this object e.g.
$message .= "<br /><strong>From:</strong> ".$this->from_name;
$message .= "<br /><strong>Email:</strong> ".$this->from_email;
$message .= "<br /><strong>Subject:</strong> ".$this->subject;
$message .= "<br /><strong>Message Body:</strong> ".$this->fields['your-message'];
// add the meta data to the message if you want
$skipfields = array('site_url','url','post_id','post_name','post_url','post_title','post_author','post_author_email','site_title','site_description');
foreach($this->meta as $k=>$v){
if(!in_array($k,$skipfields)){$message .="<strong>".$k.":</strong> ".$v."<br />";}
}
// where to send the 're-sent' message
$to = $this->meta['site_admin_email'];
//alternatively, send to current user
//$current_user = wp_get_current_user();
//$to = $current_user->user_email;
// edit the subject of the re-sent message
$subject = 'General Subject Here '.$this->meta['serial_number'].' '.$this->subject.'"';
// edit the headers
$headers = array('Reply-To: '.$this->from_name.' <'.$this->from_email.'>');
// send the message
wp_mail($to,$subject,$message,$headers);
// end new code --------------------------------------
return $this->save();
}
Could be improved to get the original mail recipients and mail template from CF7 but this is a fast a dirty way of getting the message re-sent.
Thread Starter
KZeni
(@kzeni)
@nikkofir It does make sense to have the email be sent when marking as not spam since the email notifications didn’t get sent the first time around. However, it would be more fitting if this code snippet actually pulled the email notification data for the corresponding form so the correct email recipient(s), subject, body message, etc. are all used (instead of hard-coding the body content, recipient[s], subject, etc. as your code has implemented [which is definitely fast & dirty, as you said.])
This could then potentially have a checkbox to enable/disable re-sending of the email message when marking items as not spam. Then again, I might just opt to have this presented as buttons (and potentially in the bulk actions dropdown) to trigger these to be sent on-demand as I proposed in my first message above as the ideal way to provide this.
@kzeni yes, would be much better to get the original mail recipients and mail template via the CF7 plugin. I went for fast and dirty, rather than messing around for ages trying to get Flamingo to talk to CF7 – probably not that hard but had to get a quick solution up for a client today…
Hopefully the plugin dev has a more elegant solution lined up for us, or I may revisit this if I have to do it on other sites.