2014-05-13 50 views
-3

php自動發送郵件,並設置?PHP自動從數據庫發送郵件?

我想在一次電子郵件發送自動創建電子郵件和保存數據庫

電子郵件 例如:我在8:00 PM

發送EMAIL1設置(於subject1,MESSAGE1),發送EMAIL2(以,subject2,消息2)....

,因爲我使用mysql數據庫的話,我希望自動發送主題+消息,如果狀態= 0

狀態= 0是沒有發送,狀態= 1是舊的發送。

請幫忙。 謝謝。

+0

http://stackoverflow.com/questions/3368307/how-to-send-emails-via-cron-job-usng-php-mysql – aldanux

+0

這有[點擊這裏]已經回答了檢查[1] [1]:http://stackoverflow.com/questions/3368307/how-to-send-emails-via-cron-job-usng-php- mysql – Sitati

+0

請幫忙,我有列表電子郵件要發送從MySQL。謝謝 – tranchau

回答

0

你可能會需要使用cron作業來訪問一個頁面:

0 20 * * * curl http://yourwebsite.com/emailscript.php 

^打完在0分,20小時(下午8:00),每天的,每週的,每個月。 emailscript.php的

內容:

$to = "[email protected]"; 
$subject = "Cron Job HTML email"; 

$message = " 
<html> 
<head> 
<title>HTML email</title> 
</head> 
<body> 
<p>This email contains HTML Tags and is a test of the cron jobs!</p> 
</body> 
</html> 
"; 

// Always set content-type when sending HTML email 
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

// More headers 
$headers .= 'From: [email protected] <[email protected]>' . "\r\n"; 

mail($to,$subject,$message,$headers); 
+0

請幫助,我有列表電子郵件要發送從MySQL。謝謝 – tranchau

+0

我對你問的是什麼有一個最基本的理解。 – Vigs