8 Allows scripts to send emails to the development team.
14 package CXGN
::Contact
;
19 use CXGN
::Apache
::Request
;
20 use CXGN
::Tools
::Text
;
27 Desc : Sends an email to the development team.
30 - email address or conf key name that should contain an email
32 - replyto address to include in the email
33 Ret : nothing meaningful
34 Side Effects: dies on error
37 CXGN::Contact::send_email($subject,$body,$mailto);#goes to wherever you say it should go
38 CXGN::Contact::send_email($subject,$body,'email');#goes to email found in conf object
39 CXGN::Contact::send_email($subject,$body,'bugs_email');#goes to bugs_email found in conf object
40 CXGN::Contact::send_email($subject,$body);#goes to this script's default of bugs_email
41 CXGN::Contact::send_email($subject,$body,$mailto,$replyto);#sends an email with a reply-to different from the sender (the sender is the apache user from the conf object, usually www-data)
46 my ( $subject, $body, $mailto, $replyto ) = @_;
47 my $request_info = "";
48 my $vhost_conf = SGN
::Context
->new;
49 my $hostname = `hostname`;
51 #my $dnsdomainname = `dnsdomainname`;
52 #chomp($dnsdomainname);
53 my $mailfrom = $vhost_conf->get_conf('www_user') . '@' . $hostname;
55 #if we are specifying a mailto as a vhost configuration variable (such as 'bugs_email'), then use that variable's value, and append the request info.
56 #mailto can also be specified normally (such as 'John Binns <zombieite@gmail.com>').
57 if ( $mailto and eval{ $vhost_conf->get_conf($mailto)} ) {
58 $mailto = $vhost_conf->get_conf($mailto);
59 ##$request_info .= CXGN::Apache::Request::as_verbose_string();
62 #if we have no one specified to mail to, send it to bugs, and append the request info.
64 $mailto = $vhost_conf->get_conf('bugs_email')
65 ; #for all emails that do not specify email address, send them to our bugs_email
66 ##$request_info .= CXGN::Apache::Request::as_verbose_string()
67 ; #append request info to all emails that do not specify email address
70 $subject ||= 'No subject specified';
71 $body ||= 'No message body specified';
72 $mailto ||= 'sgn-bugs@sgn.cornell.edu';
74 $body .= $request_info;
75 print STDERR
"$subject\n\n$body";
76 if ( $vhost_conf->get_conf('production_server') ) {
77 if ( $vhost_conf->get_conf('disable_emails') ) {
79 "CXGN::Contact: Configured as production server, but not configured to send emails; no email sent from $mailfrom to $mailto.\n";
88 $mail{'Reply-To'} = $replyto;
89 if ( sendmail
(%mail) ) {
91 "CXGN::Contact: Email notification sent from $mailfrom to $mailto.\n";
94 print STDERR
"CXGN::Contact: UNABLE TO SEND EMAIL NOTIFICATION\n";
100 "CXGN::Contact: Not configured as production server; no email sent from $mailfrom to $mailto.\n";
107 john binns - John Binns <zombieite@gmail.com>