ฟังก์ชั่น mail()
ความหมายของฟังก์ชั่นและการใช้งาน
การส่ง mail โดยจะคืนค่า true ถ้าส่ง mail ได้สำเร็จ ด้วยฟังก์ชั่น mail()
รูปแบบการเขียน (Syntax)
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
ตัวอย่างที่ 1
<?php
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");
// Send
mail('[email protected]', 'My Subject', $message);
?>
ตัวอย่างที่ 2
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>