" SMTP AUTH Email Gönderme fonksiyonu ve örneği." <?php // Örnek Kullanım $to = "ayhan@abkod.com"; $nameto = "Ayhan BARIS "; $from = "admin@siteadi.com"; $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 = "
"; /* * * * 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";
//Email 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
From: $from
Subject: $subject
$headers
$message
.
"); $smtpResponse = fgets($smtpConnect, 515); $logArray['data2response'] = "$smtpResponse";
// Bye to SMTP fputs($smtpConnect,"QUIT" . $newLine); $smtpResponse = fgets($smtpConnect, 515); $logArray['quitresponse'] = "$smtpResponse"; } ?>
|
|