[ mika @ 29.01.2008. 21:53 ] @
Pozdrav svima,

Za potrebe jednog projekta (PHP5) potrebna mi je sto manja klasa koja može da se autentifikuje na SMTP server i pošalje HTML email (attachmenti nisu bitni).

Znam za "divove" poput PHP Mailera ili Swift Mailera ali treba mi što manja klasa. Gledao sam na PHPclasses.org ali nisam našao ništa odgovorajuće (ili su pisane za PHP4 ili nisu pisane u OOP maniru kao što je npr. PHP Mailer).

Može li neko da mi preporuči neku proverenu klasicu?

Unapred hvala!

[ agvozden @ 30.01.2008. 08:00 ] @
zbog autentifikacije na SMTP takva klasa ne moze uopste biti mala. Moze prost SMTP modul, ali razliciti nivoi pristupa SMTP serveru traze malo vise koda...
[ mika @ 30.01.2008. 08:48 ] @
OK, hvala!

Imate li neku ideju koja klasa bi to mogla da bude, da je neko već koristio?

Pozz

[ CtrlAltDel @ 30.01.2008. 22:34 ] @
znam da nije klasa ali to vec mozes sam da pretabas kako ti odgovara...


Code:

<?
function saljimail($from, $to, $subject, $message)
{

// server konfiguracija

$smtpServer = "mail.vasdomen.com";
$username = "emailadresa";
$password = "sifra";

$port = "25";
$timeout = "30";
$localhost = "localhost";
$newLine = "\r\n";
//--------------------------------------------





//Konektovanje na port
$smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);
$smtpResponse = fread($smtpConnect, 515); 
if(empty($smtpConnect)) 
{
$failed = "failed+"; 
$output = "Failed to connect:$smtpResponse"; 
return $output; 

}
else
{
$logArray['connection'] = "Connected: $smtpResponse";

}

//Kazi EHLO zbog EXIMA inace HELO
fputs($smtpConnect, "EHLO $localhost" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['heloresponse'] = "$smtpResponse";


//zahtevaj autorizaciju
fputs($smtpConnect,"AUTH LOGIN" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authrequest'] = "$smtpResponse";

//salji korisnicko ime
fputs($smtpConnect, base64_encode($username) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authusername'] = "$smtpResponse";

//salji sifru
fputs($smtpConnect, base64_encode($password) . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['authpassword'] = "$smtpResponse";


//mail od
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";

//mail ka
fputs($smtpConnect, "RCPT TO: $to" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailtoresponse'] = "$smtpResponse";

//mail
fputs($smtpConnect, "DATA" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data1response'] = "$smtpResponse";

//hederi
$headers = "MIME-Version: 1.0" . $newLine;
$headers .= "Content-type: text/html; charset=windows-1250" . $newLine;
//$headers .= "To: $to" . $newLine;
$headers .= "From: $from" . $newLine;

fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");
$smtpResponse = fgets($smtpConnect, 515);
$logArray['data2response'] = "$smtpResponse";

// zatvori SMTP
fputs($smtpConnect,"QUIT" . $newLine); 
$smtpResponse = fgets($smtpConnect, 515);
$logArray['quitresponse'] = "$smtpResponse"; 

echo '<pre>';

//izvestaj
//print_r($logArray);
}
?>




[Ovu poruku je menjao CtrlAltDel dana 31.01.2008. u 01:55 GMT+1]
[ mika @ 31.01.2008. 08:30 ] @
Probacu!

Puno hvala!!