Rewriting FAX= Recepient Address with Sendmail

Posted on in System Administration

Previously, I mentioned that I was unable to remove the FAX= portion of the string produced by Cisco's $s$ (or $d$) macro in a T.37 store and forward fax configuration. That's still the case. I have found no way of doing this inside IOS. If it's possible, I've overlooked it or it's a hidden command. What I have done, is use Sendmail on a Linux server to rewrite the recipient address. The impetus for this was a recent conversion to Google Apps. Unfortunately, Google does not permit addresses that contain an = sign.

<!--more-->

The idea is to accept emails from a Cisco AS5300, rewrite the address, and then forward the email on. The following can be placed at the bottom of your sendmail.mc configuration file:

LOCAL_CONFIG
Kfax regex -s1 ^FAX=(.+)$$
LOCAL_RULE_0
R$+ < @ $=R . > $: $(fax $1 $: $1 $) < @ $2 . > 
R$+ < @ $=w . > $: $(fax $1 $: $1 $) < @ $2 . >

The above configuration tells Sendmail to check relay domains (class{R}) and local domains (class{w}) for addresses beginning with the string FAX=. If you are not using both of these, feel free to remove the unused line.

After rebuilding your sendmail.cf configuration file, you can test your changes with the sendmail -bt command:

$ echo "3,0 FAX=8008675309@slaptijack.com" | sendmail -bt
canonify           input: FAX=8008675309 @ slaptijack . com
Canonify2          input: FAX=8008675309 < @ slaptijack . com >
Canonify2        returns: FAX=8008675309 < @ slaptijack . com . >
canonify         returns: FAX=8008675309 < @ slaptijack . com . >
parse              input: FAX=8008675309 < @ slaptijack . com . >
Parse0             input: FAX=8008675309 < @ slaptijack . com . >
Parse0           returns: FAX=8008675309 < @ slaptijack . com . >
ParseLocal         input: FAX=8008675309 < @ slaptijack . com . >
ParseLocal       returns: 8008675309 < @ slaptijack . com . >
Parse1             input: 8008675309 < @ slaptijack . com . >
Mailertable        input: < slaptijack . com > 8008675309 < @ slaptijack . com . >
Mailertable        input: slaptijack . < com > 8008675309 < @ slaptijack . com . >
Mailertable      returns: 8008675309 < @ slaptijack . com . >
Mailertable      returns: 8008675309 < @ slaptijack . com . >
MailerToTriple     input: < > 8008675309 < @ slaptijack . com . >
MailerToTriple   returns: 8008675309 < @ slaptijack . com . >
Parse1           returns: $# esmtp $@ slaptijack . com . $: 8008675309 < @ slaptijack . com . >
parse            returns: $# esmtp $@ slaptijack . com . $: 8008675309 < @ slaptijack . com . >

Slaptijack's Koding Kraken