สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ตอบกลับโพส
mr_narin
PHP Newbie
PHP Newbie
โพสต์: 1
ลงทะเบียนเมื่อ: 07/12/2010 4:28 pm

php ไม่ส่ง mail รบกวนด้วยครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mr_narin »

โค้ด: เลือกทั้งหมด

<?
	include("back-office/web_db.php");
	include("back-office/config.php");

	if (!(empty($_POST['action'])) && ($_POST['action'] == "send_mail")) {
		$email = '[email protected]';
		//mail($email, "Message: Contact", $_POST['msg'], "From: $_POST['email']");
		echo "<script language='JavaScript' type='text/JavaScript'>  alert ('The message has been sent.');</script>";
	}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-874">
    <title>True Value Thailand - Quality for your home hardware, home improvement and gardening</title>
    <link href="font.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a = document.MM_sr;  for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d = document;  if (d.images) {
    if (!d.MM_p) d.MM_p = new Array();
    var i,j = d.MM_p.length,a = MM_preloadImages.arguments;
	for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
  }
}

function MM_findObj(n,d) { //v4.01
  var p,i,x;  if (!d) d = document;
  if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
    d = parent.frames[n.substring(p + 1)].document;  n = n.substring(0,p);
  }
  if (!(x = d[n]) && d.all) x = d.all[n];  for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
  for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n,d.layers[i].document);
  if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j = 0,x,a = MM_swapImage.arguments; document.MM_sr = new Array;
  for (i = 0; i < (a.length - 2); i += 3) if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
//-->
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function Product(cURL) {
  msg = window.open(cURL,"Product","toolbar=no,directories=no,menubar=no,location=no,scrollbars=no,top=10,left=10,width=520,height=370");
}
function News(cURL) {
  msg = window.open(cURL,"News","toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,top=10,left=10,width=520,height=370");
}
// -->
</script>
<script language="JavaScript">
<!--
function validateEmailv2(email) {
// a very simple email validation checking.
// you can add more complex email checking if it helps.
	if (email.length <= 0) {
		return true;
	}
	var splitted = email.match("^(.+)@(.+)$");
	if (splitted == null) return false;
	if (splitted[1] != null ) {
		var regexp_user=/^\"?[\w-_\.]*\"?$/;
		if(splitted[1].match(regexp_user) == null) return false;
	}
	if (splitted[2] != null) {
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
		if (splitted[2].match(regexp_domain) == null) {
			var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
			if (splitted[2].match(regexp_ip) == null) return false;
		}
		return true;
	}
	return false;
}

function checkform() {
	if (window.document.form1.name.value.length == 0) {
		alert("Name is Required.");
		window.document.form1.name.focus();
		return false;
	}

	else if (window.document.form1.email.value.length == 0) {
		alert("Email is Required.");
		window.document.form1.email.focus();
		return false;
	}

	else if (window.document.form1.msg.value.length == 0) {
		alert("Message is Required.");
		window.document.form1.msg.focus();
		return false;
	}

	else if (window.document.form1.email.value.length != 1) {
		if (!validateEmailv2(window.document.form1.email.value)) {
			var strError = window.document.form1.email.value +": Enter a valid Email address ";
			alert(strError);
			window.document.form1.email.focus();
			return false;
		}
	}

	else return true;
}

function refresh() {
	window.location.reload(false);
}
//-->
</script>

  </head>
  <body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" onLoad="MM_preloadImages('images/menu_over_05.gif','images/menu_over_07.gif','images/menu_over_09.gif','images/menu_over_11.gif','images/menu_over_13.gif','images/menu_over_15.gif','images/menu_over_17.gif','images/menu_over_19.gif')">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center" bgcolor="#C4000C"><table width="770"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td rowspan="4"><img src="images/layout_02.gif" width="183" height="60"></td>
            <td height="5" align="right" valign="top" class="font_copyright"></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="top" class="font_copyright" id="top"><a href="about.php">About us</a>&nbsp; l &nbsp;<a href="contact.php">Contact us</a>&nbsp; l &nbsp;<a href="join.php">Join with us</a></td>
          </tr>
                   <tr>
            <td height="25" align="right" valign="bottom" class="font_copyright" id="top">
<?
if (!(empty($_SESSION["language"])) && ($_SESSION["language"] == "eng")) {
	echo "<a href='?lang=THA'>Thai</a>&nbsp; l &nbsp;English";
} else {
	echo "Thai&nbsp; l &nbsp;<a href='?lang=ENG'>English</a>";
}
?>
            </td>
          </tr>
          <tr>
            <td height="5" align="right" valign="top" class="font_copyright"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center" bgcolor="#CDCDCD"><table width="770" border="0" cellspacing="0" cellpadding="0">
          <tr align="center">
            <td width="40">&nbsp;</td>
            <td><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image25','','images/menu_over_05.gif',1)"><img src="images/menu_05.gif" name="Image25" width="30" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="arrival.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image26','','images/menu_over_07.gif',1)"><img src="images/menu_07.gif" name="Image26" height=24 width=67 border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="promotion.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image27','','images/menu_over_09.gif',1)"><img src="images/menu_09.gif" name="Image27" width="53" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="product_type.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image29','','images/menu_over_13.gif',1)"><img src="images/menu_13.gif" name="Image29" width="77" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="tips.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image31','','images/menu_over_17.gif',1)"><img src="images/menu_17.gif" name="Image31" width="21" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="diy.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image32','','images/menu_over_19.gif',1)"><img src="images/menu_19.gif" name="Image32" width="27" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="member_privilege.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image28','','images/menu_over_11.gif',1)"><img src="images/menu_11.gif" name="Image28" width="43" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
            <td><a href="location.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image30','','images/menu_over_15.gif',1)"><img src="images/menu_15.gif" name="Image30" width="75" height="24" border="0"></a></td>
            <td width="40">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center" bgcolor="#E6E6E6"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="770" height="135">
          <param name="movie" value="images/demo1.swf">
          <param name=quality value=high>
          <embed src="images/demo1.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="770" height="135"></embed>
        </object></td>
      </tr>
      <tr>
        <td align="center"><table width="770"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="5" colspan="2" valign="top"></td>
          </tr>
          <tr>
            <td width="190" valign="top"><img src="images/pic_l_c.jpg" width="190" height="445"></td>
            <td width="580" valign="top"><table width="580" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right" bgcolor="#CDCDCD"><img src="images/t_contact.gif" width="168" height="44"></td>
              </tr>
              <tr>
                <td valign="top"><table width="505" border="0" align="center" cellpadding="0" cellspacing="0" class="font">
                  <tr>
                    <td height="25">&nbsp;</td>
                  </tr>
                  <tr>
                    <td>
