sendmail を使用して PHP でメールを送信しています。問題は、メール内のデータベースで詳細を取得したいということです。どうやってやるの ?これが私のコードです。
<?php
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "";
$db = "master_inventory";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "SELECT * FROM desktop";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
$to = 'nazasdei@domain.com';
$subject = 'warranty licensed expired';
$message = 'The Following Your Product Expired
Product Code:.$row[Desk_PC_Name]';
$headers = 'From: miloe@gmail.com' . "\r\n" .
'Reply-To: miloe@gmail.com' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
}
if(mail($to, $subject, $message, $headers))
echo "Email sent";
else
echo "Email sending failed";
?>