Hi, I need help about sending mail in linux. I have a ubuntu server with working web site, users are uploading files in one main directory (to folder inbox). With samba I shared that directory and on other mashine is Windows server and application that is reading that files and writting content to database. Based of the result is creating new file with content: package name that is recieved, size, date and time and does the package contained erros or it was OK. That newly created files are again sent over samba to the same directory in ubuntu server (to folder outbox). That all is working!

Now, i need to listen are there new files in folder outbox. If there are new files, I need to send their content to specific email address. I have users in Mysql database. The name of files that are coming to outbox is with mask like this ddmmyyyy.x where x is user id in Mysql. So if "extension" of file is 1, I need to send mail to mail address of user in mysql with user id 1. If its 2 I am sending to user with user id... and after that move file from outbox to archive.

So, it's going like this: new file arrived in outbox, based on the extension of that file, select email address of user from database with user id = extension of file. On that email address send content of that file and move file to archive.

Does anyone can help me to solve this. Thank you!

P.S I have a mail working and I can send email from shell.