hmm... Based on Philipps idea I have modified my script as follows:
#!/bin/bash cat - > /tmp/notfallemail from=`cat /tmp/notfallemail | head -n 50 | grep -i ^From` from=${from// /+} subject=`cat /tmp/notfallemail | head -n 50 | grep -i ^Subject` subject=${subject// /+} out=`curl -g "https://smsgw01/cgi-bin/sms_send?text=Neue+Notfall+Email+von+$from+mit+Betreff+$subject"` exit 0 Stdin works. The SMS message now contains the From and the Subject header. However, OpenSMTPd still complains with "mda exited prematurely". If I however change the script to the following, while the message OpenSMTPd complains about is still in the queue and pending #!/bin/bash cat - > /dev/null out=`curl -g "https://smsgw01/cgi-bin/sms_send?text=Neue+Notfall+Email"` exit 0 and then issue smtpctl schedule all, then OpenSMTPd reports a successful delivery and removes the mail from the queue. Any ideas? Thanks! Cheers, Simon Philipp wrote: > Hi Simon > > [2024-03-05 10:49] Simon Hoffmann <open...@list.simonhoffmann.net> > > in my virtual users file, I have specified an external script additionally > > to > > delivery to mailboxes. > > > > > > emerge...@domain.tld user1,user2,|/etc/smtpd/send_sms.sh > > > > Local delivery to the mailboxes works fine. > > The script itself is called as well as I do receive the SMS message. > > > > However, OpenSMTPd says "MDA exited prematurely" after calling the script, > > thus > > leading to a TEMPFAIL and OpenSMTPd trying again periodically. > > This means your script exited while OpenSMTPd still has (parts of) the > mail in the output buffer. > > > [...] > > > > The send_sms.sh script consists of a static curl call at the moment, that > > performs a > > HTTP Get call to the SMS Gateway with the static text "new emergency mail > > received". > > I am not yet parsing sender/subject etc. > > I would guess that you don't read stdin at all. > > > Sadly, I could find nothing on the man pages as to which exit codes > > OpenSMTPd expects > > from an mda script. Additionally, based on the documentation available, I > > am not sure > > if OpenSMTPd just pipes the whole message into stdin or if OpenSMTPd > > expects some > > form of "smtp communication" (MAIL FROM + response, RCPT TO + response, > > ....) and > > thus comlains that my script exits prematurely because I have not > > implemented > > that. > > smtpd pipes the mail to stdin and expect your script to read it. > > > So, long story short: how shall I modify my script so that OpenSMTPd > > recognises that > > the SMS Gateway received the call and has queued the SMS? > > A simple line "cat - > /dev/null" should fix it. > > Philipp > -- --
signature.asc
Description: PGP signature