Is it possible to create a catch-all email using postfix which accepts any email address and sends an email to an external address? - linux

Some background and my challenge:
Background
I am using Magento 2.x using a virtual machine set-up which runs on Ubuntu 16.04
Challenge
My goal is to be able to test emails sent to me from the Magento application. In an ideal situation, I would not use an extension or third-party service (although a third-party SMTP server on the linux box could work).
To achieve my goal, I need to be able to register as a customer in the Magento application with any email address (fake or real) and have the email sent to the same external email address, no matter what.
What I've done so far
I've installed postfix
I've installed Magento using luma.com as the domain (and set up my hosts file accordingly on my host machine, etc.)
I've created a linux user account called "contact"
I've configured inet_interfaces in /etc/postfix/main.cf as loopback-only
I've set mydestination to $myhostname, localhost.$mydomain, $mydomain
I've configured Magento to send its store emails from contact#luma.com
I've set up an aliases file as the following:
postmaster: root
root: contact
contact: me#gmail.com
Then I ran newaliases As far as I recall, email sends fine with this setup. Hooray!
Next, the catch-all part. For this, I've tried loads of things, and none seem to work. From the reading I've done, I've tried the following:
In /etc/postfix/main.cf, I added the following:
virtual_alias_domains = luma.com
virtual_alias_maps = hash:/etc/postfix/virtual
Next, in /etc/postfix/virtual, I encountered my first problem. As far as I understand from the reading I've done, I'm supposed to use something like:
#example.com contact
This step apparently ensures that any email sent via postfix (e.g. from the Magento application) which uses an #example.com email address would be routed to the contact linux user I created above. Then, my thinking was that the system would use the alias I set up to ultimately send out that email from contact#luma.com (via the settings in Magento) through to the external address I set up in the aliases file. This approach would theoretically allow a user to register for an account with Magento using, say, joe#example.com, and then send the associated Welcome email to my external email address.
The issue with this is that I need the system to do this for any email, not just for emails ending in #example.com
Just for sake of completeness, I'll say that before asking this question, I was most recently researching how to achieve this part of the challenge using pcre tables. I've also tried configuring something using luser_relay, but both of these things are over my head at this point, so I'm lost.
My hope is that someone can offer some guidance as to whether I'm on the right path, where I may have missed something, and ultimately, offer some advice on whether my challenge can be solved and how I might go about solving it.
Thanks for reading.

Related

Setting up simple web application service and testing - Linux debian 10

I am doing my assignment given by the lecturer. On the title stated, my idea is about setting up a mail server on the server and we can send the email from the client, all the email is stored in the server virtual machine. Do my idea is correct on this title stated or any recommendations?
Sending mail is not that hard, especially just using (E)SMTP, tcp
text dialogs. Or you can use Linux mail commands.
Storing mail, either locally or accessing mail on a pop or imap server, poses
another set of challenges.
And of course, you need the HTML web pages as well as the services.
Attaching files can be another challenge, both uploading the files
and encoding them for inclusion in the mail.
JAVAScript can make some usual features of email clients easier, like sorting a list of emails in a folder or from a search by a column ascending or descending.
Searching email is an even bigger challenge!

How to check a email in linux server automatically?

I have a Ubuntu 14 server, I have to assign a email account to this server, when some person write a email to this account, the server have to open this mail automatically, and check if there are a specific information, if yes some thing happen.
I suppose that the email are stored in a data base o something like that, but I not have any idea how to start.
Any Idea
First you should get confident how mail systems work in general on linux machines. A good start would be to dig into the linux documentation project, particularly the linux electronic mail administrator HOWTO, chapter 3 (how electronic mail works): http://www.tldp.org/HOWTO/Mail-Administrator-HOWTO.html#toc3
Then, you can decide to which extent you want to set up your email account on the ubuntu server (full smtp server, only mail client etc).
As #arkascha mentions in his comment, the least painful way would be to use an existing mail server and fetch mail from there. With scripts, appropriate actions can be taken once a mail has been received.
If I have correctly understood your question, what you need is a mail alias to a command.
The following may depend on the actual mail server that you use, at least it is relevant for good old sendmail, and postfix. The mail system can use an alias database (normally the file /etc/aliases) but can be hashed into a binary version. This files can contains plain aliase that simply redirect a mail address to other mail addresses, and can also contain file aliases (the mail is appended to a local file) and program aliases.
In this last case (lines are like local_address: | /path/to/program), the program is started for each mail, and it receives the message through its standard input. Read the manual for your mail server for more detailed instructions.

Postfix cannot send email to own domain name from VPS

