-1

I am stuck.

I am wondering how to check if a Q-ID is a valid mailq ID.

/var/spool/mqueue (3 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
m9TMLQHG012749     1103 Thu Oct 30 11:21 <apache@localhost.localdomain>
                 (host map: lookup (electrictoolbox.com): deferred)
                                         <test@electrictoolbox.com>
m9TMLRB9012751    37113 Thu Oct 30 11:21 <apache@localhost.localdomain>
                 (host map: lookup (electrictoolbox.com): deferred)
                                         <test@electrictoolbox.com>
m9TMLPcg012747   240451 Thu Oct 30 11:21 <apache@localhost.localdomain>
                 (host map: lookup (electrictoolbox.com): deferred)
                                         <test@electrictoolbox.com>
                Total requests: 3

thanks for any hint.

  • how is `validity` defined here? – anishsane Jun 11 '14 at 14:07
  • m9TMLQHG012749, m9TMLRB9012751 and m9TMLPcg01274 are valid Q-IDs –  Jun 11 '14 at 19:06
  • Yes, but those are examples. What is the rule to define validity? or these 3 are the only available valid IDs? Is it that ID found in `/var/spool/mqueue` is valid, others are not? & you have to check the input if it is present in `/var/spool/mqueue`? – anishsane Jun 12 '14 at 05:35
  • OK. this is the output of the mailq command. it lists the mails in the que. I want to make a function that checks a random email Q-ID I get from another program that deals with emails with the mailq ID's and and outputs a boolean yes or no if the ID is in mailq. Practically tells me "this email ID is in the mail que right now". –  Jun 12 '14 at 18:51

1 Answers1

1

Based on your last comment, I guess this is what would suffice.

randomMailQId=XXXXXXXX # get this populated

if mailq | grep "^$randomMailQId\s"; then 
    echo Valid
else
    echo Invalid
fi
anishsane
  • 20,270
  • 5
  • 40
  • 73
  • this can only be run by user who have the right to run 'mailq'. I was looking for another method. Something that would check the folder /var/spool/mqueue and/or the way the ID are generated. –  Jun 15 '14 at 06:25