PHP sending emails through random email accounts - php

I'm working on a website that allows you to send emails without registering, and without specifying a sender. You enter the recipient's address, subject, body and send. My problem is sending the message. What I'm trying to achieve:
User clicked send -> Subject,recipient,body sent to PHP -> Server validates the information -> Server creates a random email account -> Server sends the email through the random account created -> Server deletes the account
I'm stuck at the random email account creation step. How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
I googl'd the hell out of this issue and I can't find an answer.
Thanks!
BTW
I'm using Apache to "host" on my own Ubuntu

How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
The way to create E-Mail accounts varies wildly from server software to server software, and is usually not possible from within PHP.
Depending on your server's configuration, though, that might not be necessary: If you set up a catch all address for a domain, many server configurations will allow you to send out mails from any E-Mail on that domain (e.g. 123456789#example.com). Any responses will then go to that catch-all mailbox, the contents of which you will probably want to discard.
You have to realize, though, that this is exactly how spam providers operate. Extreme caution is advised if you don't want to end up on all sorts of spam blacklists.

I don't believe you can create accounts or email accounts on a server, using PHP, as this supersedes PHP's permission level. Sending emails this way is a good way to get your server banned, FYI. Also, if you insist on sending emails like this, why not just specify a dummy From: email address? It would essentially be the same thing as creating a dummy account anyhow.
You may also want to use the -f switch, for PHP's mail(). See php.net/manual/en/function.mail.php

Related

How can my users answer to one email and that goes to user account on website?

Ok, so here's a difficult question for me.
I have searched on Google for some solutions but I couldn't yet make it clear on my mind.
Do you know some way of sending a message through the website "internal messaging system" (it's working ok) and then (this is the difficult part), just as it happens with eBay or Freelancer or many others, if user answers to that message on his email box, that can go to other user website account?
How can I be able to do that?
Website is in PHP and I am using phpmailer and my server SMTP credentials to send emails.
I imagine it's probably needed some POP configurations in order to receive the emails and some way to create an individual and unique email address so when people answers, it can go directly to that user.
Btw, website is www.mf.pt.la
I understand that you don't want the email to end up in mailbox, but in database of your web application. This usually involves forwarding all email to some mailbox or matching a patern to an executable script. You have to consult your smtp server documentation, but it might be as simle as creating .forward file in mailboxes account home directory with this content:
|/path/to/executable/script
script will receive the email, including all headers on stdin.
Now you need a way to identify, who should receive the message.
If you can forward email based on patern, you can place some identifier into the email address, this is what facebook does.
Or you can look for In-Reply-To email header, there you will find Message-ID of the email you send to the user. But sure, you either have to set it or get the autogenerated from phpmailer. Again, consult the manual.
Then there will be the most difficult part, extract the message itself from the email body :)
If it's not possible to forward incoming emails in your case, you might still have luck with cron job executing script that will fetch new emails from POP3 (or IMAP) account.

How can one resend a received email as totally NEW email? So no forwarding or re-directs

