|
 |
|
สอบถามการส่งอีเมลล์ โดยเลือกข้อมูลจากฐานข้อมูล และแนบไฟล์ได้ |
|
 |
|
|
 |
 |
|
การเลือกข้อมูลให้เขียน Query เพื่อดึงค่า email มาจากฐานข้อมูลน่ะครับ ส่วนการแนบไฟล์อ่านได้ที่

Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP Sending Email</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
$strTo = $objResult["Email"];
$strSubject = "Test Send Email";
$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]";
$strVar = "My Message";
$strMessage = "
<h1>My Message</h1><br>
<table width='285' border='1'>
<tr>
<td><div align='center'><strong>My Message </strong></div></td>
<td><div align='center'><font color='red'>My Message</font></div></td>
<td><div align='center'><font size='2'>My Message</font></div></td>
</tr>
<tr>
<td><div align='center'>My Message</div></td>
<td><div align='center'>My Message</div></td>
<td><div align='center'>My Message</div></td>
</tr>
<tr>
<td><div align='center'>".$strVar."</div></td>
<td><div align='center'>".$strVar."</div></td>
<td><div align='center'>".$strVar."</div></td>
</tr>
</table>";
@mail($strTo,$strSubject,$strMessage,$strHeader); // @ = No Show Error //
}
?>
</body>
</html>
Go to : PHP Sending Email Attachment Files
|
 |
 |
 |
 |
Date :
2010-11-02 17:42:18 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากค่ะพี่วิน
|
 |
 |
 |
 |
Date :
2010-11-03 11:34:49 |
By :
Ombu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code
<? session_start();?>
<?
include ('../../config/conn.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title></title>
</head>
<body>
<?php
if($_POST) {
include "../../PHPMailer/class.phpmailer.php";
$mailer = new PHPMailer();
$ref_tg_id = $_POST['to'];
$sql = "SELECT DISTINCT(customer_mail) FROM customer where ref_tg_id = '$ref_tg_id'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
while($row = mysql_fetch_array($query)) {
$mailer->AddAddress($row['customer_mail']);
}
if(get_magic_quotes_gpc()) {
foreach($_POST as $key => $value) {
$_POST[$key] = stripslashes($value);
}
}
$mailer->WordWrap = 70;
$mailer->CharSet = "utf-8";
$mailer->IsHTML(true);
$mailer->From = "[email protected]";
$mailer->FromName = iconv("tis-620", "utf-8", $_POST['fromname']);
$mailer->Subject = iconv("tis-620", "utf-8", $_POST['subject']);
$mailer->Body = iconv("tis-620", "utf-8", $_POST['body']);
//ถ้ามีการอัปโหลดไฟล์ขึ้นมาด้วย
if($_FILES) {
@mkdir("upload");
$path = "upload/" . $_FILES['upfile']['name'];
move_uploaded_file($_FILES['upfile']['tmp_name'], $path);
$mailer->AddAttachment($path);
}
if($mailer->Send()) {
echo "Send Mail Completed !!";
} else {
echo "Sent Mail Error !!";
}
}
?>
</body>
</html>
|
ประวัติการแก้ไข 2010-11-03 11:49:48
 |
 |
 |
 |
Date :
2010-11-03 11:39:17 |
By :
Ombu |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|