PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Probleme mit SMTP Mailer


Zero111
06.06.2010, 01:30
Nabend.

ich versuche schon den ganzen Tag eine Mail zu senden. Die Mail soll via BCC weitergeleitet werden.

So sieht die Korrespodenz aus:

Server:

220 mail-in-18.arcor-online.net ESMTP arcor.de Mailservices usermail
250-mail-in-18.arcor-online.net
250-PIPELINING
250-SIZE 48000000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Authentication successful
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
250 2.0.0 Ok: queued as 8FA933DC5B0
221 2.0.0 Bye
und so sehen die gesendeten Daten aus:

EHLO localhost
AUTH LOGIN
XXX==
XXX==
MAIL FROM: <Info@XXX>
RCPT TO: <Info@XXX>
DATA
MIME-Version: 1.0
From: XXX TestCenter <Info@XXX>
To: XXX TestCenter <Info@XXX>
Bcc: Nick1 <email1@xxx.de>, Nick2 <email2@xxx.de>, Nick3 <email3@xxx.de>, Nick4 <email4@xxx.de>
Subject: Test Betreff
Content-type: text/plain; charset=iso-8859-1
Test Message
.
QUIT
So sieht die ensprechende Funktion aus


<?php
function smtp_mail($userid_email, $subject, $message, $htmlmail = false)
{
global $db;

if(is_array($userid_email))
{
$email = $userid_email['email'];
$username = $userid_email['username'];
}
elseif(is_numeric($userid_email))
{
$sql = "SELECT username, email FROM users WHERE id = ".$userid_email;
$arr = $db -> querySingleArray($sql);

$email = $arr['email'];
$username = $arr['username'];
}
else
{
$email = $userid_email;
$username = $userid_email;
}

if (!validemail($email) || !$username)
{
return false;
}

$data = array(
"TO" => array($username,$email),
"HTML" => $htmlmail,
"MAIL" => array($subject,$message)
);

return mail_send($data);
}

function smtp_massmailer($userarray, $subject, $message, $htmlmail = false)
{
if (!is_array($userarray))
{
return false;
}

$data = array(
"TO" => array($GLOBALS['SITENAME'],$GLOBALS['SITEEMAIL']),
"BCC" => $userarray,
"HTML" => $htmlmail,
"MAIL" => array($subject,$message)
);

return mail_send($data);
}

function mail_send($data)
{
$auth = explode("|",htmlentities(trim(get_config_data("SMTPAUTH"))));

if (!$auth[0] || !$auth[1] || !$auth[2] || !is_array($data))
{
return false;
}

$port = 25;
$debug = true;

if (is_array($data['BCC']))
{
$bcc = array();
foreach($data['BCC'] as $row)
{
if (empty($row[1]))
{
$name = $row[0];
$mail = $row[0];
}
else
{
$name = $row[0];
$mail = $row[1];
}
$bcc[] = $name." <".$mail.">";
}
$bcc = implode(", ",$bcc);
}

$send = array(
"EHLO visionx.ws",
"AUTH LOGIN",
base64_encode($auth[1]),
base64_encode($auth[2]),
"MAIL FROM: <".$GLOBALS['SITEEMAIL'].">",
"RCPT TO: <".$data['TO'][1].">",
"DATA",
"MIME-Version: 1.0",
"From: ".$GLOBALS['SITENAME']." <".$GLOBALS['SITEEMAIL'].">",
"To: ".$data['TO'][0]." <".$data['TO'][1].">",
"Bcc: ".$bcc,
"Subject: ".$data['MAIL'][0],
"Content-type: text/".($data['HTML'] === true?"html":"plain")."; charset=iso-8859-1",
$data['MAIL'][1],
".",
"QUIT",
);
$handle = fsockopen($auth[0],$port);

foreach($send as $line)
{
fputs($handle, $line."\n");
}

if ($debug === true)
{
while (!feof($handle))
{
print fgets($handle);
}
print "\n\n\n";
foreach($send as $line)
{
print $line."\n";
}
}
fclose($handle);
return true;
}
?>
Es wird jedoch nur eine Email an den im To genannten Empfänger gesendet. Die Bcc wird komplett ignoriert..