구글 메일(GMail)로 메일 발송하기 | |||
| |||
엄청난 뒷북일 수도 있지만, 검색해보니 없네요 :-) 급조한 소스 들어갑니다. 간단하기 때문에 딱 보시면 알듯 하구요, 중요한 것은 구글의 SMTP 메일 설정 몇가지 일듯 합니다. 우선 문자셋 기준은 UTF-8로 되어 있고, 예제로 만든 페이지에서 구글 광고를 삭제한 원본 그대로입니다. 원래 메일러를 PEAR로 쓰려 했는데 의존성이 있어서, XPertMailer라는 것을 사용했습니다. 말 그대로 전문가들이 쓰는 것이라는 뜻인 듯 하지만, 꽤나 편하게 쓸 수 있도록 되어 있더군요. XPertMailer.php 파일을 동일 폴더에 넣으면 작동할 것 같네요. 아참, 그리고 서버에 SSL 모듈이 깔려있어야 합니다. -------------------------------------- if(isset($_POST['submit'])) { $password = $_POST['password']; $sender_email = $_POST['sender_email']; $sender = '=?UTF-8?B?'.base64_encode($_POST['sender']).'?='; $receiver = '"'.'=?UTF-8?B?'.base64_encode($_POST['receiver']).'?='.'" <'.$_POST['receiver_email'].'>'; $subject = '=?UTF-8?B?'.base64_encode($_POST['subject']).'?='; $contents = $_POST['contents']; $contents .= ' ---------------------- 이 메일은 리플넷에서 제공하는 구글 SMTP를 이용한 시험 메일 발송입니다. 자세한 사항은 어바웃웹을 참고하세요. http://blog.repl.net/web/ http://www.repl.net/smtp/ '; require("XPertMailer.php"); $mail = new XPertMailer(SMTP_RELAY_CLIENT, '66.249.93.109', 1, true); $mail->auth($sender_email, $password, AUTH_LOGIN, SSL_TRUE, 465); //$mail->port(25); $mail->timeout(10); $mail->priority(P_HIGH); $mail->from($sender_email, $sender); $header['Reply-To'] = $sender_email; $header['X-Whatever'] = 'description'; $mail->headers($header); $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <body> '.nl2br($contents).' </body> </html>'; $text = $contents; $send = $mail->send($receiver, $subject, $text, $html, 'UTF-8'); echo $send ? "Done." : "Error."; echo "<br>Server response: ".$mail->response; if($send=="Done.") { ?> <script> alert('Success'); document.location = 'http://www.repl.net/smtp/'; </script> <?PHP exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>구글의 SMTP 서버를 이용한 메일 발송</title> <meta http-equiv="Content-Style-Type" content="text/css" /> <META NAME="Author" CONTENT="이삼구"> <META NAME="Keywords" CONTENT="지메일 SMTP 메일발송"> <META NAME="Description" CONTENT="구글의 지메일 SMTP를 이용한 메일발송 테스트 페이지입니다."> </head> <body style="margin: 0 0 0 0px"><script type="text/javascript" src="http://www.repl.net/js/repl_top.js"></script> <div align=center> <h1 style="font-size: 40px; font-family: 돋움">구글메일의 SMTP를 이용한 메일발송 <th>Beta!</th></h1> 아래의 정보를 정확히 넣고 발송 버튼을 눌러주세요.<br /> (보내는 메일은 실제 구글 메일이어야 합니다. 정확한 계정과 비밀번호를 넣으세요.) <br /><br /> <form action="" method="POST"> 보내는 이름 : <input type="text" name="sender" value="<?PHP echo @$_POST['sender'];?>" style="width: 450px;"><br /> 구글 이메일 : <input type="text" name="sender_email" value="<?PHP echo @$_POST['sender_email'];?>" style="width: 450px;"><br /> 구글 계정 암호 : <input type="password" name="password" value="<?PHP echo @$_POST['password'];?>" style="width: 450px;"><br /> 받는 이름 : <input type="text" name="receiver" value="<?PHP echo @$_POST['receiver'];?>" style="width: 450px;"><br /> 받는 이메일 : <input type="text" name="receiver_email" value="<?PHP echo @$_POST['receiver_email'];?>" style="width: 450px;"><br /> 제목 : <input type="text" name="subject" value="<?PHP echo @$_POST['subject'];?>" style="width: 450px;"><br /> 내용 : <textarea name="contents" style="width: 450px; height: 200px"><?PHP echo @$_POST['contents'];?></textarea><br /> <input type="submit" name="submit" value="발송"> </form><br /><br /> Copyright © 2006 <a href="http://www.repl.net/">리플넷</a> </div> </body> </html> Tags: JavaScript PHP gmail smtp | |||
| |||
| |||
로그인을 하시면 댓글을 등록 할 수 있습니다. |
SIMILAR POSTS window 스스로 닫기 |
OTHER POSTS IN THE SAME CATEGORY spoolsv.exe의 문제 cpu점유률 100% |