|
 |
|
เขียนโปรแกรมส่งเมล์ทำไงคะ เขียนโปรแกรมส่งเมล์ต้อง Set อะไรบ้างคะ ขอเป็นแนวทางหน่อยค่ะ |
|
 |
|
|
 |
 |
|
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body>
<?php
// mail.php - send email using php mail() function
// is_email_valid code take from:
// http://www.phpexamples.net/codeExSnippet-47.html
function is_email_valid($email) {
if(eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $email)) return TRUE;
else return FALSE;
}
$t_email = $_POST['t_email'];
$f_email = $_POST['f_email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$send = $_POST['send'];
if ( $t_email && $f_email && $subject && $message && $send ) {
if (is_email_valid($t_email) && is_email_valid($f_email)) {
echo "Sending email using the following mail() command...<p />";
//function ที่ใช้สำหรับการส่ง mail
echo 'mail( $t_email, $subject, $message, "From: $f_email\r\n")<p />';
echo "And this expands to:<p />";
echo ' mail( '. $t_email .', '. $subject .', '. $message .', "From: '. $f_email .'\r\n");<p />';
mail($t_email, $subject, $message, "From: $f_email\r\n");
} else {
if ( !is_email_valid($t_email) ) {
echo "<b>To</b> email address was <b>invalid</b><br />";
}
if ( !is_email_valid($f_email) ) {
echo "<b>From</B> email address was <b>invalid</b><br />";
}
}
} else {
?>
<form method=post action="mail.php">
<table border=0>
<tr>
<td>To Email Address:</td>
<td><input type="text" name="t_email" value="Valid Email Address"></td>
</tr>
<tr>
<td>From Email Address:</td>
<td><input type="text" name="f_email" value="Valid Email Address"></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" value="Subject Here"></td>
</tr>
<tr>
<td colspan=2>Message:<br /> <textarea cols=28 rows=5 wrap=physical name="message">
Message Here
</textarea>
<p /> </td>
</tr>
<tr>
<td colspan=2><input type="submit" name="send" value="Send Email"> <input name="reset" type="reset" value="Reset Form"></td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>
ตัวอย่างข้างต้น ลองเอาไปศึกษาดูแล้วกันน่ะ ซึ่งมันเป็นโค๊ดที่ผมก๊อบมาอีกที.......
|
 |
 |
 |
 |
Date :
26 ก.ย. 2548 10:18:31 |
By :
top |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|