How can I get administrative email delivered to a Gmail account?

1

For years and years, I've been running my own email server on my home network. Thanks to getting a Nexus 4, I've finally switched everything over to Google, and decommissioned my email server. Now I'm having trouble getting administrative emails (think logwatch, RAID health checks, and the like) delivered out to my Google account.

I have a single internal relay which bounces email out to the world through Comcast's SMTP relay. So I can send email to my account on Gmail, but it will all look like it came from a single address. What I can't seem to sort out is a way to tell which machine the email came from. I have a "proper" network at my house, with an internal domain name and name server. I'd like to be able to see email come into my Gmail account with a {user}@{machine}.{domain} address, but Comcast won't deliver mail with my a local machine + domain name. Failing this, I tried using {machine}@{domain}, but this was also failing with my internal domain name.

I can fake mail to look like it's coming from my actual, real domain, but I was still losing the machine information.

I suppose more options open up if I use my real Gmail credentials, send straight to Google's SMTP server(s), and bypass Comcast's? I'd probably have the same trouble with my internal domain with their servers, though.

I was fooling with nullmailer, ssmtp, and postfix. I know I could work out the simplest working solution through trial and error, but I also know that will take many more hours of screwing around. Someone's bound to have sorted out something clever for this, but I can't seem to find anything through Google. This is probably a dupe, but I couldn't find anything even close on SuperUser or ServerFault.

Maybe it's time to take out another real domain? I'm pretty partial to this one. Or maybe I could use my DyDNS name internally? Comcast and/or Google may respect that one.

David Krider

Posted 2013-02-10T16:10:56.053

Reputation: 245

Why don't you add the necessary information to the subject line? – terdon – 2013-02-10T16:16:24.957

Sorry, but I don't understand what you want me to add. – David Krider – 2013-02-10T16:37:14.283

Well, the point here is to have emails delivered to your gmail address with specific information encoded in the From line. You want to know which machine/user sent the mail and would like that information to be user@machine. Can't you get the same information by having each machine send mails with a specific subject line? – terdon – 2013-02-10T16:41:56.883

That's a good enough idea to warrant an actual answer. (I thought you meant the subject of this post on superuser.com!) Postfix could probably rewrite the subject lines somehow... – David Krider – 2013-02-10T23:05:01.600

Answers

1

Another option might be to tweak the To: address using extended addressing. In an email address, Gmail ignores everything after a plus sign, so myname@gmail.com, myname+todo@gmail.com and myname+someotherstring@gmail.com will all get delivered to myname@gmail.com.

This is great for filter targets. For instance, I have a filter which automatically adds a star to anything from myname+followup@gmail.com.

So perhaps you can generate addresses like yourname+machine.domain@gmail.com and then filter accordingly.

ale

Posted 2013-02-10T16:10:56.053

Reputation: 3 159

I like this idea for determining which machine sent the message, but I still have a problem with sending the mail looking like it comes from my internal domain. So this idea could save me the trouble of changing the Subject lines, but I still have to masquerade the domain somehow. Unfortunately, it would seem that the "masquerade" Postfix directive only gets rid of the hostname from the FQDN. I'm having trouble configuring something stronger. – David Krider – 2013-02-11T17:46:49.940

I have it all setup to masquerade my internal machines to my single domain name, then use smtp_generic_maps to rewrite any addresses it gets to a dynamic (but still real) domain name I use, then send to a "plus" address in the real world. – David Krider – 2013-02-13T04:16:56.127

2

Here you go then, comment as an answer.

In your place I would try and modify whatever program/script/service is sending the mails out to include the user and machine information in the subject line of the email. That should be much easier to set up and is equally amenable to gmail filters and labels and the like to allow for organization.

If you give some more information on the specific services that are sending the emails I should be able to help with the details.

terdon

Posted 2013-02-10T16:10:56.053

Reputation: 45 216

Looks like you can rewrite Subject lines through Postfix's "header_checks" directive, and you can change the From addresses through "smtp_generic_maps". I'm still trying to get these configured correctly. – David Krider – 2013-02-11T17:44:34.450