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 '
'; //izvestaj //print_r($logArray); } ?>