Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a bit of problem and I am pretty new in this field and I don't know how to set this. I have searched somewhere on the internet how to solve this but I don't really get all this stuff about mailing.

My problem is I have apache2 running localy and when there is error trigger while debbuging application the apache2 sends debugging email onto out common email address. Problem is I am spamming this address with irrelevant data from my localhost. Is it possible to set some kind of filtering or catch for sender or recipient all this emails and maybe redirect them to some other email address?

I am running fedora 18 and apache 2.4. I used in access to set all as REJECT but that again rejects all outgoing emails?

This is example from /var/log/maillig when the error on the application occurs

Jan 31 09:13:21 localhost sendmail[7153]: r0V8DLVw007153: Authentication-Warning: localhost.localdomain: apache set sender to <email_address1> using -f
Jan 31 09:13:21 localhost sendmail[7153]: r0V8DLVw007153: from=<email_address1>, size=1639, class=0, nrcpts=1, msgid=<201301310813.r0V8DLVw007153@localhost.localdomain>, relay=apache@localhost
Jan 31 09:13:21 localhost sendmail[7154]: r0V8DLfZ007154: from=<email_address1>, size=1968, class=0, nrcpts=1, msgid=<201301310813.r0V8DLVw007153@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jan 31 09:13:22 localhost sendmail[7153]: r0V8DLVw007153: to=dev@server.com, ctladdr=email_address1 (48/48), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=31639, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r0V8DLfZ007154 Message accepted for delivery)
Jan 31 09:13:23 localhost sendmail[7156]: STARTTLS=client, relay=mail.server.com., version=TLSv1/SSLv3, verify=FAIL, cipher=AES256-SHA, bits=256/256
Jan 31 09:13:24 localhost sendmail[7156]: r0V8DLfZ007154: to=<dev@server.com>, delay=00:00:03, xdelay=00:00:02, mailer=esmtp, pri=121968, relay=mail.server.com. [62.146.53.91], dsn=2.0.0, stat=Sent (ok 1359620004 qp 7564)
share|improve this question

2 Answers 2

I assume the simple option of changing the email address isn't available to you (it may or may not be the ServerAdmin setting in your httpd.conf).

If you are not using sendmail for anything else you can safely use FEATURE(domainmap) in your .mc:

FEATURE(`domainmap',`server.com',`hash -o /etc/mail/domainmap_server_com')dnl

This feature lets you rewrite recipient addresses on a per-domain basis.

You may need to copy the domainmap.m4 file from the contrib/ directory to the feature/ directory, depending on your installation. You will need to remake your sendmail.cf from the .mc, and restart sendmail, see the Fedora documentation.

Add the address(es) you want to that file /etc/mail/domainmap_server_com :

# domain map file for server.com
dev           other@server.com

The left-hand side contains the local part of @server.com recipient addresses, the right contains the address to rewrite it to. Then build the required hashmap file (sendmail uses this run-time, not the text format):

makemap hash /etc/mail/domainmap_server_com < /etc/mail/domainmap_server_com

Verify with:

echo "3,0 dev@server.com" | sendmail -bt -d0

Notes:

  • this only rewrites the envelope, not the To: header
  • addresses not listed will bounce (550) on your sendmail, so you must add all recipient addresses needed, this is probably what you want
  • it's doing something slightly underhand by rewriting an @server.com address to another @server.com address, make sure not to create loops
  • you'll need to read the domainmap documentation if you ever decide to tell sendmail one of the domains it handles (class w) is server.com. FEATURE(virtusertable) offers similar functionality, and may be more useful if so.
share|improve this answer

Well you can change the recipient address by adding rules in your rule set 0. At the bottom of your /etc/mail/sendmail.mc file add the following lines:

LOCAL_RULE_0
Ruser < @ example . com . > $*     $: newuser < @ newexample . com . > $1

Keep in mind that the left hand side is separated from the right one with tabs and not spaces, so you cannot copy-paste this; type it. After that, you need to regenerate sendmail.cf and restart sendmail. In Debian this is done by running sendmailconfig.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.