<?
	$query = "select * from contact_us where active_flg='Y' order by id";
	$str = data_row($query,"front_contact");
	echo $str;
?>
<?
					$ws_mail=@mail($email, "Message: Contact From Web", $_POST['msg'], $_POST['email']);
?>
                    </td>
                  </tr>
                  <tr>
                    <td height="30">&nbsp;</td>
                  </tr>
                  <tr>
                    <td><form name="form1" method="post" action="contact.php" onSubmit="return checkform();" >
                      <table width="60%"  border="1" align="center" cellpadding="0" cellspacing="2" bordercolor="#CCCCCC" class="font">
                        <tr bordercolor="#FFFFFF">
                          <td height="20" colspan="2" align="center" bgcolor="#C4000C" class="font_copyright"><b><? if (!(empty($_SESSION["language"])) && ($_SESSION["language"] == "eng")) { echo "Send message to True Value"; } else { echo "ส่งข้อความถึง True Value"; } ?></b></td>
                        </tr>
                        <tr valign="top" bordercolor="#FFFFFF">
                          <td width="34%" align="right"><b><? if (!(empty($_SESSION["language"])) && ($_SESSION["language"] == "eng")) { echo "Name :"; } else { echo "ชื่อ :"; } ?></b></td>
                          <td width="66%"><span class="font2">
                            <input name="name" type="text" class="textbox1" id="name">
                          </span></td>
                        </tr>
                        <tr valign="top" bordercolor="#FFFFFF">
                          <td align="right"><b><? if (!(empty($_SESSION["language"])) && ($_SESSION["language"] == "eng")) { echo "E-mail :"; } else { echo "อีเมล์ :"; } ?></b></td>
                          <td><span class="font2">
                            <input name="email" type="text" class="textbox1" id="email">
                          </span></td>
                        </tr>
                        <tr valign="top" bordercolor="#FFFFFF">
                          <td align="right"><b><? if (!(empty($_SESSION["language"])) && ($_SESSION["language"] == "eng")) { echo "Message :"; } else { echo "ข้อความ :"; } ?></b></td>
                          <td><span class="font2">
                            <textarea name="msg" class="textbox_area" id="msg"></textarea>
                          </span></td>
                        </tr>
                        <tr valign="top" bordercolor="#FFFFFF">
                          <td align="right"></td>
                          <td width="120" align="center">
                            <input name="Submit" type="submit" class="button" value="Submit">
                          </td>
                        </tr>
                        <tr valign="top" bordercolor="#FFFFFF">
                          <td height="5" colspan="2" align="right"></td>
                        </tr>
                      </table>
                      <input name="action" type="hidden" id="action" value="send_mail">
                    </form></td>
				  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>

                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td colspan="2" valign="top">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="10" align="center" bgcolor="#CDCDCD">&nbsp;</td>
      </tr>
      <tr>
        <td height="25" align="center" bgcolor="#C4000C" class="font_copyright">Copyright &copy; 2006 True Value Home Improvement Co.,Ltd. All Rights Reserved.</td>
      </tr>
    </table>

  </body>
</html>
รบกวนถามว่าทำไม มันส่ง Email มาให้ครับ
ภาพประจำตัวสมาชิก
imsn
PHP Super Member
PHP Super Member
โพสต์: 375
ลงทะเบียนเมื่อ: 07/05/2010 12:58 pm
ติดต่อ:

Re: php ไม่ส่ง mail รบกวนด้วยครับ

โพสต์ที่ยังไม่ได้อ่าน โดย imsn »

งงกะปัญหา ตกลงส่งได้หรือส่งไม่ได้ครับเนี่ย
ถ้าส่งไม่ได้ เมลเซฟเวอร์ ใช้งานได้่หรือเปล่า
ช่วยตอบเพราะอยากโปรโหมทเว็บ คิคิคลิกเลย
หาเพื่อนฝรั่งคุย M ...
HBme1551
PHP Newbie
PHP Newbie
โพสต์: 1
ลงทะเบียนเมื่อ: 11/12/2010 11:50 pm
ติดต่อ:

Re: php ไม่ส่ง mail รบกวนด้วยครับ

โพสต์ที่ยังไม่ได้อ่าน โดย HBme1551 »

มี error อะไรขึ้นมั้ยล่ะครับ copy paste error มาดูหน่อย
ตอบกลับโพส

ย้อนกลับไปยัง “Programming - PHP”



ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Amazon [Bot] และบุคลทั่วไป 126