PHP E-mail Autoresponder...

PHTech

Senior Member
Joined
Aug 21, 2006
Messages
588
Reaction score
0
Location
Witbank
Hi there...

Anybody knows how to create a VERY SIMPLE script to create an Autoresponder via e-mail... Like those websites sending you your details after you have registered...?

Would appreciate the simplest way please..!
 
Easiest "auto responder" would be to set one up in the website Cpanel admin panel or whatever you want to call it. Any mail sent to [email protected] gets message Y set as reply.

By the way it is something totally different to the email you get after registering on a forum for example. This mail is generated by pure php and sendmail :)
So do you want an auto responder or a sendmail php script?
 
OK.... Thanx for the correction over there... What I am looking for is the SENDMAIL script thing... But I am not much of an expert in hand coding, so a bit of explaining can work...???
 
You need to have sendmail setup (postfix, I find, has the best balance between being easy to setup and easy of use). Then you just need to do something like:

Code:
mail($to, $subject, $message, "MIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\nFrom: " . $from . "\n" . $headers)

where $to, $subject and $message should have the obvious values, and $headers contains extra headers you may need.

The "MIME-Version: 1.0..." string, I find, helps the mail get past spam filters. You need the mail to be as compliant as possible.
 
Cool... Thanx fior this one... But do I need to setup any mail client somewhere for it to work. I want to implement it for an Intranet project...
 
As I say, you'd need something like Postfix to send the mail. If I understand correctly, you also want to receive internal mail. For this, you'd need a POP3 server.

PHP's mail function works as follows:

1) You call mail() in your PHP script to send an email
2) PHP interfaces with the Sendmail program using the parameters that you provided when calling mail()
3) Sendmail sends the mail by interfacing with the destination server (not important in your case)

This means the following:
1) You need something, like Postfix, that will act as your mail agent (in place of Sendmail, which is just horrible).
2) You need PHP to be compiled with mail functionality. In most cases, this should be true.
3) You need PHP to know what program it is that you want to use for mail(). This is typically specified in php.ini (can't remember exactly, been a while since I set it up). This is because you might have several different mail agents installed, and then PHP won't know which to use.

And that's it! Once you have a working PHP installation (with mail support) and have configured it to use you mail agent, all you have to do is call mail() and it does its thing! Pretty cool indeed.

If you're having trouble getting your head around this whole mechanism, you'd benefit greatly from:
1) Reading http://communication.howstuffworks.com/email.htm/printable
2) Setting up Postfix (extremely easy) and checking the logs as you make an attempt to get this to work.

Hope this gets you started in the right direction!
 
Top
Sign up to the MyBroadband newsletter
X