25.03.2010, 18:07
Moin Moin,
ich habe folgende Problematik:
Ich habe einen vServer mit Ubuntu 8.04 LTS (Hardy) - 32 Bit minimal. auf diesem laufen unter anderem einige Projekte die mit dem CMS ilch (www.ilch.de) realisiert sind, diese projekte versenden auch emails über smtp. aber ich habe alle bisher erdenklichen beiträge im bezug auf email versand hier aus dem forum und auch via google etc. versucht.
Infos zur Umgebung:
vServer m. Ubuntu 8.04 lts 32 bit minimal
Div. Projekte mit ilch V. 11N umgesetzt die auch emails senden via smtp
smtp über gmx.de mit dem gleichen konto
myBB Version 1.4.11 (1411)
Theme: geändert (nicht manuell sondern importiert)
Plugins:
Fit on Page
MYPS
PHP and Themplate Conditionals
Simple Calender on Portal
Post on Registration
ragtek_eventcalendar
Specific forum banning
INFO: Der email Versand ist auch nicht in der reinen Grundinstallation möglich (getestet)
Hier meine myBB - php.php (alle Komentare entfernt)
Hier die myBB - smtp.php (alle komentare entfernt)
Hier noch die ilch - smtp.php (dieses CMS kann mails versenden)
Ich Sende meine php.php und die smtp.php aus dem mailhandlers Verzeichnis als Anhang mit.
[attachment=5419]
[attachment=5420]
Link zu dem Forum: http://deine.bos-freunde.de (fast vergessen anzugeben ^^)
MfG DieBulldogge
ich habe folgende Problematik:
Ich habe einen vServer mit Ubuntu 8.04 LTS (Hardy) - 32 Bit minimal. auf diesem laufen unter anderem einige Projekte die mit dem CMS ilch (www.ilch.de) realisiert sind, diese projekte versenden auch emails über smtp. aber ich habe alle bisher erdenklichen beiträge im bezug auf email versand hier aus dem forum und auch via google etc. versucht.
Infos zur Umgebung:
vServer m. Ubuntu 8.04 lts 32 bit minimal
Div. Projekte mit ilch V. 11N umgesetzt die auch emails senden via smtp
smtp über gmx.de mit dem gleichen konto
myBB Version 1.4.11 (1411)
Theme: geändert (nicht manuell sondern importiert)
Plugins:
Fit on Page
MYPS
PHP and Themplate Conditionals
Simple Calender on Portal
Post on Registration
ragtek_eventcalendar
Specific forum banning
INFO: Der email Versand ist auch nicht in der reinen Grundinstallation möglich (getestet)
Hier meine myBB - php.php (alle Komentare entfernt)
PHP-Code:
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
class PhpMail extends MailHandler
{
var $additional_parameters = '';
function send()
{
global $lang, $mybb;
$this->sendmail = @ini_get('sendmail_path');
if($this->sendmail)
{
$this->headers = str_replace("\r\n", "\n", $this->headers);
$this->message = str_replace("\r\n", "\n", $this->message);
$this->delimiter = "\n";
}
$this->sendmail_from = @ini_get('sendmail_from');
if($this->sendmail_from != $mybb->settings['adminemail'])
{
@ini_set("sendmail_from", $mybb->settings['adminemail']);
}
if(ini_get('safe_mode') == 1 || strtolower(ini_get('safe_mode')) == 'on')
{
$sent = @mail($this->to, $this->subject, $this->message, trim($this->headers));
}
else
{
$sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters);
}
$function_used = 'mail()';
if(!$sent)
{
$this->fatal_error("MyBB was unable to send the email using the PHP {$function_used} function.");
return false;
}
return true;
}
}
?>
Hier die myBB - smtp.php (alle komentare entfernt)
PHP-Code:
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
if(!defined('MYBB_SSL'))
{
define('MYBB_SSL', 1);
}
if(!defined('MYBB_TLS'))
{
define('MYBB_TLS', 2);
}
class SmtpMail extends MailHandler
{
var $connection;
var $username = '';
var $password = '';
var $helo = 'localhost';
var $authenticated = false;
var $timeout = 5;
var $status = 0;
var $port = 25;
var $secure_port = 465;
var $host = '';
var $data = '';
var $code = 0;
var $last_error = '';
var $keep_alive = false;
function SmtpMail()
{
global $mybb;
$this->__construct();
}
function __construct()
{
global $mybb;
$protocol = '';
switch($mybb->settings['secure_smtp'])
{
case MYBB_SSL:
$protocol = 'ssl://';
break;
case MYBB_TLS:
$protocol = 'tls://';
break;
}
if(empty($mybb->settings['smtp_host']))
{
$this->host = @ini_get('SMTP');
}
else
{
$this->host = $mybb->settings['smtp_host'];
}
$this->helo = $this->host;
$this->host = $protocol . $this->host;
if(empty($mybb->settings['smtp_port']) && !empty($protocol) && !@ini_get('smtp_port'))
{
$this->port = $this->secure_port;
}
else if(empty($mybb->settings['smtp_port']) && @ini_get('smtp_port'))
{
$this->port = @ini_get('smtp_port');
}
else if(!empty($mybb->settings['smtp_port']))
{
$this->port = $mybb->settings['smtp_port'];
}
$this->password = $mybb->settings['smtp_pass'];
$this->username = $mybb->settings['smtp_user'];
}
function send()
{
global $lang, $mybb;
if(!$this->connected())
{
$this->connect();
}
if($this->connected())
{
if(!$this->send_data('MAIL FROM:<'.$this->from.'>', '250'))
{
$this->fatal_error("The mail server does not understand the MAIL FROM command. Reason: ".$this->get_error());
return false;
}
$emails = explode(',', $this->to);
foreach($emails as $to)
{
$to = trim($to);
if(!$this->send_data('RCPT TO:<'.$to.'>', '250'))
{
$this->fatal_error("The mail server does not understand the RCPT TO command. Reason: ".$this->get_error());
return false;
}
}
if($this->send_data('DATA', '354'))
{
$this->send_data('Date: ' . gmdate('r'));
$this->send_data('To: ' . $this->to);
$this->send_data('Subject: ' . $this->subject);
// Only send additional headers if we've got any
if(trim($this->headers))
{
$this->send_data(trim($this->headers));
}
$this->send_data("");
$this->message = str_replace("\n.", "\n..", $this->message);
$this->send_data($this->message);
}
else
{
$this->fatal_error("The mail server did not understand the DATA command");
return false;
}
$this->send_data('.', '250');
if(!$this->keep_alive)
{
$this->close();
}
return true;
}
else
{
return false;
}
}
function connect()
{
global $lang, $mybb;
$this->connection = @fsockopen($this->host, $this->port, $error_number, $error_string, $this->timeout);
if(function_exists('stream_set_timeout') && DIRECTORY_SEPARATOR != '\\')
{
@stream_set_timeout($this->connection, $this->timeout, 0);
}
if(is_resource($this->connection))
{
$this->status = 1;
$this->get_data();
if(!$this->check_status('220'))
{
$this->fatal_error("The mail server is not ready, it did not respond with a 220 status message.");
return false;
}
if(!empty($this->username) && !empty($this->password))
{
$data = $this->send_data('EHLO ' . $this->helo, '250');
if(!$data)
{
$this->fatal_error("The server did not understand the EHLO command");
return false;
}
preg_match("#250-AUTH( |=)(.+)$#mi", $data, $matches);
if(!$this->auth($matches[2]))
{
$this->fatal_error("MyBB was unable to authenticate you against the SMTP server");
return false;
}
}
else
{
if(!$this->send_data('HELO ' . $this->helo, '250'))
{
$this->fatal_error("The server did not understand the HELO command");
return false;
}
}
return true;
}
else
{
$this->fatal_error("Unable to connect to the mail server with the given details.<br /><br />{$error_number}: {$error_string}");
return false;
}
}
function auth($auth_methods)
{
global $lang, $mybb;
$auth_methods = explode(" ", $auth_methods);
if(in_array("LOGIN", $auth_methods))
{
if(!$this->send_data("AUTH LOGIN", 334))
{
if($this->code == 503)
{
return true;
}
$this->fatal_error("The SMTP server did not respond correctly to the AUTH LOGIN command");
return false;
}
if(!$this->send_data(base64_encode($this->username), '334'))
{
$this->fatal_error("The SMTP server rejected the supplied SMTP username. Reason: ".$this->get_error());
return false;
}
if(!$this->send_data(base64_encode($this->password), '235'))
{
$this->fatal_error("The SMTP server rejected the supplied SMTP password. Reason: ".$this->get_error());
return false;
}
}
else if(in_array("PLAIN", $auth_methods))
{
if(!$this->send_data("AUTH PLAIN", '334'))
{
if($this->code == 503)
{
return true;
}
$this->fatal_error("The SMTP server did not respond correctly to the AUTH PLAIN command");
return false;
}
$auth = base64_encode(chr(0).$this->username.chr(0).$this->password);
if(!$this->send_data($auth, 235))
{
$this->fatal_error("The SMTP server rejected the supplied login username and password. Reason: ".$this->get_error());
return false;
}
}
else
{
$this->fatal_error("The SMTP server does not support any of the AUTH methods that MyBB supports");
return false;
}
return true;
}
function get_data()
{
$string = '';
while((($line = fgets($this->connection, 515)) !== false))
{
$string .= $line;
if(substr($line, 3, 1) == ' ')
{
break;
}
}
$this->data = $string;
$this->code = substr(trim($this->data), 0, 3);
return $string;
}
function connected()
{
if($this->status == 1)
{
return true;
}
return false;
}
function send_data($data, $status_num = false)
{
if($this->connected())
{
if(fwrite($this->connection, $data."\r\n"))
{
if($status_num != false)
{
$rec = $this->get_data();
if($this->check_status($status_num))
{
return $rec;
}
else
{
$this->set_error($rec);
return false;
}
}
return true;
}
else
{
$this->fatal_error("Unable to send the data to the SMTP server");
return false;
}
}
return false;
}
function check_status($status_num)
{
if($this->code == $status_num)
{
return $this->data;
}
else
{
return false;
}
}
function close()
{
if($this->status == 1)
{
$this->send_data('QUIT');
fclose($this->connection);
$this->status = 0;
}
}
function get_error()
{
if(!$this->last_error)
{
$this->last_error = "N/A";
}
return $this->last_error;
}
function set_error($error)
{
$this->last_error = $error;
}
}
?>
Hier noch die ilch - smtp.php (dieses CMS kann mails versenden)
PHP-Code:
<?php
# Copyright by Manuel
# Support www.ilch.de
defined ('main') or die ( 'no direct access' );
function server_parse($socket, $response, $line = __LINE__)
{
$server_response = '';
while (substr($server_response, 3, 1) != ' ')
{
if (!($server_response = fgets($socket, 256)))
{
echo 'Couldn\'t get mail server response codes<br />';
}
}
if (!(substr($server_response, 0, 3) == $response))
{
echo "Ran into problems sending Mail. Response: $server_response<br />";
}
}
function smtpmail($mail_to, $subject, $message, $headers = '')
{
global $allgAr;
$smtp_host = $allgAr['mail_smtp_host'];
$smtp_username = $allgAr['mail_smtp_login'];
require_once('include/includes/class/AzDGCrypt.class.inc.php');
$cr64 = new AzDGCrypt(DBDATE.DBUSER.DBPREF);
$smtp_password = $cr64->decrypt($allgAr['mail_smtp_password']);
$absender = $allgAr['mail_smtp_email'];
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
if ($headers != '')
{
if (is_array($headers))
{
if (sizeof($headers) > 1)
{
$headers = join("\n", $headers);
}
else
{
$headers = $headers[0];
}
}
$headers = chop($headers);
$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);
$header_array = explode("\r\n", $headers);
@reset($header_array);
$headers = '';
while(list(, $header) = each($header_array))
{
if (preg_match('#^cc:#si', $header))
{
$cc = preg_replace('#^cc:(.*)#si', '\1', $header);
}
else if (preg_match('#^bcc:#si', $header))
{
$bcc = preg_replace('#^bcc:(.*)#si', '\1', $header);
$header = '';
}
$headers .= ($header != '') ? $header . "\r\n" : '';
}
$headers = chop($headers);
$cc = explode(', ', $cc);
$bcc = explode(', ', $bcc);
}
if (trim($subject) == '')
{
echo 'No email Subject specified<br />';
}
if (trim($message) == '')
{
echo 'Email message was blank<br />';
}
if( !$socket = @fsockopen($smtp_host, 25, $errno, $errstr, 20) )
{
echo "Could not connect to smtp host : $errno : $errstr<br />";
}
server_parse($socket, "220", __LINE__);
if( !empty($smtp_username) && !empty($smtp_password) )
{
fputs($socket, "HELO " . $smtp_host . "\r\n");
server_parse($socket, "250", __LINE__);
fputs($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334", __LINE__);
fputs($socket, base64_encode($smtp_username) . "\r\n");
server_parse($socket, "334", __LINE__);
fputs($socket, base64_encode($smtp_password) . "\r\n");
server_parse($socket, "235", __LINE__);
}
else
{
fputs($socket, "HELO " . $smtp_host . "\r\n");
server_parse($socket, "250", __LINE__);
}
fputs($socket, "MAIL FROM: <" . $absender . ">\r\n");
server_parse($socket, "250", __LINE__);
$to_header = '';
$mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to);
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to))
{
fputs($socket, "RCPT TO: <$mail_to>\r\n");
server_parse($socket, "250", __LINE__);
}
@reset($bcc);
if (isset($bcc))
{
while(list(, $bcc_address) = each($bcc))
{
$bcc_address = trim($bcc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address))
{
fputs($socket, "RCPT TO: <$bcc_address>\r\n");
server_parse($socket, "250", __LINE__);
}
}
}
@reset($cc);
if (isset($cc))
{
while(list(, $cc_address) = each($cc))
{
$cc_address = trim($cc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address))
{
fputs($socket, "RCPT TO: <$cc_address>\r\n");
server_parse($socket, "250", __LINE__);
}
}
}
fputs($socket, "DATA\r\n");
server_parse($socket, "354", __LINE__);
fputs($socket, "Subject: $subject\r\n");
fputs($socket, "To: $mail_to\r\n");
fputs($socket, "$headers\r\n\r\n");
fputs($socket, "$message\r\n");
fputs($socket, ".\r\n");
server_parse($socket, "250", __LINE__);
fputs($socket, "QUIT\r\n");
fclose($socket);
return true;
}
?>
Ich Sende meine php.php und die smtp.php aus dem mailhandlers Verzeichnis als Anhang mit.
[attachment=5419]
[attachment=5420]
Link zu dem Forum: http://deine.bos-freunde.de (fast vergessen anzugeben ^^)
MfG DieBulldogge