relay all non-local mail to 1 local address and NOT real destinations
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
relay all non-local mail to 1 local address and NOT real destinations
I'm trying to setup a development environment for our web
application such that all emails are relayed/routed to 1 particular email address instead of their real destination email addresses.
This allows us to make sure the emails were constructed properly, count them for testing the correct number sent, etc.
The main issue is to relay all mails send by the server to one particular email address, where I can check whether the emails where sent properly by the application without reaching their destination. In real I would want the emails to reach their destination, but for testing I cannot allow this.
Thanks for the interest, actually I had tried configuring the virtual table and the local-host-names files, but it failed. The problem is that we have multiple foreign domains (about 3000 email addresses with different domains), so adding those will be a mission. I thought if it was possible to use the "*" character in the virtual table to forward all emails passing through to the test account. Example: *@* testacc@mydomain
The emails of particular interest are the non-local,so we want all emails reaching the server not to leave, but be forwarded to a local user account. All I want is the application to email, then the server avoids sending the messages to the real users until the test is done. No emails should leave the server during test, then when the testing is done we allow the server to send out.
Ok, I see. Yes that would be a pain to add all of those domain names by hand to the virtualtable file.
I just had a really crazy idea, but it might work. Actually I just had two.
1. Are there some emails that are "test" (the 3000) and others that aren't part of the test? If they are ALL going to be in the test app, could you not simply turn off "relaying" on sendmail. Run your test, no emails get sent anywhere, but in /var/log/mail you'd see that indeed all of the emails were sent to sendmail. That would work if the idea is to verify that the application is indeed sending to all 3000 addresses. You could even use awk or something to parse the log file and list / show you all of the emails that didn't get sent during the test.
2. Speaking of awk (this is my second idea), do you happen to have a list of all of the email addresses in a text file? If so, you could probably put together a simple awk script that would parse the list and populate the virtualtable file for you
I know, neither of these is as easy as just "* -> testAccount" but I don't know how to do that with sendmail...maybe someone else will chime in.
Sorry for the late response JimDog, apparently I like the ideas you proposed. The mission is to test my application whether its sending the emails. So I will monitor the /var/logs/maillog to see if those emails passed through. About the second one, I tried manipulating text with the "grep" command, then "awk", but I'm not extremely good on that because its tricky. All I wanted to do was grep a common pattern of domains and make sure they are not repeated. e.g
manqox:~$ less emails.txt |grep .org.za
this would display all patterns with ".org.za" , but it will repeat same domains.The "awk" command could come in here, but I failed to use it.
I hope I tried explaining it out, on the questions, there is an email.txt with a list of all emails registered. Also there are both test emails and real emails sent out.
well. turning off mail to all those people may not be so good.
I would make a test mail for each website or domain....ifyou want to go that far...and then use it to test by sending to your self at yahoo or something. and then send back.
as long as you set up that test the same as you set up the others in that domain, then it should be fine for all of them.
The only other way to easily see if there is an issue is...
check maillog and error logs for anything involving mail errors throughout the entire day, everyday..if you see one, then you know there is a problem.
Also, a catchall for all domains to grab all mail and route to a user that can grab them all (and this will include ALL spam) and then check out the mail file for that one..
It just seems like a crazy thing to test every single mail user... must be something better you can do then do that....
You could send 3000 mails out,...one at a time using a script...to your yahoo account or something...one from each user...and see if you get it..
Thanks for the advice, I would also look at the Catchall suggestion although there maybe spam mail. One could have changed the Java code to email to a new group, the system needs no changes until re-deployed and about 3000 emails already exist on the database.
1. The idea is during testing my application I should add new email addresses and use them,
2. When I send mail then all mail is forwarded to me to establish who could not be receiving the emails from the system.
3. If I send 3000 then receive 2500 email, then I would know 500 emails are not been delivered. Its not like the application sends 3000 emails at once, but its the 3000 emails already in the database with different domains, which make the work tedious.
4. Receiving the emails is the best way I can test because at times you will see contents were delivered as they were sent. Currently I'm using the logs to see which emails are coming through.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.