I need a script that connects to mail servers via POP3, POP3s, IMAP or IMAPs and fetches emails without deleting them. The script shall check for each mail if a pattern can be found within the mail body defined by the mail subject. If not an error shall be written to a logfile. If one error occurs during a fetch the status is BAD, otherwise OK.
The script shall take the following arguments: [login to view URL] [login to view URL] [login to view URL] [login to view URL]
[login to view URL]:
<mailserver>
<ID>MAILSERVER-POP3-PLAIN</ID> # Any (String)
<PROTOCOL>POP3</PROTOCOL> # POP3 or IMAP
<SSL>NO</SSL> # YES OR NO
<HOST>[login to view URL]</HOST> # FQDN or IP
<PORT>110</PORT> # PORT (INT)
<USERNAME>TESTUSER</USERNAME> # Any (String)
<PASSWORD>TESTPASS</PASSWORD> # Any (String)
</mailserver>
[login to view URL]:
<tests>
<case>
<ID>CHECK ONE</ID> # Any (String)
<SUBJECT>Subject 123</SUBJECT> # Any (String), full match
<PATTERN>ABC</PATTERN> # Any (String), within mail body
</case>
<case>
<ID>CHECK TWO</ID> # Any (String)
<SUBJECT>Subject 456</SUBJECT> # Any (String), full match
<PATTERN>DEF</PATTERN> # Any (String), within mail body
</case>
</tests>
[login to view URL] (Format and possible cases):
YYYY-MM-DD HH:MM:SS MAILSERVER-ID TEST-CASE-ID OK # If pattern for subject can be found in body
YYYY-MM-DD HH:MM:SS MAILSERVER-ID TEST-CASE-ID ERROR # If pattern for subject can not be found in body
YYYY-MM-DD HH:MM:SS MAILSERVER-ID CONNECT-ERROR # Mailserver can not be reached
YYYY-MM-DD HH:MM:SS MAILSERVER-ID TIMEOUT # While fetching a mail an timeout occured
[login to view URL]
OK # BAD
The script can be in perl, php, python or bash.
The source code has to be very lean and well documented.
Please state in your private message which language you want to use and add a sample script of yours as reference.
The chosen service provider has to be able to issue a valid invoice (including local tax id OR vat code in case of a company). Additional projects to follow.
Best regards,
Sebastian