11c0c
![]() |
|
|
|
|
|||||||
| Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
Configure the servers to use the ISP as a smarthost. Then they will be able to send to gmail.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
thanks.
ssmtp is working for root, but not for 'myuser'. This works: Code:
echo "test" | mail -s "test" root Code:
echo "test" | mail -s "test" myuser 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 |
|
#7
|
|||
|
|||
|
I think you need something like this in /usr/local/etc/ssmtp/revaliases:
Code:
myuser:myuseratgmail@gmail.com:smtp.gmail.com:587 Code:
myuser:myuseratgmail@gmail.com |
|
#8
|
|||
|
|||
|
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/ |
|
#9
|
|||
|
|||
|
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 Last edited by DutchDaemon; April 19th, 2012 at 18:51. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |