| SMTP AUTH Email Gönderme |
|
|
|
| Salı, 21 Ağustos 2007 | ||||||||
|
"SMTP AUTH Email Gönderme fonksiyonu ve örneği." <?php // Örnek Kullanım $to = " Bu mail adresi spam botlara karşı korumalıdır, görebilmek için Javascript açık olmalıdır "; $nameto = "Ayhan BARIS "; $from = " Bu mail adresi spam botlara karşı korumalıdır, görebilmek için Javascript açık olmalıdır "; $namefrom = "Gonderen Adı "; $subject = "Mesaj Konusu "; $message = "Mesaj" authSendEmail($from, $namefrom, $to, $nameto, $subject, $message); ?> <?php /* * * * * * * * * * * * * * EMAIL GONDERME FONKSIYONLARI * * * * * * * * * * * * * */ //Authenticate Send - 21st March 2005 //This will send an email using auth smtp and output a log array //logArray - connection, function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) { //SMTP + SERVER DETAYLARI /* * * * AYAR BASLANGICI* * * */ $smtpServer = "mail.server.com"; $port = "25"; $timeout = "30"; $username = "smtpusername"; $password = "smtppassword"; $localhost = "localhost"; $newLine = "\r\n"; /* * * * AYAR SONU * * * * */ //Connect to the host on the specified port $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout); $smtpResponse = fgets($smtpConnect, 515); if(empty($smtpConnect)) { $output = "Baglantı Kurulamadı : $smtpResponse"; return $output; } else { $logArray['connection'] = "Baglandı: $smtpResponse"; } //Request Auth Login fputs($smtpConnect,"AUTH LOGIN" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authrequest'] = "$smtpResponse"; //Username Gonderiliyor fputs($smtpConnect, base64_encode($username) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authusername'] = "$smtpResponse"; //Password Gonderiliyor fputs($smtpConnect, base64_encode($password) . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['authpassword'] = "$smtpResponse"; //Hello to SMTP fputs($smtpConnect, "HELO $localhost" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['heloresponse'] = "$smtpResponse"; //Email From fputs($smtpConnect, "MAIL FROM: $from" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailfromresponse'] = "$smtpResponse"; //Email To fputs($smtpConnect, "RCPT TO: $to" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['mailtoresponse'] = "$smtpResponse"; fputs($smtpConnect, "DATA" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['data1response'] = "$smtpResponse"; //Headerlar $headers = "MIME-Version: 1.0" . $newLine; $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine; $headers .= "To: $nameto <$to>" . $newLine; $headers .= "From: $namefrom <$from>" . $newLine; fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse"; // Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?> Bu yazıyı web sayfanızda alıntılayın | Görüntüleme sayısı: 256
Powered by AkoComment Tweaked Special Edition v.1.4.6 |
||||||||
| < Önceki | Sonraki > |
|---|






Bu yazıya ilk yorumu yazın


