diff --git a/info.textgrid.middleware.tgauth.tgaccount/edit_request.php b/info.textgrid.middleware.tgauth.tgaccount/edit_request.php index b78c5a6e7b403d7106ecac98ce85eb5d8ffc2236..8773f8c55ddebf196f5da7f8ccabc1975d9baf10 100644 --- a/info.textgrid.middleware.tgauth.tgaccount/edit_request.php +++ b/info.textgrid.middleware.tgauth.tgaccount/edit_request.php @@ -5,7 +5,7 @@ include 'webinit.inc.php'; if($_POST['mail']){ $mail = $_POST['mail']; - $imap->mail($mail['reciever'], $mail['subject'], $mail['body'], true); + $imap->mail($mail['reciever'], $mail['subject'], $mail['body']); $status='Mail an '.$mail['reciever'].' wurde versendet'; } diff --git a/info.textgrid.middleware.tgauth.tgaccount/include/tgImap.class.php b/info.textgrid.middleware.tgauth.tgaccount/include/tgImap.class.php index 87d249c16a268e4e7508d62e6ef4fe4454eaed86..a89b09524710ab0ddedb1a9588afb2f5ef253200 100644 --- a/info.textgrid.middleware.tgauth.tgaccount/include/tgImap.class.php +++ b/info.textgrid.middleware.tgauth.tgaccount/include/tgImap.class.php @@ -4,69 +4,77 @@ require_once('Mail.php'); require_once('Mail/mime.php'); class tgImap { + var $conf; + var $sender; + var $bcc; + var $reply; - var $conf; - var $sender; - var $cc; - var $reply; + function __construct($conf) { + $this->conf = $conf; + $this->bcc = $conf['mail']['bcc']; + $this->reply = $conf['mail']['reply']; + $this->sender = $conf['mail']['sender']; - function __construct( $conf) { - $this->conf = $conf; - $this->sender = $conf['mail']['sender']; - $this->cc = $conf['mail']['cc']; - $this->reply = $conf['mail']['reply']; + // $params['debug'] = true; + $params['host'] = $conf['mail']['smtpHost']; + $params['localhost'] = $conf['mail']['smtpEhlo']; + $params['username'] = $conf['mail']['smtpUser']; - $params['host'] = $conf['mail']['smtpHost']; - $params['username'] = $conf['mail']['smtpUser']; - //$params['debug'] = true; - $params['localhost'] = $conf['mail']['smtpEhlo']; - $this->smtp =& Mail::factory('smtp', $params); - - } - - function mail($to, $subject, $body, $cc=false) { -/* - // Falls eine Zeile der Nachricht mehr als 70 Zeichen enthälten könnte, - // sollte wordwrap() benutzt werden (http://de.php.net/manual/de/function.mail.php) - $body = wordwrap($body, 70); - - $header = 'From: '. $this->sender . "\n" . - 'Reply-To: '. $this->sender . "\n" . - 'Cc: ' . $this->cc . "\n" . - 'X-Mailer: PHP/' . phpversion() . "\n" . - 'MIME-Version: 1.0' . "\n" . - 'Content-type: text/plain; charset=UTF-8' . "\n". - 'Content-Transfer-Encoding: 8bit' . "\n"; + $this->smtp =& Mail::factory('smtp', $params); + } - // replace linebreaks on www.textgrid.de - $body = str_replace("\r\n", "\n", $body); - - mail($to, $subject, $body, $header);*/ - - $text = $body; - $html = '<html><body>'.nl2br($body).'</body></html>'; - $crlf = "\n"; + function mail($to, $subject, $body) { + /** + * Falls eine Zeile der Nachricht mehr als 70 Zeichen enthälten könnte, + * sollte wordwrap() benutzt werden (http://de.php.net/manual/de/function.mail.php): + * + * $body = wordwrap($body, 70); + * $header = 'From: '. $this->sender . "\n" . + * 'Reply-To: '. $this->sender . "\n" . + * 'Cc: ' . $this->cc . "\n" . + * 'X-Mailer: PHP/' . phpversion() . "\n" . + * 'MIME-Version: 1.0' . "\n" . + * 'Content-type: text/plain; charset=UTF-8' . "\n". + * 'Content-Transfer-Encoding: 8bit' . "\n"; + * + * Replace line breaks on www.textgrid.de: + * + * $body = str_replace("\r\n", "\n", $body); + * mail($to, $subject, $body, $header); + */ - $mime = new Mail_mime(array('eol' => $crlf, 'html_charset' => 'UTF-8', 'text-charset' => 'UTF-8')); - $mime->setTXTBody($text); - $mime->setHTMLBody($html); + $recipients = $to . ', ' . $this->bcc; - $headers['From'] = $this->sender; - $headers['To'] = $to; - $headers['Reply-To'] = $this->reply; - $headers['Subject'] = $subject; - - if($cc) { - $headers['Cc:'] = $this->cc; - } - - $body = $mime->get(); - $headers = $mime->headers($headers); - - $this->smtp->send($to, $headers, $body); + $headers['Bcc'] = $this->bcc; + $headers['From'] = $this->sender; + $headers['Reply-To'] = $this->reply; + $headers['Subject'] = $subject; + $headers['To'] = $to; + + $body = wordwrap($body, 70); + $text = $body; + // $html = '<html><body>' . nl2br($body) . '</body></html>'; - } + $mime = new Mail_mime(array('eol' => "\n", + 'head_charset' => 'UTF-8', + 'text_charset' => 'UTF-8', + 'text_encoding' => '8bit') + ); + // $mime = new Mail_mime(array('eol' => "\n", + // 'head_charset' => 'UTF-8', + // 'html_charset' => 'UTF-8', + // 'text_charset' => 'UTF-8', + // 'text_encoding' => '8bit') + // ); + $mime->setTXTBody($text); + // $mime->setHTMLBody($html); + + $body = $mime->get(); + $headers = $mime->headers($headers); + + $this->smtp->send($recipients, $headers, $body); + } } ?>