How can I send an automated e-mail to a users entered e-mail address?
I have Xampp, which is a local web server equipped with Apache, and Mercury for mail.
Ideas?
How can I send an automated e-mail to a users entered e-mail address?
I have Xampp, which is a local web server equipped with Apache, and Mercury for mail.
Ideas?
To send email: Look up the mail function.
To schedule a task in linux look up crontab.
To schedule a task in Windows look up task scheduling in the control panel.
And don't use Xampp for production. It's insecure.
Instead of php's mail() function you should use something like http://swiftmailer.org
You can easily do smtp-authentication, encryption, mime-mail, character encoding, batch mailing ...
And you get much more reliable error reporting.
This is not an answer to your question, but could be relevant anyway:
My experience with a local web-server is that the mail will not get to its destination. It depends on your isp, but if you have a changing ip address every time you connect to your isp (dial-up, adsl, cable), your outgoing mail will most likely be rejected by the recipients mail server.
A lot of those ip ranges that isp give their clients are blocked by spam filters.
At least the range I am in is :)
Be careful though, because bad people will write scripts to submit your form with a zillion email addresses and try to send spam. They will also (try) to embed \r\n in the submitted address to write out other content and headers. I do something like this:
function sanitize($s) {
$badheaders = array("/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i");
$s = preg_replace($badheaders, '(spam)', $s);
if (strlen($s) > 2048) {
$s = substr($s, 0, 2048);
$s = $s." (TRUNCATED)";
}
return $s;
}
then I run user inputted strings through sanitize() before calling mail(). YMMV of course.