0

I just set up postfix and dovecot on a CentOS 7 server using this tutorial. I am able to successfully create a mail record using echo "TEST" | mail -s "testmail" youruser@localhost && tail -f /var/log/maillog. But how can I access and work with the resulting email files?

I need to configure a java program to process incoming email, including decomposing and processing attachment files. This could be done using either mysql or simply raw files. But I need to know where to have the java program look for the mail.

As per the tutorial, I set mail_location = maildir:~/Maildir in /etc/dovecot/conf.d/10-mail.conf. But when I type cd /home/youruser/Maildir, the terminal replies with -bash: cd: Maildir: Permission denied. Similarly, sudo cd /home/youruser/Maildir simply results in the terminal ignoring the command and remaining in whatever directory it was previously in.

1 Answer 1

1

In general you shouldn't have to manipulate maildir directly. Maildir is not only a directory tree with files but also a set of indexes and other supplementary files. When you create the file in the ./new subdir you, at least, have to recreate the index of corresponding folder.

Recommended way is to use doveadm utility to create folders an subfolders as well as subscribe them. If you want to inject some message to the maidir, you have to use deliver utility that perform injection in the proper way.

If you need to read the content of maildir you have to use some IMAP library that conforms IMAP protocol. I'm not familiar with Java but I'm absolutely sure that more than one library with required functionality exists.

Raw access to the maildir is not recommended.

http://wiki2.dovecot.org/Tools/Doveadm

http://wiki2.dovecot.org/LDA

8
  • Thank you very much. Can you please post some links to explanations of how to do the things that you are suggesting? I need step by step instructions. With your knowledge of the subject, I imagine that you could find some tutorials or other documentation that I would not be able to find myself. Commented Jan 1, 2015 at 4:56
  • @slm Thank you. This does not answer my question. I need to read the sender, the message text, the attached files, and possibly the sender's ip address from each email into another program. It is fine if this all goes into mysql. I can use java to get it out of mysql myself. The answer does not have to be specific to java. I just definitely need to be able to use code to view and manipulate the contents of each message. I am tempted to write another question, but I am reaching out first so as to reduce clutter of redundant questions on the site if this question can be answered in a unable way. Commented Jan 1, 2015 at 20:28
  • @CodeMed - wasn't my answer, I simply edited it. Commented Jan 1, 2015 at 20:33
  • @CodeMed Email format (MIME-multipart/encoded) is quite complex. Look for ready-to-use third-party solution instead of making you own toolset. Commented Jan 1, 2015 at 21:24
  • @Kondybas Anything that gets it into mysql would be sufficient. Can you suggest how to get it into mysql? Commented Jan 1, 2015 at 21:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.