This has been a massive headache. We use Ning as a our platform for an arts event project. We want to ask our audience to upload photos to our website via an email address. The only issue is that Ning only will give us ridiculous email addresses for this purpose... such as photos34628234896#ourwebsite.com That hardly sticks in the mind!
So I thought, lets just forward emails from an easy to remember email address to the Ning's crazy one... BUT Ning doesn't allow any emails to upload photos if they are detected as being forwarded or redirected. I guess that detection is done through the email header.
So that is why I need a way to redirect an email to another address without that being reflected in the header info in the email. I thought perhaps Outlook receiving the emails from the easy to remember email address, then somehow resending them with a fresh clean header may be the answer? I can code in PHP, and run a home headerless ubuntu server on a domestic internet connection too if that may provide a better answer?
Any thoughts how I could achieve this goal?
If you can forward the email to your server you can have it piped to PHP which can then resend the email for you with whatever email address you wish to be displayed. Just make sure you have things like DomainKeys and SPF records set up for that server or else your chances of the mail being seen as spam will increase.
If you are using an Exchange server, you can use Transport rules to redirect the message, which will pass most forwarding checks. If it does indeed change the headers or something else, you can use the same ruleset to remove or modify them. Most MTAs(Mail Transport) will allow the same sort of functions, but it really depends on which one you use. Postfix is quite flexible.
The changes will be made in
Exchange Management Console
Origanization Configuration
Hub Transport
Transport Rules
Also, and maybe easier, you could simply try to add a secondary delivery address, in the mail flow settings for the fictional user you assign to receive the emails. This would be done in the user properties. Server level forwarding amy not trigger the forwarding blocks that you are encountering, as client forwarding does not work the in entirely the same way. Many clients send the email again, but the server redirects it.
Exchange Management Console
Recipient Configuration
Mailbox
Properties, Mail Flow Settings.
You would enable forwarding in Delivery Options.
Sorry, just noticed that you are using ubuntu, you can simply have postfix redirect the email for you, you will use Postfix Virtual Alias Maps...
Here is a link that describes it perfectly...
http://www.cyberciti.biz/faq/linux-unix-bsd-postfix-forward-email-to-another-account/

Automatically Create Email

First of, let me just say that I know similar questions have been asked
Here
and here
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 username#myawesomedomain.com. From that point on, whenever email is sent to username#myawesomedomain.com, 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 username#myawesomedomain.com, 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?
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 ("john#myawesomedomain.com","john#example.net")
see:
http://www.postfix.org/MYSQL_README.html
http://www.postfix.org/postconf.5.html#virtual_alias_maps
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.

Create a random disposable mail receiver

I need to create random e-mail addresses that possess the role of receivers. Though these addresses should not be in any case real e-mails. I know that this kind of problem could easily be solved by creating something like Random_root#dummy_host.com . But the real deal is that there's a case my CMS will notify via e-mail these accounts, and so in this case the server will have a re-bounce mail traffic or even worse the host could be black-listed as spam.
I am thinking a mail server that dispose any kind of non existed mail address at its host but I can't find any applicable.
Thanks in advance!
Though not a PHP solution there is a web based service that runs off an API you can use, take a look at http://mailgun.net/
Again not a direct PHP solution but http://cloudmailin.com will allow you to send to any email address at your domain, you can then use a 403 status in your app to reject email to anything you're not expecting and the mail server will actually refuse the message.

Routing email from a desktop email client to php?

Lets take a look at the following scenario:
I have a websitesite, site.com. One customer support tech guy has an email account on it: techguy#site.com. Customers send messages to that email, tech guy replies via that email. They are both using desktop email clients (thunderbird, outlook...).
What I know is: using php to read incoming mail from customers
What I want to know is: how to use php to read outgoing mail that the tech guy is sending from his client via smtp, imap..
This would be used for archiving conversations between techs and customers without forcing them to use some php app on the site to send emails (I want them to use desktop clients).
I dont know much about email protocols, but I have plenty of experience in php. Im guessing that the email daemon could be setup to call a php script every time it recieves an outgoing email or something like that. Is there any way that this can be done?
The way how some products on the market are doing it is by requiring the user to install a plugin on his/her email client. Using this method doesn't matter what smtp server is used, the mails will be logged using the plugin.
Another way(this is just an idea) is to "force" the tech guy to use your smtp server so you can access the logs and see who sent mails and who is the receiver(accessing the logs using php)
It would be much easier to have a separate email address for logging purposes and simply keep it in the cc or bcc field for all communication between customer support and clients.
since you can have php interpret the emails, the best thing to do is have a dedicated email address that gets piped to a script (i know this is easy to set up cpanel)
you have the client email support#domain.com which gets piped to the script - do what you want with it there.
then you have the script email back out to bob#domain.com with a from address as support-reply#domain.com - which is also piped to a script
when he replies to that, it goes to support-reply#domain.com which goes to a script, which in turn you would process, then forward back out to the client#google.com with a return address of support#domain.com
i think amazon uses a similar technique so that people can email each other back and forth, but they create coded email addresses and have a database to keep track of who they are going to and coming from.

Categories