Skip to content

Commit

Permalink
Fixed issue #1254: Sending email to group in admin screens failing. (…
Browse files Browse the repository at this point in the history
…fabianc2k)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/stable_plus@3456 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 22, 2007
1 parent a9873f9 commit a260dfc
Showing 1 changed file with 49 additions and 33 deletions.
82 changes: 49 additions & 33 deletions common.php
Expand Up @@ -2520,46 +2520,62 @@ function ReplaceFields ($text,$fieldsarray)

function MailTextMessage($body, $subject, $to, $from, $sitename, $ishtml=false)
{
global $emailmethod, $emailsmtphost, $emailsmtpuser, $emailsmtppassword;


$mail = new PHPMailer;
$mail->CharSet = "UTF-8";

$fromname='';
$fromemail=$from;
if (strpos($from,'<'))
{
$fromemail=substr($from,strpos($from,'<')+1,strpos($from,'>')-1-strpos($from,'<'));
$fromname=trim(substr($from,0, strpos($from,'<')-1));
}
$mail->Mailer = $emailmethod;
if ($emailmethod=="smtp")
{ $mail->Host = $emailsmtphost;
$mail->Username =$emailsmtpuser;
$mail->Password =$emailsmtppassword;
if ($emailsmtpuser!="")
{$mail->SMTPAuth = true;}
}
$mail->From = $fromemail;
$mail->AddAddress($to);
$mail->FromName = $fromname;
$mail->AddCustomHeader("X-Surveymailer: $sitename:Emailer (LimeSurvey.sourceforge.net)");
if (get_magic_quotes_gpc() != "0") {$body = stripcslashes($body);}
$textbody = strip_tags($body);
$textbody = str_replace("&quot;", '"', $textbody);
// This function mails a text $body to the recipient $to. YOu can use more than one
// recipient when using a comma separated string with recipients.

global $emailmethod, $emailsmtphost, $emailsmtpuser, $emailsmtppassword;


$mail = new PHPMailer;
$mail->CharSet = "UTF-8";

$fromname='';
$fromemail=$from;
if (strpos($from,'<'))
{
$fromemail=substr($from,strpos($from,'<')+1,strpos($from,'>')-1-strpos($from,'<'));
$fromname=trim(substr($from,0, strpos($from,'<')-1));
}
$mail->Mailer = $emailmethod;
if ($emailmethod=="smtp")
{ $mail->Host = $emailsmtphost;
$mail->Username =$emailsmtpuser;
$mail->Password =$emailsmtppassword;
if ($emailsmtpuser!="")
{$mail->SMTPAuth = true;}
}
$mail->From = $fromemail;
$toemails = explode(",", $to);
foreach ($toemails as $singletoemail)
{
if (strpos($singletoemail, '<') )
{
$toemail=substr($singletoemail,strpos($singletoemail,'<')+1,strpos($singletoemail,'>')-1-strpos($singletoemail,'<'));
$toname=trim(substr($singletoemail,0, strpos($singletoemail,'<')-1));
$mail->AddAddress($toemail,$toname);
}
else
{
$mail->AddAddress($singletoemail);
}
}
$mail->FromName = $fromname;
$mail->AddCustomHeader("X-Surveymailer: $sitename:Emailer (LimeSurvey.sourceforge.net)");
if (get_magic_quotes_gpc() != "0") {$body = stripcslashes($body);}
$textbody = strip_tags($body);
$textbody = str_replace("&quot;", '"', $textbody);
if ($ishtml) {
$mail->IsHTML(true);
$mail->Body = $body;
$mail->AltBody = $textbody;
$mail->Body = $body;
$mail->AltBody = $textbody;
} else
{
$mail->IsHTML(false);
$mail->Body = $textbody;
$mail->Body = $textbody;
}

$mail->Subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
return $mail->Send();
$mail->Subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
return $mail->Send();
}

// This functions removes all tags, CRs, linefeeds and other strange chars from a given text
Expand Down

0 comments on commit a260dfc

Please sign in to comment.