http://salmingkorea.com/salmingkorea/070.htm
인터넷에 있는 소스들을 퍼와서 적용을 했는데
메일로 발송이 되질 않습니다 ..
- - - - - html 내용 - - - - - -
<form method='post' action='send.php'> <tr> <td align="center" height="50" width="408" bgcolor="#FFFFFF" bordercolor="#FFFFFF" colspan="2"> <b><font size="2">폼메일 테스트 </font></b></td> </tr> <tr> <td align="center" height="22" width="90" bgcolor="#7481AB"> <font color="#FFFFFF">이름</font></td> <td width="316"> <input type="text" name="name" maxlength="35" style="height:20; width:160" size="35"></td> </tr> <tr> <td align="center" height="22" width="90" bgcolor="#7481AB"> <font color="#FFFFFF">성별</font></td> <td width="316"> <input type="radio" value="male" name="sex">남자 <input type="radio" value="female" name="sex" > 여자</td> </tr> <tr> <td align="center" height="22" width="90" bgcolor="#7481AB"> <font color="#FFFFFF">직업</font></td> <td width="316"> <select size="1" name="job" style="width:100"> <option selected>직장인</option> <option>주부</option> <option>학생</option> <option>기타</option> </select></td> </tr> <tr> <td align="center" height="22" width="90" bgcolor="#7481AB"> <font color="#FFFFFF">이메일</font></td> <td width="316"> <input type="text" name="email" maxlength="35" style="height:20; width:160" size="35"></td> </tr> <tr> <td align="center" height="22" width="90" bgcolor="#7481AB"> <font color="#FFFFFF">제목</font></td> <td width="316"> <input type="text" name="subject" maxlength="60" style="height:20; width:316" size="60"></td> </tr> <tr> <td height="172" bgcolor="#7481AB"> <p align="center"><font color="#FFFFFF">추가내용</font></td> <td height="172"><textarea name="content" rows="13" cols="49"></textarea></td> </tr> <tr> <td align="center" height="50" colspan="2"> <input type="submit" value="입 력" style="width=100;height:24px"> <input type="reset" value="취 소" style="width=100;height:24px"></td> </tr></table></form>
- - - - - - php 내용 - - - - - - - -
<[email protected]"; //이 폼메일을 받을 메일주소function error($text){ echo " <script language=javascript> window.alert('$text') history.go(-1) </script>"; exit;}function msg($text){ echo " <script language=javascript> window.alert('$text') top.location.href = '070.htm' </script> "; exit;}if (!$name) {error('성명을 적어주세요');} // 이름이 없을때 에러 메세지if (!$sex) {error('성별을 선택해 주세요');}if (!$email) {error('메일 주소를 적어주세요');} // 메일주소가 없을때 에러 메세지if (!$subject) {error('제목을 적어주세요');} // 제목이 없을때 에러 메세지 $mailheaders = "Return-Path: $email \r\n"; // 메일 헤더의 반송 메일 주소 $mailheaders .= "From: $name <$email>\r\n"; // 메일헤더의 이름과 메일 주소 표시$body = " 이름 : $name \r\n";$body .= " 메일주소 : $email \r\n";$body .= " 성별 : $sex \r\n";$body .= " 직업 : $job \r\n";$body .= " 내 용 : $content \r\n";$result=mail($tomail , $subject , $body , $mailheaders); // 메일 전송if($result) {msg('메일이 성공적으로 발송되었습니다.');} // 전송 성공시else{error('메일 발송에 실패하였습니다.');} // 전송 실패시?>
답변 2개 / 댓글 4개
php내용 중에서
1번째 줄에 보면
<?
[email protected]"; //이 폼메일을 받을 메일주소
라고 되어 있는데요.
<?
$email = "[email protected]"; //이 폼메일을 받을 메일주소
와 같은 형식으로 되어야 하겠고요.
그리고, 폼메일 페이지에서 post방식으로 보낸 값들을 $변수값 으로 받아오지 못하도록 기본설정이 되어 있을 수 있으므로 $_POST["변수값"] 형식으로 수정해서 적용해보세요.
답변에 대한 댓글 4개
$body 값에 이름을 불러오는 것을 예를 든다면
$body = " 이름 :".$_POST["name"]."\r\n";
와 같이 되겠구요.
기본적인 php 사용법은 숙지하셔야 할것 같네요.
$email값은 이전 페이지에서 가져오는 것이 아니라 현재 페이지 상단의 변수값에서 받아오므로
$_POST["email"]이 아니라 그냥 $email 로 사용하셔야 합니다.
그리고, 가장 중요한 것은 현재 호스팅되고 있는 사이트에서 센드메일 기능을 지원하는지 먼저 확인해 보세요.
그누보드가 설치 되어 있다면 관리자 모드에서 메일 테스팅을 이용해서 메일 전송이 정상적으로 되는지 확인하세요.
제가 PHP를 전혀 몰라서요 .. 웹디자이너인데 .. 저희 회사에 개발자.. 프로그래머 없이 혼자 작업하다보니 모르는 것 투성이네요 .. 도움 주셔서 감사합니다!!
위 방법으로 해봤는데 덧글 다 읽고 수정을 해봤는데 메일이 오지 않습니다...
$email = "받을 이메일 주소";
.. 중략 ..
$body .= $email;
.. 중략 ..
이렇게 했는데 메일이 오질 않네요...
카페24를 사용해서 테스트 메일들은 정상적으로 오는데...
위 소스만 오지 않습니다. 어떻게 해야하나요 ㅠ^ㅠ
<?$email = "[email protected]"; function error($text) { echo " <script> window.alert('$text') history.go(-1) </script>"; exit;}function msg($text){ echo " <script language=javascript> window.alert('$text') top.location.href = '/gb/test/mail_test.php' </script> "; exit;}/*if (!$name) {error('성명을 적어주세요');} // 이름이 없을때 에러 메세지if (!$sex) {error('성별을 선택해 주세요');}if (!$email) {error('메일 주소를 적어주세요');} // 메일주소가 없을때 에러 메세지if (!$subject) {error('제목을 적어주세요');} // 제목이 없을때 에러 메세지 */$mailheaders = "Return-Path: $email \r\n"; // 메일 헤더의 반송 메일 주소 $mailheaders .= "From: $name <$email>\r\n"; // 메일헤더의 이름과 메일 주소 표시$body = " 이름 :".$_POST["name"]."\r\n"; $body = $email; $body = " 성별 :".$_POST["sex"]."\r\n"; $body = " 직업 :".$_POST["job"]."\r\n"; $body = " 내 용 :".$_POST["content"]."\r\n"; $result=mail($tomail , $subject , $body , $mailheaders); // 메일 전송if($result) {msg('ok.');} // 전송 성공시else{error('no');} // 전송 실패시?>
메일이 안오는데요... 다른 1:1 문의나 일반 게시판, 메일 테스트는 정상적으로 메일이 옵니다.
근데 이거는 메일이 안오네요...
답변을 작성하려면 로그인이 필요합니다.
$body = $_POST[" 이름 : $name \r\n"] ;
$body .= $_POST[" 메일주소 : $email \r\n"];
$body .= $_POST[" 성별 : $sex \r\n"];
$body .= $_POST[" 직업 : $job \r\n"];
$body .= $_POST[" 내 용 : $content \r\n"];
이렇게 수정했는데.. 안되네요 .. ;