1

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?

6 Answers 6

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1

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 :)

Comments

1

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.

Comments

0

php.net/mail:

mail($to, $subject, $messge);

Comments

0

You can use phpmailer to send mail via SMTP protocol , this library is pretty good ! ( Wordpress CMS use it ! )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.