Programming/PHP
mail 함수로 메일 보내기
왕계란
2007. 11. 20. 10:10
email.html
sendMail.php
누가 물어 봐서 걍 간단하게 만들어서 올린다.
대충 고쳐서 보내면 보내짐;;
설명이 필요하면 도토리 점~ 굽신굽신
- <html>
- <head>
- <title>email</title>
- <script>
- function blankChk() {
- var ff = document.email;
- if(!ff.userName.value) {
- alert(\"이름\");
- ff.userName.focus();
- return false;
- }
- if(!ff.emailAccount.value) {
- alert(\"이메일\");
- ff.emailAccount.focus();
- return false;
- }
- }
- </script>
- </head>
- <body>
- <form name="email" action="sendMail.php" method="post" onSubmit="return blankChk()">
- 이름 <input type="text" name="userName" /><br />
- 이메일 <input type="text" name="emailAccount" /><br />
- 내용 <textarea cols=20" rows=4" name="sendContents"></textarea><br />
- <input type="submit" value="Send" />
- </form>
- </body>
- </html>
sendMail.php
- <?
- $from = "$_POST[userName] : <$_POST[emailAccount]>";
- $additional_headers = "From : $from\n";
- $additional_headers .= "Content-type:text/html; charset=EUC-KR\n";
- $mailto = "받는 사람 메일 주소";
- $subject = "메일 제목(미리 지정해도 되고 폼으로 받아와도 됨)";
- $contents = "
- <table border='0' cellpadding='0' cellspacing='0'>
- <tr>
- <td>이름</td>
- <td>$_POST['userName']</td>
- </tr>
- <tr>
- <td>내용</td>
- <td>$_POST['sendContents']</td>
- </tr>
- </table>
- ";
- mail($mailto, $subject, $contents, $additional_headers);
- ?>
누가 물어 봐서 걍 간단하게 만들어서 올린다.
대충 고쳐서 보내면 보내짐;;
설명이 필요하면 도토리 점~ 굽신굽신