테스트 사이트 - 개발 중인 베타 버전입니다

폼메일로 메일을 보내면 보낸사람 메일주소가 root@ruwa64-077.fmcity.com 로 나옵니다. 채택완료

미니2 6년 전 조회 3,703

폼메일로 메일을 보내면 보낸사람 메일주소가 root@ruwa64-077.fmcity.com 로 나옵니다.

이걸 보낸사람이 입력한 메일 주소로 바꿀수는 없을까요?

 

 

</strong></p>

<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank" rel="noopener noreferrer">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank" rel="noopener noreferrer">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a></a>">

<html xmlns="<a href="<a href="http://www.w3.org/1999/xhtml" target="_blank" rel="noopener noreferrer">http://www.w3.org/1999/xhtml</a>"><a href="http://www.w3.org/1999/xhtml" target="_blank" rel="noopener noreferrer">http://www.w3.org/1999/xhtml</a></a>">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<SCRIPT LANGUAGE="JavaScript">

<!--

function chkMailFrm() {

 var f = document.formmail;

 if (!f.title.value) {

  alert("제목을 입력해주세요");

  f.title.focus();

  return false;

 }

 if (!f.senduser.value) {

  alert("이름을 입력해주세요");

  f.senduser.focus();

  return false;

 }

 if (!f.phone.value) {

  alert("전화번호을 입력해주세요");

  f.phone.focus();

  return false;

 }

 if (!f.email.value) {

  alert("이메일을 입력해주세요");

  f.email.focus();

  return false;

 }

}

//-->

</SCRIPT></p>

<p>

</head></p>

<p><body>

<form name="formmail" method="get" action="/mail/data.php" onSubmit="return chkMailFrm()">

<a name=01></a>   

<table width="0" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td><img src="images/back_1.jpg" width="568" height="19" /></td>

  </tr>

  <tr>

    <td><table width="0" border="0" cellspacing="0" cellpadding="0" >

      <tr>

        <td><img src="images/back_3.jpg" width="21" height="472" /></td>

        <td width="525" align="center">

      

      

 

       

        <table width="100" border="0" cellpadding="0" cellspacing="5">

          <tr>

            <td width="100" align="right"><font color="#663300"><img src="images/form_1.jpg"  /></font></td>

            <td width="500" align="left"><input type="text" style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 350px; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 20px" name="title"

             size="32" /></td>

          </tr>

          <tr>

            <td align="right"><img src="images/form_2.jpg"  /></td>

            <td align="left"><input type="text" style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 350px; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 20px" name="senduser"

             size="32" /></td>

          </tr>

          <tr>

            <td align="right"><img src="images/form_3.jpg"  /></td>

            <td align="left"><input type="text" style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 350px; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 20px" name="phone"

             size="32" /></td>

          </tr>

          <tr>

            <td align="right"><img src="images/form_4.jpg" /></td>

            <td align="left"><input type="text" style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 350px; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 20px" name="email"

             size="32"/ ></></td>

          </tr>

          <tr>

            <td align="center"><font color="#663300"><img src="images/form_5.jpg" /> </font></td>

            <td align="left"><textarea style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 350px; COLOR: #333333; BORDER-BOTTOM: #cccccc 1px solid; HEIGHT: 198px" name="body"

             rows="5" cols="26"></textarea></td>

          </tr>

          <tr align="left">

            <td colspan="2"> </td>

          </tr>

          <tr>

            <td> </td>

            <td  align="right"><input name="submit" type="image" value="신청하기" src="images/ok.jpg"  />

              <a onclick="reset();"><img src="images/can.jpg"  border="0" /></a></td>

          </tr>

        </table></td>

        <td><img src="images/back_4.jpg" width="22" height="472" /></td>

      </tr>

    </table>

    </td>

  </tr>

  <tr>

    <td><img src="images/back_2.jpg" width="568" height="19" /></td>

  </tr>

</table>

</form>

</body>

</html></p>

<p><strong>

 

</strong></p>

<p><?

//보내는 이//받는사람

  $recipient = "메일주소";

//제목 처리

  $subject = '=?UTF-8?B?'.base64_encode($_GET['title']).'?=';

//메일주소

  $mail_from = '=?UTF-8?B?'.base64_encode($_GET['email']).'?=';</p>

<p>//메일내용

  $mail_body = "<table width='600' border='0' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>

        <tr>

          <td width='100' height='30' align='center' bgcolor='#eeeeee'>제목</td>

          <td width='400' bgcolor='#FFFFFF'>". $_GET['title']."</td></tr>".</p>

<p>       " <tr>

          <td width='100' height='30' align='center' bgcolor='#eeeeee'>성함</td>

          <td width='400' bgcolor='#FFFFFF'>". $_GET['senduser']."</td></tr>".  

   

       " <tr>

          <td width='100' height='30' align='center' bgcolor='#eeeeee'>연락처</td>

          <td width='400' bgcolor='#FFFFFF'>". $_GET['phone']."</td></tr>". 

   

       " <tr>

          <td width='100' height='30' align='center' bgcolor='#eeeeee'>이메일</td>

          <td width='400' bgcolor='#FFFFFF'>". $_GET['email']."</td></tr>". 

 

       " <tr>

          <td width='100' height='30' align='center' bgcolor='#eeeeee'>전달사항</td>

          <td width='400' bgcolor='#FFFFFF'>". $_GET['body']."</td></tr>". 

   

      "</table>";</p>

<p> 

//메일 발송처리</p>

<p>  //$header = "From:$subject\n";

  $header = "Content-Type: text/html;charset=UTF-8";

  $header .= "From : mail_from <".$_GET['email'].">\n";</p>

<p>

 

  $email = mail($recipient, $subject, $mail_body, $header);</p>

<p> </p>

<p>  if (!$email)

    echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <script>

         window.alert('메일 발송이 실패하였습니다. ');

         history.go(-1);

         </script>";

  else

    echo "         <script>

         window.alert('메일이 정상적으로 발송되었습니다.');

         history.go(-1);

         </script>";

?></p>

<p> </p>

<p> </p>

<p> </p>

<p><strong>

 

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
6년 전

$header .= "From : mail_from <".$_GET['email'].">\n";

=>

$header .= "From : <".$_GET['email'].">\n";

 

로 변경해 보면 어떨까 싶습니다.

 

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

$ext = "-f ".$_GET['email']; $email = mail($recipient, $subject, $mail_body, $header, $ext);

위처럼 해서 마지막에 $ext를 하나 추가해서 보내 보세요.

https://www.php.net/manual/en/function.mail.php">https://www.php.net/manual/en/function.mail.php

php 버전에 따라서 안 될 수도 있습니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

플래토
6년 전

 $header .= "From : mail_from <".$_GET['email'].">\n";

 

여기가 문제인듯 싶습니다.

</code></p>

<p>$myemail = '내ID@naver.com'; // 변경할 이메일 주소</p>

<p><code>$header</code> <code>.= </code><code>"From : mail_from <"</code><code>.</code><code>$myemail</code><code>.</code><code>">\n"</code><code>;</code></p>

<p><code>

로 변경해서 테스트해보세요

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인