#!/usr/bin/perl
use strict;
use warnings;

use Digest::MD5 qw(md5 md5_hex md5_base64);
use MIME::Parser;
use MIME::Entity;
use MIME::Body;
use Getopt::Long;

use lib qw(../Core);
use lib qw(../Classes);

use Configuration;
use LocalConfiguration;

use Submission;
use Logger;

my $SCRIPTNAME = 'sendemailsfromlist.pl';

my $logger = new Logger();


my $email_from = "kfidelis\@ucdavis.edu";
my $email_replay_to = $email_from; 
my $email_cc = "casp\@predictioncenter.org";
my $email_subject = "Availability of protein structures obtained by modeling";

my $email_body_template = "
Dear Dr. %s,

I am writing to inquire about the use of protein structure models in your research. We are presently considering putting together a collaborative effort to substantially facilitate access to models of protein structure, models obtained primarily through comparative modeling. This would increase the number of available models over those obtained through experiment (PDB) by approximately 10-100 fold. We envision putting special emphasis on evaluating and annotating these models in terms of quality and suitability for specific applications. Requests to modelers regarding specific protein targets would also be accepted.  The initiative aims primarily at the plant biology community.

At this time I am asking only if you are interested in participating in such collaboration at any level, from using models to helping organize this effort. Please, let me know if you or a senior member of your research group would be willing to participate in a workshop on these issues (place and date will be announced later), organized through the iPlant collaborative. If you are interested please let me know via reply e-mail (at this stage brief answers are fully acceptable). 

Krzysztof Fidelis
Protein Structure Prediction Center, UC Davis
kfidelis\@ucdavis.edu

";


my $count = 0;
my $filename ="emails_list";


	
if(open(FILE, $filename)) {


	
	while(<FILE>) {
		my $line = $_;
	
		my $email_to  = "";	
		my $full_name = "";
		
		if($line =~ /(\S+)\s(.*)/) { 
			$email_to = $1;
			$full_name = $2;
			# Email -> send_email ([email from], [email to], [email replay to], [email CC], [subject], [email_body])
			Email::send_email($email_from, $email_to, $email_replay_to, $email_cc, $email_subject, sprintf($email_body_template, $full_name));	
		}
			
		$count++;
		print sprintf("# %d email sent to <%s> %s \n", $count, $full_name, $email_to);
		
		

	}	


close(FILE);


}




