Skip to content
Snippets Groups Projects
Commit e0816773 authored by Ubbo Veentjer's avatar Ubbo Veentjer
Browse files

mail with mime and smtp relay

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@13672 7c539038-3410-0410-b1ec-0f2a7bf1c452
parent be556530
No related branches found
No related tags found
No related merge requests found
......@@ -13,10 +13,10 @@ Installation:
Required pear (http://pear.php.net) packages:
Auth
Auth, Mail, Mail_Mime
$ sudo apt-get install php-pear
$ sudo pear install Auth
$ sudo pear install Auth Mail Mail_Mime
2) Put source into your Webserver path (possibly /var/www)
......
......@@ -19,9 +19,12 @@ $conf['ldap']['managerdn'] = $ini['managerdn'];
$conf['ldap']['managerpassword'] = $ini['managerpassword'];
$conf['ldap']['debug'] = false;
// imap
$conf['imap']['sender'] = $ini['mailSender'];
$conf['imap']['cc'] = $ini['mailCC'];
// mail (imap)
$conf['mail']['sender'] = $ini['mailSender'];
$conf['mail']['cc'] = $ini['mailCC'];
$conf['mail']['smtpHost'] = $ini['smtpHost'];
$conf['mail']['smtpUser'] = $ini['smtpUser'];
$conf['mail']['smtpEhlo'] = $ini['smtpEhlo'];
// textgrid-sandbox
$conf['sandbox'][0] = 'TGPR30';
......
<?php
require_once('Mail.php');
require_once('Mail/mime.php');
class tgImap {
var $conf;
var $sender;
var $cc;
function __construct( $conf) {
function __construct( $conf) {
$this->conf = $conf;
$this->sender = $conf['imap']['sender'];
$this->cc = $conf['imap']['cc'];
$this->sender = $conf['mail']['sender'];
$this->cc = $conf['mail']['cc'];
$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) {
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);
......@@ -29,8 +39,29 @@ class tgImap {
// replace linebreaks on www.textgrid.de
$body = str_replace("\r\n", "\n", $body);
mail($to, $subject, $body, $header);
mail($to, $subject, $body, $header);*/
$text = $body;
$html = '<html><body>'.nl2br($body).'</body></html>';
$crlf = "\n";
$mime = new Mail_mime(array('eol' => $crlf));
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$headers['From'] = $this->sender;
$headers['To'] = $to;
$headers['Subject'] = $subject;
if($cc) {
$headers['Cc:'] = $this->cc;
}
$body = $mime->get();
$headers = $mime->headers($headers);
$this->smtp->send($to, $headers, $body);
}
}
......
......@@ -13,8 +13,11 @@ managerdn = "cn=Manager,dc=textgrid,dc=de"
managerpassword =
[mail]
mailSender = register@textgrid.de
mailSender = register@textgridlab.org
mailCC = TEXTGRID-REGISTER@D-GRID.DE
smtpHost = localhost
smtpUser = register@textgridlab.org
smtpEhlo = localhost
[smarty]
smartyLib = /usr/share/php/smarty/libs/Smarty.class.php
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment