11c0c Collect mails from all servers? - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old April 13th, 2012, 04:35
feralape feralape is offline
Member
 
Join Date: Nov 2008
Posts: 146
Thanks: 2
Thanked 4 Times in 4 Posts
Default Collect mails from all servers?

Here is the situation, I have a handful of FreeBSD servers, most are behind firewalls/nat. I need to capture emails on the servers to monitor for problems.

I'm forwarding all root mail to -> my user@localhost (via /etc/mail/aliases). This works.

Now I would like to forward user@localhost to user@gmail. Basically dump everything there and then I'll sort it out later (I actually pull it down to another server and run procmail on it, but this step is working and not important).

Is there an easy way to do this? Like I said, it's quite a few servers and I'll be adding more, so don't want to have to manually fiddle the knobs on each. A generic solution that works for hosts without real domain names would be best.

I tried adding 'user@gmail.com' to the ~user/.forward but google is rejecting it:

Code:
Apr 12 22:23:07 fire3 sm-mta[84432]: q3D3N7SY084432: from=<myuser@fire3>, size=344, class=0, nrcpts=1, msgid=<201204130
323.q3D3N7N7084431@fire3>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Apr 12 22:23:07 fire3 sendmail[84431]: q3D3N7N7084431: to=root@localhost, ctladdr=myuser (1001/1001), delay=00:00:00, x
delay=00:00:00, mailer=relay, pri=30051, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q3D3N7SY084432 Message accepted for delivery)
Apr 12 22:23:19 fire3 sm-mta[84433]: q3D3N7SY084432: to=myuser@gmail.com, ctladdr=<myuser@fire3> (1001/1001), dela
y=00:00:12, xdelay=00:00:12, mailer=esmtp, pri=30566, relay=alt4.gmail-smtp-in.l.google.com. [173.194.65.26], dsn=4.0.0,
 stat=Deferred: Connection refused by alt4.gmail-smtp-in.l.google.com.
Apr 12 22:33:29 fire3 sm-mta[84463]: q3D3N7SY084432: to=myuser@gmail.com, ctladdr=<myuser@fire3> (1001/1001), dela
y=00:10:22, xdelay=00:00:13, mailer=esmtp, pri=120566, relay=alt4.gmail-smtp-in.l.google.com. [173.194.65.27], dsn=4.0.0
, stat=Deferred: Connection refused by alt4.gmail-smtp-in.l.google.com.

Last edited by DutchDaemon; April 13th, 2012 at 20:56.
Reply With Quote
  #2  
Old April 13th, 2012, 04:49
wblock@'s Avatar
wblock@ wblock@ is offline
Moderator
 
Join Date: Sep 2009
Location: Milky Way galaxy
Posts: 7,701
Thanks: 429
Thanked 1,757 Times in 1,456 Posts
Default

Configure the servers to use the ISP as a smarthost. Then they will be able to send to gmail.
Reply With Quote
  #3  
Old April 13th, 2012, 04:57
kpa kpa is online now
Senior Member
 
Join Date: Jul 2010
Location: People's Technocratic Republic of Finland
Posts: 1,987
Thanks: 44
Thanked 460 Times in 390 Posts
Default

You'll need to do couple of things:

Enable SMART_HOST with smtp.gmail.com as the host and enable TLS/SSL with username/password for outgoing mails, for example:

http://rajasuperman.blogspot.com/200...412436946.html

The page says that sendmail(8) needs to be recompiled to support SSL/TLS but that's no longer true.


