À¥¼¹ö¿¡¼ php ¸ÞÀÏÇÔ¼ö »ç¿ëÀÌ ºÒ°¡´ÉÇϰųª ¿À·ù°¡ ¹ß»ýµÉ¶§ ¾Æ·¡¿Í°°ÀÌ ¸ÞÀϼ¹ö¿¡ smtp ¼ÒÄÏÁ¢¼ÓÈÄ ¹ß¼ÛÇÏ´Â ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.
½ºÅ©¸³Æ®¸¦ ÂüÁ¶Çϼż ¼öÁ¤Çؼ »ç¿ëÇÏ½Ã¸é µÇ°Ú½À´Ï´Ù. °¨»çÇÕ´Ï´Ù.
<? $smtp_id = "smtp ¾ÆÀ̵ð"; $smtp_pwd = "smtp Æнº¿öµå"; $host = "smtp.ÀÚ½ÅÀǵµ¸ÞÀÎ"; // ex) smtp.g3.cc $port = 25; $tomail = "¹Þ´Â »ç¶÷ ¸ÞÀÏÁÖ¼Ò"; $frommail ="º¸³»´Â »ç¶÷ ¸ÞÀÏÁÖ¼Ò"; $webid="º¸³»´Â »ç¶÷ À̸§ ¶Ç´Â ID"; $subject = "Á¦¸ñ"; $type = "text/html"; // ÀÌ°Ç html Çü½ÄÀ¸·Î º¸³¾¶§ ¾¹´Ï´Ù. $message = "³»¿ë";
$fp = fsockopen($host, $port, &$errno, &$errstr, 30);
if($fp) {
fgets($fp, 128); fputs($fp, "helo $HTTP_HOSTrn"); fgets($fp, 128);
// À̺κп¡ ´ÙÀ½°ú °°ÀÌ ·Î±ä°úÁ¤¸¸ µé¾î°¡¸éµË´Ï´Ù. fputs($fp, "auth loginrn"); fgets($fp,128); fputs($fp, base64_encode($smtp_id)."rn"); fgets($fp,128); fputs($fp, base64_encode($smtp_pwd)."rn"); fgets($fp,128);
fputs($fp, "mail from: <$frommail>rn"); $returnvalue[0] = fgets($fp, 128); fputs($fp, "rcpt to: <$tomail>rn"); $returnvalue[1] = fgets($fp, 128); fputs($fp, "datarn"); fgets($fp, 128); fputs($fp, "Return-Path: $frommailrn"); fputs($fp, "From: "$webid" <$frommail>rn"); fputs($fp, "To: <$tomail>rn"); fputs($fp, "Subject: $subjectrn"); fputs($fp, "Content-Type: ".$type."; charset="euc-kr"rn"); //fputs($fp, "Content-Transfer-Encoding: base64rn"); fputs($fp, "rn");
$message= chunk_split(base64_encode($message)); fputs($fp, $message); fputs($fp, "rn"); fputs($fp, "rn.rn"); $returnvalue[2] = fgets($fp, 128); fclose($fp);
if (ereg("^250", $returnvalue[0])&&ereg("^250", $returnvalue[1])&&ereg("^250", $returnvalue[2])) { $sendmail_flag = true; } }
if ($sendmail_flag) { echo "¸ÞÀÏ º¸³»±â ¼º°ø"; } else { echo "¸ÞÀÏ º¸³»±â ½ÇÆÐ"; } ?> |
|