$user = 'xxxx@gmail.com';
$pass = '1234';
kısmını değiştirerek kullanabilirsiniz...
<?php header('Content-Type: text/html; charset=utf-8');
$smtp = fsockopen("smtp.gmail.com", 587, $errno, $errstr, 15);
function get($smtp){
$send = '';
$sr = fgets($smtp,1024);
while( $sr ){
$send .= $sr;
if( $sr[3] != '-' ){ break; }
$sr = fgets($smtp,1024);
}
return $send;
}
function put($cmd,$smtp){
fputs($smtp,$cmd."\r\n",1024);
}
function smtp_mail($to, $subject, $message, $headers = '',$smtp)
{
$recipients = explode(',', $to);
$user = 'xxxx@gmail.com';
$pass = '1234';
echo '<pre>';
get($smtp);
put("EHLO ".$_SERVER['HTTP_HOST'],$smtp);
echo get($smtp); // 250
put("STARTTLS",$smtp);
echo get($smtp); // 220
if(false == stream_socket_enable_crypto($smtp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)){
die("unable to start tls encryption");
}
put('AUTH LOGIN',$smtp);
echo get($smtp); // 334
put(base64_encode($user),$smtp);
echo get($smtp); // 334
put(base64_encode($pass),$smtp);
echo get($smtp); // 235
put('MAIL FROM: <'.$user.'>',$smtp);
echo get($smtp); // 250
foreach ($recipients as $email)
{
put('RCPT TO: <'.$email.'>',$smtp);
echo get($smtp); // 250
}
put('DATA',$smtp);
echo get($smtp); // 354
fwrite($smtp, 'Subject: '.$subject."\r\n".'To: <'.implode('>, <', $recipients).'>'."\r\n".$headers."\r\n\r\n".$message."\r\n");
fwrite($smtp, '.'."\r\n");
echo get($smtp); // 250
put("EHLO ".$_SERVER['HTTP_HOST'],$smtp);
echo get($smtp); // 250
put("QUIT",$smtp);
echo get($smtp);
echo "</pre>";
fclose($smtp);
return true;
}
function send_test_email($smtp) {
if(smtp_mail('ulusanyazilim@gmail.com', 'Konu', 'Mesaj','',$smtp)) {
echo "Gönderim Başarılı.";
}else{
echo "Bir Hata Oluştu.";
}
}
send_test_email($smtp);
?>