We had a shared hosting for, let's say myndd.com. then we migrated to a VPS
I installed postfix and I'm able to send emails to everyone except addresses from my own domain.
The hosting company told me it is normal because the MX zone is managed my mail01.myndd.com, so I have to forward emails to mail01.myndd.com
Problem is if I go to /etc/postfix/main.cf and add relayhost=mail01.myndd.com I cannot send emails to anyone anymore.
A temporary solution could be to forward our email to some others in another account like for example forward example1#myndd.com to example1#myotherndd.com . It will help but I find it a bit dirty.
Any idea how I can handle this problem?
Thanks !
My Bad. I found a way using transport.
I had to add the following line into /etc/postfix/transport:
myndd.com smtp:mail01.myndd.com
Tehn I launched
=> postmap /etc/postfix/transport.
Then I added the line transport_maps = hash:/etc/postfix/transport into /etc/postfix/main.cf
then
=> run postfix reload
So I can send emails in #myndd.com

Best Way To Receive Email Website

I am developing a website -- in the prototype stage, soon to be alpha. I will provide an email address to each account that allows the user to deposit stuff -- not a real email account, just an endpoint for sending things to the site. Many sites provide this kind of service nowadays. I think the first one I saw was Photobucket, which let's you send photos as email attachments.
My question is, what is the best way to implement this kind of service?
In my prototype, I have written a POP3 client which fetches all newly delivered mail (currently from a test Gmail account). My service processes each new mail and attachments, and immediately removes it from the email server.
I could certainly outsource to an email service with POP3 and be done with it. The problem is cost. Most services I have seen provide much more than I need, and they charge per account. I expect to have many accounts and low traffic volume.
So I'm leaning towards hosting email receipt myself. I am open to Windows or Linux. The code that processes incoming emails runs on Windows, but I have other services running on Linux. I have seen a number of open source and free email servers, such as hMailServer and MailEnable (Windows) and qmail, Postfix and exim (Linux).
I guess I have a slight preference towards Linux because of lower hosting costs, but if a Windows service can provide cleaner integration, that might be worth it. As far as features, I would like to have some spam filtering, but it's is not a huge priority. POP3 is adequate for retrieval, but a more direct API would be nice. I will need some kind of API for programmatically provisioning new accounts.
All suggestions are appreciated. Do you know how others implement this kind of service?
UPDATE: I ended up using hMailServer, which is a free mail server that runs on Windows. It seems to be quite mature and robust. It has a COM interop library which makes accessing emails, accounts, etc. from my .NET server app very easy indeed.
If you're going the host-your-own-email-server route, I would probably just use POSTFIX and pipe all your email to a PHP script, which processes the email.
Here's a quick'n dirty tutorial on setting up the email pipe if you're using cPanel:
http://kb.siteground.com/article/How_to_pipe_an_email_to_a_PHP_script.html
If not, here's how to do it:
http://answers.google.com/answers/threadview?id=562518
The bottom line is, you need to have an open SMTP connection to accept email. If you have your own server, then you can install a SMTP server on the machine. Usually, you have filesystem access to the location the email files are placed. Be sure to select a SMTP server that allows this, and that the email are in a format that you can parse.
Then, you can just monitor the file location for incoming emails.
If you can't pipe your emails (using the Postfix suggestion), and you don't have your own server (for example, on a shared hosting plan), then you will need to query a POP3 or IMAP mailbox server for your emails, and parse them accordingly.
I wanted to get emails in real time so I worked out my own solution with google app engine. I basically made a small dedicated google app engine app to receive and POST emails to my main site. That way I could avoid having to set up an email server.
You can check out Emailization (a little weekend project I did to do it for you), or you this small GAE app that should do the trick.
I kinda explained it more on another question.
Hope that helps!

Monotouch: any ideas why sending mail is sporadic?

This is the code: d59516457">http://monobin.com/_d59516457
These are the results when using Debug|iPhone (Debug|Simulator works fine):
When the "From" is set to GMail, I can only send to a GMail account.
When the "From" is set to my ISP, I can send to myself (at the ISP) and GMail, but NOT to another of my email addresses not connected to the ISP. (it's to an address for one of my websites, which is then forwarded to my ISP).
Any ideas why this is so flakey? I thought at first it was the ISP, but now I'm not so sure.. is there a way to "trace" any of hops?
I'm concerned that if I submit it to the app store, a user will have the same problem as this, and I don't want a bad rep for the app. On the other hand, because it works, sometime and not others, maybe I could hope it's my phone?
if you want you can use http://testflightapp.com/ so you get some beta testers doing Ad-Hoc releases of your app (you choose who you want to invite), if you want so I can send you an invite I would be more than glad to help you to test your app :) email me if you want the invite, my email its on my profile
About the solution, you can check if you have a webmail based interface that you can view on your computer, the email that you sent from the iPhone must be on the sent items folder, if the email and the attachment are there you can be sure that your application is delivering correctly you email to the SMTP server so the problem resides somewhere else...
Also make sure your that your smtp server is not blacklisted as a SPAM server even more if your smtp server relies on shared enviroment like Hostgator shared plans etc
Alex

Resources