2006-07-28 16:09:10 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2006-07-28 16:09:10 +00:00
require_once ( " ../project/project.inc " );
require_once ( " ../inc/email.inc " );
function replace ( $toname , $comment , $fromname , $template ) {
$pat = array (
'/<toname\/>/' ,
'/<comment\/>/' ,
'/<fromname\/>/' ,
);
$rep = array (
$toname ,
$comment ,
$fromname ,
);
return preg_replace ( $pat , $rep , $template );
}
$html = file_get_contents ( '../ops/ffmail/html' );
$text = file_get_contents ( '../ops/ffmail/text' );
$subject = file_get_contents ( '../ops/ffmail/subject' );
$preview = get_str ( 'preview' , true );
$uname = get_str ( 'uname' );
$uemail = get_str ( 'uemail' );
2006-07-28 19:02:48 +00:00
$comment = get_str ( 'comment' , true );
2006-07-28 16:09:10 +00:00
$action = get_str ( 'action' );
if ( $action == 'Preview' ) {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " Email preview " ));
echo tra ( " Your email will appear as follows: " ) . "
2006-07-28 16:09:10 +00:00
< hr >
" ;
echo replace ( " [Friend's name] " , $comment , $uname , $html );
$args = strstr ( $_SERVER [ 'REQUEST_URI' ], '?' );
$args = str_replace ( 'action=Preview' , 'action=Send' , $args );
echo "
< hr >
2011-08-25 22:12:48 +00:00
< b >< a href = ffmail_action . php $args > " .tra( " Send email " ). " </ a ></ b >
2006-07-28 16:09:10 +00:00
< p >
2011-08-25 22:12:48 +00:00
[ " .tra( " Use your browser ' s back button to return to message form " ). " ]
2006-07-28 16:09:10 +00:00
" ;
page_tail ();
} else {
2011-08-25 22:12:48 +00:00
page_head ( tra ( " Sending emails " ));
2006-07-28 19:02:48 +00:00
$found = false ;
2006-07-28 16:09:10 +00:00
for ( $i = 0 ; $i < 5 ; $i ++ ) {
$n = get_str ( " n $i " , true );
$e = get_str ( " e $i " , true );
if ( $n && $e ) {
2006-07-28 19:02:48 +00:00
$found = true ;
2006-07-28 16:09:10 +00:00
$mail = new PHPMailer ();
$mail -> AddAddress ( $e , $n );
$mail -> Subject = $subject ;
if ( $html ) {
$mail -> Body = replace ( $n , $comment , $uname , $html );
$mail -> AltBody = replace ( $n , $comment , $uname , $text );
} else {
$mail -> Body = replace ( $n , $comment , $uname , $text );
}
$mail -> From = $uemail ;
$mail -> FromName = $uname ;
$mail -> Host = $PHPMAILER_HOST ;
$mail -> Mailer = $PHPMAILER_MAILER ;
2006-07-28 19:02:48 +00:00
if ( $mail -> Send ()) {
2011-08-25 22:12:48 +00:00
echo " <br> " . tra ( " email sent successfully to %1 " , $e ) . " \n " ;
2006-07-28 19:02:48 +00:00
} else {
2011-08-25 22:12:48 +00:00
echo " <br> " . tra ( " failed to send email to %1: %2 " , $e , $mail -> ErrorInfo ) . " \n " ;
2006-07-28 19:02:48 +00:00
}
2006-07-28 16:09:10 +00:00
}
}
2006-07-28 19:02:48 +00:00
if ( $found ) {
echo "
2011-08-25 22:12:48 +00:00
< p > " .tra( " Thanks for telling your friends about % 1 " , PROJECT);
2006-07-28 19:02:48 +00:00
} else {
2011-08-25 22:12:48 +00:00
echo tra ( " You forgot to enter your friends' names and/or email addresses; Please %1return to the form%2 and enter them. " , " <a href=ffmail_form.php> " , " </a> " );
2006-07-28 19:02:48 +00:00
}
page_tail ();
2006-07-28 16:09:10 +00:00
}
exit ();
?>