Rewrite the sender address (gmail won't accept root@someweirddomain) to myusername@gmail.com using /etc/mail/genericstable, see the sendmail README at /usr/share/sendmail/cf/README
Reply With Quote
  #4  
Old April 13th, 2012, 05:18
feralape feralape is offline
Member
 
Join Date: Nov 2008
Posts: 146
Thanks: 2
Thanked 4 Times in 4 Posts
Default

Wow, thanks guys for the quick response and detailed write ups.

What is your take on this?

http://analysisandreview.com/securit...ail-via-gmail/

Seems like it's a bit easier to set up.

Last edited by DutchDaemon; April 13th, 2012 at 20:57.
Reply With Quote
  #5  
Old April 13th, 2012, 05:24
kpa kpa is online now
Senior Member
 
Join Date: Jul 2010
Location: People's Technocratic Republic of Finland
Posts: 1,987
Thanks: 44
Thanked 460 Times in 390 Posts
Default

Yes, that should work as well. I can't remember exactly but I think you'll be limited to forwarding local (sent from the machine itself) mail only with that setup but it sounds to me that's not going to be a problem?

Edit: There's a chapter in the handbook about outgoing only MTA using mail/ssmtp:
http://www.freebsd.org/doc/en_US.ISO...oing-only.html

Last edited by DutchDaemon; April 13th, 2012 at 20:57.
Reply With Quote
  #6  
Old April 13th, 2012, 06:27
feralape feralape is offline
Member
 
Join Date: Nov 2008
Posts: 146
Thanks: 2
Thanked 4 Times in 4 Posts
Default

thanks.

ssmtp is working for root, but not for 'myuser'.

This works:
Code:
echo "test" | mail -s "test" root
This doesn't:
Code:
echo "test" | mail -s "test" myuser
gmail gets it, but has to 'To:' address as 'myuser@myhost' which gets rejected since it doesn't exist.
How do I rewrite it so 'myuser@myhost' goes 'myuser@gmail.com'?

root@myhost goes to 'myuser@gmail.com' when I set root=myuser@gmail.com in ssmtp.conf

the logs show this:

Code:
Apr 13 00:21:17 fire3 sSMTP[21436]: 235 2.7.0 Accepted
Apr 13 00:21:17 fire3 sSMTP[21436]: MAIL FROM:<myuser@gmail.com>
Apr 13 00:21:17 fire3 sSMTP[21436]: 250 2.1.0 OK hq3sm4718420igc.0
Apr 13 00:21:17 fire3 sSMTP[21436]: RCPT TO:<myuser@fire3>
Apr 13 00:21:17 fire3 sSMTP[21436]: 250 2.1.5 OK hq3sm4718420igc.0
Apr 13 00:21:17 fire3 sSMTP[21436]: DATA
Apr 13 00:21:18 fire3 sSMTP[21436]: 354  Go ahead hq3sm4718420igc.0
Apr 13 00:21:18 fire3 sSMTP[21436]: Received: by myhost (sSMTP sendmail emulation); Fri, 13 Apr 2012 00:21:17 -0500
Apr 13 00:21:18 fire3 sSMTP[21436]: From: "User &" <myuser@gmail.com>
Apr 13 00:21:18 fire3 sSMTP[21436]: Date: Fri, 13 Apr 2012 00:21:17 -0500
Apr 13 00:21:18 fire3 sSMTP[21436]: To: myuser
Apr 13 00:21:18 fire3 sSMTP[21436]: Subject: test 
Apr 13 00:21:18 fire3 sSMTP[21436]:
Apr 13 00:21:18 fire3 sSMTP[21436]: test
Apr 13 00:21:19 fire3 sSMTP[21436]: .
Apr 13 00:21:19 fire3 sSMTP[21436]: 250 2.0.0 OK 1334294479 hq3sm4718420igc.0
Apr 13 00:21:19 fire3 sSMTP[21436]: QUIT
Apr 13 00:21:19 fire3 sSMTP[21436]: 221 2.0.0 closing connection hq3sm4718420igc.0
Apr 13 00:21:19 fire3 sSMTP[21436]: Sent mail for myuser@gmail.com (221 2.0.0 closing connection hq3sm4718420igc.0) u
Reply With Quote
  #7  
Old April 13th, 2012, 21:46
kpa kpa is online now
Senior Member
 
Join Date: Jul 2010
Location: People's Technocratic Republic of Finland
Posts: 1,987
Thanks: 44
Thanked 460 Times in 390 Posts
Default

I think you need something like this in /usr/local/etc/ssmtp/revaliases:

Code:
myuser:myuseratgmail@gmail.com:smtp.gmail.com:587
Or just:
Code:
myuser:myuseratgmail@gmail.com
Reply With Quote
  #8  
Old April 17th, 2012, 09:35
ecazamir ecazamir is offline
Member
 
Join Date: Mar 2009
Posts: 215
Thanks: 5
Thanked 28 Times in 26 Posts
Default

I like aliases. Edit /etc/mail/aliases, put a line "root: youraccount@gmail.com, root", then execute newaliases.
This works for postfix, it should work for sendmail and any other MTA.
__________________
My blog: http://ghid-it.blogspot.com
Other guides: http://sites.google.com/site/ghidit/
Reply With Quote
  #9  
Old April 19th, 2012, 18:35
feralape feralape is offline
Member
 
Join Date: Nov 2008
Posts: 146
Thanks: 2
Thanked 4 Times in 4 Posts
Default

Thanks guys.

I went with SSMTP, once that was set up I just manually set this in the crontabs for most users:

Code:
MAILTO=dumpmailaccount@gmail.com
So far that seems to be collecting most of the mails.

Last edited by DutchDaemon; April 19th, 2012 at 18:51.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Regarding Mails shesjustaglitch General 3 January 19th, 2012 16:53
[Solved] Sent mails, being refused... Seeker Web & Network Services 11 June 3rd, 2010 21:11
Quota for e-mails dennylin93 Web & Network Services 6 July 25th, 2009 00:20
[Solved] How to delete mails? Nokobon General 9 June 6th, 2009 15:18
sendmail collect: (read timeout) xer Web & Network Services 2 May 11th, 2009 19:04


All times are GMT +1. The time now is 16:15.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0