[Dovecot] looking for IMAP testing tool
I'm looking for an IMAP testing tool, suitable to use with Dovecot IMAP. It needs to support TLS, STARTTLS, and login/authentication. It needs to be able run from command line, shell scripts, and even do so under cron jobs (e.g. a way to supply the password to use w/o a terminal prompt). Typical interactive mail clients just don't cut it (even the text mode ones). One reason is I need to do the tests on a number of machines, under a number of user and domain names, and with a variety of parameters or destinations. This is for a suite of regression tests I am putting together intended to verify that configuration changes do not break things (or unbreak things that are supposed to not work).
Anyone ever heard of such a tool? Open source would be preferred (better yet, my favorite programming languages: C, Pike, Python).
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 18 May 2010, Phil Howard wrote:
Anyone ever heard of such a tool? Open source would be preferred (better
http://search.cpan.org/search?mode=dist&query=imap
:)
Regards,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBS/Khkb+Vh58GPL/cAQLLggf/XaHWOB7gOWqWWaW+vfAqNMuP+WU9SwVF NmAkBlWowqoqC/s9U7gT+v7J8hI/7WE+RZ04lI5EYANGtY3HR/+o44emgzT3Ds17 OepfM+ElP93qfXVi8Ch97vQwHLjOz5nMdzirVEv9MTPZiU026o4VqQxpZOhpIvhp IHFL7YhM5bOgyfCLX9cMgvJme18QHjL00pfaUxUp/MUwCAHdg/HmaWW9+sRz0e3E 4gN2Al7TGtY5h//CiOUGkVeNVCnSTHi6vrQS78lP/KbEyfQT3OFnLPLAs5T5BIw6 cE5ghS5nNkWuI/4Ro2wSm2UMZEX9e8t4253HWbR+1Q35LVBf9IjECQ== =U0go -----END PGP SIGNATURE-----
On Tue, May 18, 2010 at 10:17, Steffen Kaiser wrote: -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 On Tue, 18 May 2010, Phil Howard wrote: Anyone ever heard of such a tool? Open source would be preferred (better Those all looked like libraries/modules. Any complete commands? Writing
Perl code is not an option for me.
On 05/18/2010 04:33 PM, Phil Howard wrote:
On Tue, May 18, 2010 at 10:17, Steffen Kaiser
wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 18 May 2010, Phil Howard wrote:
Anyone ever heard of such a tool? Open source would be preferred (better
Those all looked like libraries/modules. Any complete commands? Writing Perl code is not an option for me.
Once there was small program Timo did.
http://www.dovecot.org/list/dovecot/2006-February/011635.html
Dunno if it's still around and usable for the current dovecot versions, or even if it was any good to use with other servers.
You should ask Timo.
R's,
Hugo Monteiro.
-- fct.unl.pt:~# cat .signature
Hugo Monteiro Email : hugo.monteiro@fct.unl.pt Telefone : +351 212948300 Ext.15307 Web : http://hmonteiro.net
Divisão de Informática Faculdade de Ciências e Tecnologia da Universidade Nova de Lisboa Quinta da Torre 2829-516 Caparica Portugal Telefone: +351 212948596 Fax: +351 212948548 www.fct.unl.pt apoio@fct.unl.pt
fct.unl.pt:~# _
On 05/18/2010 04:40 PM, Hugo Monteiro wrote:
On 05/18/2010 04:33 PM, Phil Howard wrote:
On Tue, May 18, 2010 at 10:17, Steffen Kaiser
wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 18 May 2010, Phil Howard wrote:
Anyone ever heard of such a tool? Open source would be preferred (better http://search.cpan.org/search?mode=dist&query=imap
Those all looked like libraries/modules. Any complete commands?
Writing Perl code is not an option for me.Once there was small program Timo did.
http://www.dovecot.org/list/dovecot/2006-February/011635.html
Dunno if it's still around and usable for the current dovecot versions, or even if it was any good to use with other servers.
You should ask Timo.
R's,
Hugo Monteiro.
Replying myself in this one. Should have looked a bit further into it.
R's,
Hugo Monteiro.
-- fct.unl.pt:~# cat .signature
Hugo Monteiro Email : hugo.monteiro@fct.unl.pt Telefone : +351 212948300 Ext.15307 Web : http://hmonteiro.net
Divisão de Informática Faculdade de Ciências e Tecnologia da Universidade Nova de Lisboa Quinta da Torre 2829-516 Caparica Portugal Telefone: +351 212948596 Fax: +351 212948548 www.fct.unl.pt apoio@fct.unl.pt
fct.unl.pt:~# _
On Tue, May 18, 2010 at 8:42 AM, Hugo Monteiro hugo.monteiro@fct.unl.pt wrote:
On 05/18/2010 04:40 PM, Hugo Monteiro wrote:
On 05/18/2010 04:33 PM, Phil Howard wrote:
On Tue, May 18, 2010 at 10:17, Steffen Kaiser
wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 18 May 2010, Phil Howard wrote:
Anyone ever heard of such a tool? Open source would be preferred (better http://search.cpan.org/search?mode=dist&query=imap
Those all looked like libraries/modules. Any complete commands? Writing Perl code is not an option for me.
Once there was small program Timo did.
http://www.dovecot.org/list/dovecot/2006-February/011635.html
Dunno if it's still around and usable for the current dovecot versions, or even if it was any good to use with other servers.
You should ask Timo.
R's,
Hugo Monteiro.
Replying myself in this one. Should have looked a bit further into it.
R's,
Hugo Monteiro.
-- fct.unl.pt:~# cat .signature
Hugo Monteiro Email : hugo.monteiro@fct.unl.pt Telefone : +351 212948300 Ext.15307 Web : http://hmonteiro.net
Divisão de Informática Faculdade de Ciências e Tecnologia da Universidade Nova de Lisboa Quinta da Torre 2829-516 Caparica Portugal Telefone: +351 212948596 Fax: +351 212948548 www.fct.unl.pt apoio@fct.unl.pt
fct.unl.pt:~# _
I haven't used it much but it looked useful: http://bc-bd.org/blog/imapfoo/
On Tue, May 18, 2010 at 13:17, Mark Moseley moseleymark@gmail.com wrote:
I haven't used it much but it looked useful: http://bc-bd.org/blog/imapfoo/
Hmmm. That (inserting mail into folders) can have it uses. But I'm really looking for something to do, in a very basic way, what is expected of an IMAP client, which is to fetch and read mail. Something that can login and list messages to stdout, or login and fetch a specified message to stdout, would be what I need (and that login might be by clear port 143, STARTTLS on port 143, or plain SSL/TLS on port 993).
On Tue, May 18, 2010 at 11:42, Hugo Monteiro hugo.monteiro@fct.unl.ptwrote:
Replying myself in this one. Should have looked a bit further into it.
What I'm looking for is not something that just tries commands. What I want to do is actually try to pick up mail and store it in some directory. My script would then check to see if it got the mail it was expecting, or got a failure it was expecting (for a scenario that should fail). Sorry for not being clear on that.
On 18.5.2010, at 19.31, Phil Howard wrote:
What I'm looking for is not something that just tries commands. What I want to do is actually try to pick up mail and store it in some directory. My script would then check to see if it got the mail it was expecting, or got a failure it was expecting (for a scenario that should fail). Sorry for not being clear on that.
imaptest actually allows something similar to that. It has possibility to "expect" kind of scripts where it sends some commands and expects something specific in return. There's a tests/ directory that tests a lot of imap commands replies. I don't remember if it currently supports matching multi-line replies, and if it does it would be a bit difficult to write those for larger emails.
Anyway, it doesn't support SSL/TLS. You could run it through stunnel though.
On Tue, May 18, 2010 at 15:50, Timo Sirainen tss@iki.fi wrote:
imaptest actually allows something similar to that. It has possibility to "expect" kind of scripts where it sends some commands and expects something specific in return. There's a tests/ directory that tests a lot of imap commands replies. I don't remember if it currently supports matching multi-line replies, and if it does it would be a bit difficult to write those for larger emails.
Anyway, it doesn't support SSL/TLS. You could run it through stunnel though.
What I need is a program that already has all the logic to do IMAP as a client already in it. This isn't about testing IMAP logic per-se. It's about making sure mail is going through OK, and logins that should fail will fail, and mail deliveries that should fail will fail (for example mail from a computer listed as blocked should never show up in the mailbox designated to test that, along with mail that has keywords specifically marked as "is always spam"). It's testing at a higher level than seeing if a given IMAP command gives the expected response (which is more of a diagnostic tool than the monitoring tool I need).
On 18 May 2010, at 22:32, Phil Howard wrote:
On Tue, May 18, 2010 at 15:50, Timo Sirainen tss@iki.fi wrote:
imaptest actually allows something similar to that. It has possibility to "expect" kind of scripts where it sends some commands and expects something specific in return. There's a tests/ directory that tests a lot of imap commands replies. I don't remember if it currently supports matching multi-line replies, and if it does it would be a bit difficult to write those for larger emails.
Anyway, it doesn't support SSL/TLS. You could run it through stunnel though.
What I need is a program that already has all the logic to do IMAP as a client already in it. This isn't about testing IMAP logic per-se. It's about making sure mail is going through OK, and logins that should fail will fail, and mail deliveries that should fail will fail (for example mail from a computer listed as blocked should never show up in the mailbox designated to test that, along with mail that has keywords specifically marked as "is always spam"). It's testing at a higher level than seeing if a given IMAP command gives the expected response (which is more of a diagnostic tool than the monitoring tool I need).
fetchmail? http://fetchmail.berlios.de/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, 18 May 2010, Phil Howard wrote:
What I need is a program that already has all the logic to do IMAP as a client already in it. This isn't about testing IMAP logic per-se. It's
That're the IMAP libraries for.
about making sure mail is going through OK, and logins that should fail will fail, and mail deliveries that should fail will fail (for example mail from a computer listed as blocked should never show up in the mailbox designated to test that, along with mail that has keywords specifically marked as "is always spam"). It's testing at a higher level than seeing if a given IMAP command gives the expected response (which is more of a diagnostic tool than the monitoring tool I need).
IMHO, you would need a pretty complex language to describe, what action is to fail and how (server response) and which includes stuff like "scan all messages in mailbox XYZ and search for SPAM tags", that this is probably not far away from using an IMAP lib itself.
Back in the time, when one dialed up via modem, there had been a tool called "expect", http://www.redhat.com/mirrors/LDP/LDP/nag2/x6675.html . Maybe you find something more generic by combing an IMAP library and a general purpose pattern matching tool.
BTW: It's more an configuration testing suite in my eyes and quite useful.
Regards,
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBS/OiFL+Vh58GPL/cAQK3kQgAu8Jkse3puny9IBQC5g4GjjVyJ+jM0Jyt /7iXI3il8MIR7jbvzdJ0IChUkCc59zSQUUWofOC27X6O6Mgav+hoI93VPk+qa9sz pAHyRITXdlQYze6H8LvojzoaLIHLAtLKA0H6y7AyYy95dxvNyWj9Ztf0oLVOwpcN TAY6XKnCrM/D2aZeX4rVTryXwRqqRWzCYht/+Mu80GYmKdSqWBQYnL6+1vDqUPyJ uWICaAmcgw3c7HJGdzMNbbf6SfleOwTGQN+Iv1SDkfNuXM+mHTnSH4uFKfzAEgNU K8njLGCvcl9d+ZyT6+y7d226mSa45z64mZmrFyJEE2one30BNd7JGg== =GVZT -----END PGP SIGNATURE-----
On Tue, May 18, 2010 at 05:32:14PM -0400, Phil Howard wrote:
What I need is a program that already has all the logic to do IMAP as a client already in it. This isn't about testing IMAP logic per-se. It's about making sure mail is going through OK, and logins that should fail will fail, and mail deliveries that should fail will fail (for example mail from a computer listed as blocked should never show up in the mailbox designated to test that, along with mail that has keywords specifically marked as "is always spam").
Then you're testing the whole environment: you'll need to deliver mail either by making SMTP connections or by invoking your LDA (e.g. sendmail) and piping the mail in - with some way of forcing it to look "spammy" or "not spammy" - to check the blocking. Then you'll use IMAP to retrieve them. This is clearly more than testing just IMAP; rather, you're testing the whole mail server platform and its configs.
I did something like this for linnet.org (warning: ancient project). I wrote ruby scripts which would invoke exim for mail delivery, although rather than fetch them via IMAP I tested in the filesystem directly that they had arrived in the Maildir.
FWIW, the code is at rubyforge.org/projects/linnet (under "SCM", fetch cvs) and the tests are in src/test/test-exim.rb, but I'm certainly not suggesting you use this.
I don't know of any ready-made test framework for what you want, and I suspect it would end up looking much like a programming language by the time you were able to configure all the different tests for processing different flavours of incoming mail.
Regards,
Brian.
On Wed, May 19, 2010 at 05:24, Brian Candler B.Candler@pobox.com wrote:
Then you're testing the whole environment: you'll need to deliver mail either by making SMTP connections or by invoking your LDA (e.g. sendmail) and piping the mail in - with some way of forcing it to look "spammy" or "not spammy" - to check the blocking. Then you'll use IMAP to retrieve them. This is clearly more than testing just IMAP; rather, you're testing the whole mail server platform and its configs.
Yes, that is what I want to be testing. So I need a way to send mail via SMTP (including TLS and login authentication) as well as picking it up via IMAP. But I chose to only ask for the IMAP piece of it here (and the SMTP piece of it on the Postfix mailing list ... to which Wietse suggested "expect" and "openssl s_client" which I think I can handle using "pexpect" in Python). I know enough SMTP to do that end of things. I don't know the IMAP protocol at all, so something already built would help. But I only need a subset which is to just pick up all email from the inbox of a given user@domain, deleting them from the server while depositing them in a designated directory. Each different class of test would be using a different mailbox. Some tests will, when things work as expected, get no mail at all (basically a test for rejecting mail).
I don't know of any ready-made test framework for what you want, and I
suspect it would end up looking much like a programming language by the time you were able to configure all the different tests for processing different flavours of incoming mail.
An IMAP library might be doable (though not in Perl since I don't know that language and don't have the time to learn it), but the basic "just pick up and delete all mail" would be sufficient.
On Wed, May 19, 2010 at 09:48:02AM -0400, Phil Howard wrote:
Yes, that is what I want to be testing. So I need a way to send mail via SMTP (including TLS and login authentication) as well as picking it up via IMAP. But I chose to only ask for the IMAP piece of it here (and the SMTP piece of it on the Postfix mailing list ... to which Wietse suggested "expect" and "openssl s_client" which I think I can handle using "pexpect" in Python). I know enough SMTP to do that end of things. I don't know the IMAP protocol at all, so something already built would help.
If you can do SMTP, you can do IMAP. This should get you started:
a login foo@bar.com xyzzy a select inbox -- or "a examine inbox" for read-only a fetch 1:15 (rfc822) a store 1:15 +flags (\Deleted) a expunge a logout
Also useful:
a namespace -- folder separator chars a list "" "*" -- list folder hierarchy
Flick through RFC3501 for anything else you need.
An IMAP library might be doable (though not in Perl since I don't know that language and don't have the time to learn it), but the basic "just pick up and delete all mail" would be sufficient.
As suggested by someone else, you can use 'fetchmail' to do that. Normally it delivers using SMTP, but with appropriate flags I believe it can pipe all the retrieved mail to stdout. And if these are all separate mailboxes, POP3 will do for your purposes anyway.
Regards,
Brian.
On Wed, May 19, 2010 at 10:04, Brian Candler B.Candler@pobox.com wrote:
If you can do SMTP, you can do IMAP. This should get you started:
a login foo@bar.com xyzzy a select inbox -- or "a examine inbox" for read-only a fetch 1:15 (rfc822) a store 1:15 +flags (\Deleted) a expunge a logout
Also useful:
a namespace -- folder separator chars a list "" "*" -- list folder hierarchy
Flick through RFC3501 for anything else you need.
I might have to do that sometime. But from what I've seen of IMAP it is more complex than SMTP. POP3 was (though not greatly so). Still, I don't feel I'd want to implement a POP3 tool (and don't need one).
An IMAP library might be doable (though not in Perl since I don't know that language and don't have the time to learn it), but the basic "just pick up and delete all mail" would be sufficient.
As suggested by someone else, you can use 'fetchmail' to do that. Normally it delivers using SMTP, but with appropriate flags I believe it can pipe all the retrieved mail to stdout. And if these are all separate mailboxes, POP3 will do for your purposes anyway.
Or maybe just hack its source code?
Phil Howard wrote:
What I need is a program that already has all the logic to do IMAP as a client already in it. This isn't about testing IMAP logic per-se. It's about making sure mail is going through OK, and logins that should fail will fail, and mail deliveries that should fail will fail (for example mail from a computer listed as blocked should never show up in the mailbox designated to test that, along with mail that has keywords specifically marked as "is always spam"). It's testing at a higher level than seeing if a given IMAP command gives the expected response (which is more of a diagnostic tool than the monitoring tool I need).
It sounds like you want a sort of "toolbox" of ready-made and tested components, such as an IMAP client, but with rich programmatic interfaces so that you only need to write a little bit of "glue" code to make it do exactly what you want.
Bill
On Wed, May 19, 2010 at 07:52, William Blunn bill@blunn.org wrote:
It sounds like you want a sort of "toolbox" of ready-made and tested components, such as an IMAP client, but with rich programmatic interfaces so that you only need to write a little bit of "glue" code to make it do exactly what you want.
I don't really need a lot. I just need to pick up all mail in the inbox of a given user@domain I login with, deposit each in a given directory, and delete them from the server. The only options I think I need are: what user@domain to login as, whether to use clear, STARTTLS, or a basic TLS/SSL protocol, and what port number (143 or 993). I don't have any interest in other folders. I just want to see if mail was delivered and do so from a separate machine than the mail server itself (or see if IMAP is even up).
Phil Howard ttiphil@gmail.com (Di 18 Mai 2010 16:04:14 CEST):
I'm looking for an IMAP testing tool, suitable to use with Dovecot IMAP. It needs to support TLS, STARTTLS, and login/authentication. It needs to be able run from command line, shell scripts, and even do so under cron jobs (e.g. a way to supply the password to use w/o a terminal prompt). Typical interactive mail clients just don't cut it (even the text mode ones). One reason is I need to do the tests on a number of machines, under a number of user and domain names, and with a variety of parameters or destinations. This is for a suite of regression tests I am putting together intended to verify that configuration changes do not break things (or unbreak things that are supposed to not work).
Anyone ever heard of such a tool? Open source would be preferred (better yet, my favorite programming languages: C, Pike, Python).
You could use imtest and pop3test from the cyrus suite. The newer versions should work with a dovecot server too. (Older ones were buggy and expected more output than dovecot sent.)
For Perl exist several modules/libray to home brew your tests.
use Mail::IMAPClient;
my $s = new Mail::IMAPCLient(
Server => …,
User => …,
…
) or die $@;
$s->examine("INBOX") or die $@;
… and so on.
-- Heiko
participants (10)
-
Brian Candler
-
Heiko Schlittermann
-
Hugo Monteiro
-
Mark Moseley
-
Nick Osborn
-
Phil Howard
-
Steffen Kaiser
-
Timo Sirainen
-
William Blunn
-
William Blunn