Search code examples
phpemailpostfix-mtaforwarding

Automatically Create Email


First of, let me just say that I know similar questions have been asked

But, there are problems with both questions. Question one has only one answer (which isn't helpful) and question two needs to work with Google Enterprise.

I have a LAMP stack hosted on Linode which hosts multiple sites each with a separate file in the sites-available folder. I have a specific domain which we will call myawesomedomain.com. Now, myawesomedomain.com has nothing in it right now and will not have any proper, full-fledged site. Only a simple form. The fields will consist of:

  • Username
  • Email Address
  • Password

Here's what I want. Whenever a user signs up, an email is automatically created with the username [email protected]. From that point on, whenever email is sent to [email protected], the email is automatically forwarded to the email the user signed up with so that the email is never stored on my server (and therefore does not take up space).

So, my essential questions are:

  • How do I automatically create email addresses from PHP
  • How can I have the emails automatically forwarded to another email address in a MySQL database and not stored on my server.
  • What mail server should I be using and how should I set it up so it doesn't interfere with the rest of my sites.
  • Is there anyway that a lack of spam and virus filtering could effect me. As in, if a hacker sends a PHP file to [email protected], is there any way that my server could be affected.
  • Whatever else you feel is needed.

I've heard of Postfix but I don't know much about mail servers...

Sorry for the long(?) question and thank you in advance.

edit

Should I put this on ServerFault instead?


Solution

  • The "creating an email alias from php"-part is not a problem. If you're running postfix as a mail server it's as simple as inserting a row into a mysql table.

    INSERT INTO myaliastable (pattern, alias) VALUES ("[email protected]","[email protected]")
    

    see:

    BUT: creating a forwarder service like this comes with a lot of problems you should be aware of:

    • you MUST verify the target email adress before you enable that forwarder(send message, have the recipient click on a link) or spammers will signup accounts and use your system as open relay
    • you MUST run a very good spamfilter... forwarding spam is no different from sending spam and will get your server blacklisted
    • if a target server starts rejecting your forwarder for any reason you will be sending backscatter which again can get your server blacklisted
    • if the sender domain uses SPF records and the target of the forwarder checks SPF, forwarded mail will be rejected. you could add SRS rewrites, which unfortunately is not that simple in postfix

    since you state you don't know much about mailservers I would strongly advise to read up on them first, check out best practices on spam prevention and then tackle this project again.