Currently i'm building a system (custom CMS) and the requirement is to catch all the emails sent by public to registered email address, and reply via the email address through the system via the registered email as well.
For example:
BUT
i don't know the term of this called. May i know how can i implement it? please advice with some links or keywords. i knew a lot of knowledgebase solution, CRM, project management software integrated through CNAME, changing DNS those stuff, but i got no idea on how. Thanks.
Update
The sample would be something like http://www.cloudmailin.com but what i want is generate from my app and receive the emails from public for my clients.
There are 2 main methods to achieve this
Fetching the email from a mailbox
In this method the email goes to a mailbox and you regularly check for content in this mailbox to process the email. While this generally causes a lag, you can reduce this by running a program regularly and having it poll the mailbox all the time.
Related question
Redirecting mail processing to a program
If your mail server is on unix, you can redirect email processing to a script where you can process the email as you wish
Related question outside SO
Specifically it may be easiest to find a web host that supports procmail scripts. These configuration scripts allow you to redirect email to a PHP program and you can do this as a catchall for all email of a domain. See this example answer
I've done exactly this with cloudmailin -- you just need to set up mail forwarding for all your public addresses to your cloudmailin address. So:
User emails randomly hashed address at, e.g. [email protected]
Mail server at example.com forwards all mail for info
to [email protected]
.
Cloudmailin posts email to your web site at http://example.com/yourwebhook.php
.
Even though all mail is filtering through a single cloudmailin address, cloudmailin will include the original hashed to-address in the fields it posts, so your web site can extract the hash and determine which user is replying. Pseudo-PHP to give you an idea:
<?php /* webhooks.php */
$address = $_POST['to']; // '[email protected]'
$addressParts = explode('@', $address); // array('info+dfj28d', 'example.com')
$userParts = explode('+', $addressParts[0]); // array('info', 'dfj28d');
$hash = $userParts[0]; // 'dfj28d'
?>
In this example I'm using hashes like info+dfj28d
because our mail domain was hosted on gmail, so gmail's username+alias
syntax was an easy way to send all random hashes to the same mailbox. Other mail hosts have similar methods of creating wildcard aliases.
The point is you need both a random component (dfj28d
), and a static component (info
) in the address so your mail server can tell the difference between hashed addresses (anything that includes info
) and regular mail accounts ([email protected]
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With