On 10/19/2016 9:50 PM, Sebastian Nielsen wrote: > I currently have this postfix server. > > > > What I want to do now, is to route all mails containing only digits > in the user part, for example: 12345...@sebbe.eu > <mailto:12345...@sebbe.eu> or 63232535...@sebbe.eu > <mailto:63232535...@sebbe.eu> > > To a application, namely smsq.
I can give you some pointers, but not a full solution. Examples here are totally untested, beware of typos or syntax errors. But I think the general idea is correct. Last part first... > And of course, sending to these adresses should be considered relay, > eg if you aren’t permitted to relay through the server, any mail to > a adress whose user-part contains only digits, should be rejected, > for obvious security reasons. The obvious way to enforce this is to use a separate domain, eg. sms.sebbe.eu. Don't list this domain in mydestination or virtual_ alias or virtual_mailbox _domains, and define relay_domains empty "relay_domains =" > > > > So basically, for any mail arriving at {DIGITS}@sebbe.eu > <mailto:%7bdigits...@sebbe.eu> , I want to cut out the first 150 > characters of the plaintext body, and then send it to the following > command: > > smsq --motx=SIP/0740940000@cellip --da {DIGITS} --ud > {TRUNCATED_PLAINTEXT_BODY} > Use a transport_maps entry to pipe all {DIGITS}@sms.sebbe.eu to a script. # main.cf smsq_destination_recipient_limit = 1 transport_maps = pcre:/etc/postfix/sms_transport.pcre # sms_transport.pcre # (a more sophisticated expression would check for a # properly formed phone number) /^[0-9]+@sms\.sebbe\.eu$/ smsq: /@sms\.sebbe\.eu$/ error:must be numeric define the smsq transport in master.cf smsq unix - n n - - pipe flags=X user=sms arv=/path/to/custom-script ${user} Postfix will pipe the message (headers+body) to custom-script. The script will need to decide which part is the body and send it to arg $1, which will be the number. Your job is to write a little custom script to interface between postfix/pipe and smsq. -- Noel Jones