Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

smtp mail

bukan punya saya pribadi, dapet dr forum hosting, cuma pas saya cek thread aslinya malah sudah dihapus

saya pikir berguna sebagai alternatif fungsi mail(),
utk kondisi web server ada di server A dan mail server ada di server B
ini bisa dipake seandainya ip server A utk mailnya kena blacklist, jd bisa dikirim lewat server lain,
atau jk server A memang tdk punya mail server atau dimatikan sehingga fungsi mail() tidak bisa dipake...

aslinya justru dr script phpbb

--------------------------------------------------------------
<?php

/***************************************************************************
* smtp.php
* -------------------
* begin : Wed May 09 2001
* copyright : (C) 2001 The phpBB Group
* modified : 2005 by edgemaster. Part of External SMTP Mail sender
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

function server_parse($socket, $response)
{
while (substr($server_response, 3, 1) != ' ')
{
if (!($server_response = fgets($socket, 256)))
{
die("Couldn't get mail server response codes");
}
}

if (!(substr($server_response, 0, 3) == $response))
{
die("Ran into problems sending Mail. Response: $server_response");
}
}

// Replacement or substitute for PHP's mail command
function smtpmail($server, $user, $pass, $from, $subject, $message, $mail_to, $headers = '')
{
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);

if ($headers != '')
{
if (is_array($headers))
{
if (sizeof($headers) > 1)
{
$headers = join("\n", $headers);
}
else
{
$headers = $headers[0];
}
}
$headers = chop($headers);

$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);

$header_array = explode("\r\n", $headers);
@reset($header_array);

$headers = '';
while(list(, $header) = each($header_array))
{
if (preg_match('#^cc:#si', $header))
{
$cc = preg_replace('#^cc:(.*)#si', '\1', $header);
}
else if (preg_match('#^bcc:#si', $header))
{
$bcc = preg_replace('#^bcc:(.*)#si', '\1', $header);
$header = '';
}
$headers .= ($header != '') ? $header . "\r\n" : '';
}

$headers = chop($headers);
$cc = explode(', ', $cc);
$bcc = explode(', ', $bcc);
}

if (trim($subject) == '')
{
die("No email Subject specified");
}

if (trim($message) == '')
{
die("Email message was blank");
}

if( !$socket = fsockopen($server, 25, $errno, $errstr, 20) )
{
die("Could not connect to smtp host : $errno : $errstr");
}

server_parse($socket, "220");

fputs($socket, "EHLO $server\r\n");
server_parse($socket, "250");

fputs($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334");

fputs($socket, base64_encode($user) . "\r\n");
server_parse($socket, "334");

fputs($socket, base64_encode($pass) . "\r\n");
server_parse($socket, "235");

fputs($socket, "MAIL FROM: <$from>\r\n");
server_parse($socket, "250");

$to_header = '';

$mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to);
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to))
{
fputs($socket, "RCPT TO: <$mail_to>\r\n");
server_parse($socket, "250");
}

@reset($bcc);
while(list(, $bcc_address) = each($bcc))
{
$bcc_address = trim($bcc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address))
{
fputs($socket, "RCPT TO: <$bcc_address>\r\n");
server_parse($socket, "250");
}
}

@reset($cc);
while(list(, $cc_address) = each($cc))
{
$cc_address = trim($cc_address);
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address))
{
fputs($socket, "RCPT TO: <$cc_address>\r\n");
server_parse($socket, "250");
}
}

fputs($socket, "DATA\r\n");

server_parse($socket, "354");

fputs($socket, "Subject: $subject\r\n");

fputs($socket, "To: $mail_to\r\n");

fputs($socket, "$headers\r\n\r\n");

fputs($socket, "$message\r\n");

fputs($socket, ".\r\n");
server_parse($socket, "250");

fputs($socket, "QUIT\r\n");
fclose($socket);

return TRUE;
}

?>
--------------------------------------------------------------
Tagged:

Comments

  • ada alternatif lagi pak Boo, pake POSS.
    http://poss.sourceforge.net
  • ga ada contoh cara penggunaannya bro?
    kasih example donk
  • contoh? :o
    kira2 klo pake script yg pertama :

    simpan script di postingan pertama pake nama smtp.php

    lalu siapin account email yg ada smtp-nya, misal pk telkom.net
    catatan : telkom.net cuma contoh, soalnya telkom.net tdk boleh kirim email dr luar lewat smtp-nya
    server smtp-nya telkom.net : smtp.telkom.net
    username emailnya : useremail
    password : passwordnya

    lalu script yg pake fungsi mail() dan mo diganti pake fungsi smtpmail() diatas diubah jadi

    mail( $to , $subject , $message , $header )

    jadi :

    include("smtp.php");
    smtpmail( "smtp.telkom.net" , "useremail" , "passwordnya" , $from , $subject , $message , $to , $header )

    $from bisa diisi alamat account email yg di telkom.net, useremail@telkom.net
    atau alamat email yg lain
  • Terimakasih spidey.
    Kira2 komputer yg konek ke speedy bs ga ya dijadiin server buat kirim newsletter?
    karena speedy menerapkan dinamic IP, dan hanya punya no IP aja (tdk ada domainnya). maka email yg saya kirim masuk ke bulk/spam. bener ga analisa saya?
    Untuk mengatasinya gmn?
    Thanks B4
  • coba cari alamat imel gratis yg bs di pk smtpnya,
    dulu hotpop.com & bluebottle.com bisa,
    terakhir info yg dapet, bluebottle cm buat yg bayar, yg gratis gk bisa lg,
    jd cb hotpop-nya
Sign In or Register to comment.