Answers
Best Answer
Best Answer
Here is a quick script that will help you develop a auto reminder sent to specific emails. If you want to specify time, date, and more then you'll need to do a bit more coding.
Code:
$db = mysql_connect('host','dbuser','dbpass');
mysql_select_db('some_database');
$sql = "SELECT name,email_addr from users";
$rs = mysql_query($sql);
while ($row = mysql_fetch_assoc($rs)) {
$to = "'" . $row['name'] . "' ";
$subject = "RE: The subject";
$message = "Your message goes here";
$headers = 'From: Info@mysite.com' . "rn" .
'Reply-To: Info@mysite.com' . "rn" .
'X-Mailer: AnythingYouWant.0' ;
// Assuming you have a properly setup mail connection at your hosting account
$success = mail($to, $subject, $message, $headers);
// Check $success and process accordingly
}
Code:
$db = mysql_connect('host','dbuser','dbpass');
mysql_select_db('some_database');
$sql = "SELECT name,email_addr from users";
$rs = mysql_query($sql);
while ($row = mysql_fetch_assoc($rs)) {
$to = "'" . $row['name'] . "' ";
$subject = "RE: The subject";
$message = "Your message goes here";
$headers = 'From: Info@mysite.com' . "rn" .
'Reply-To: Info@mysite.com' . "rn" .
'X-Mailer: AnythingYouWant.0' ;
// Assuming you have a properly setup mail connection at your hosting account
$success = mail($to, $subject, $message, $headers);
// Check $success and process accordingly
}
If you are using JSP, the following code can be used as reference:
Import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.activation.*;
public class Mail {
public static void main(String[] args) {
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.xxx.com");
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props);
s.setDebug(true);
MimeMessage message = new MimeMessage(s);
try {
InternetAddress from = new InternetAddress("xxx@xxx.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("xxx@xxx.com");
message.setRecipient(Message.RecipientType.TO, to);
message.setSubject("test");
String content = "Test Content";
message.setContent(content, "text/html;charset=UTF-8");
message.saveChanges();
Transport transport = s.getTransport("smtp");
transport.connect("smtp.xxx.com", "name", "pwd");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
And then use JAVA Time Class to call on
Import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.activation.*;
public class Mail {
public static void main(String[] args) {
Properties props = System.getProperties();
props.setProperty("mail.smtp.host", "smtp.xxx.com");
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props);
s.setDebug(true);
MimeMessage message = new MimeMessage(s);
try {
InternetAddress from = new InternetAddress("xxx@xxx.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("xxx@xxx.com");
message.setRecipient(Message.RecipientType.TO, to);
message.setSubject("test");
String content = "Test Content";
message.setContent(content, "text/html;charset=UTF-8");
message.saveChanges();
Transport transport = s.getTransport("smtp");
transport.connect("smtp.xxx.com", "name", "pwd");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
And then use JAVA Time Class to call on
If you are coding your website with PHP, Autobot's answer would work. I'm confused as your question is lacking important details. So, in the off chance that what you ask is less web development related and more emailing related: There are some email scheduling services (?) might suite your needs: LaterGator and LetterMeLater are a couple.

