[Gambas-user] Receiving an email

Rolf-Werner Eilert eilert-sprachen at ...221...
Fri Jul 19 17:47:49 CEST 2013



Am 15.07.2013 23:12, schrieb Tobias Boege:
> On Mon, 15 Jul 2013, Rolf-Werner Eilert wrote:
>> Thanks for your advice, Randall.
>>
>> Am 15.07.2013 17:16, schrieb Randall Morgan:
>>> Is your email pop3, IMAP, MAPI, or webmail? The way you approach this
>>> depends on the target system.
>>
>> It is pop3 and it is my own vserver for my firm's website.
>>
>>>
>>> IMHO pop3 would be the easiest. There you would only need to access your
>>> mail account to download the emails for processing. Gambas has PDF
>>
>> Yes, that would be the precise question. My idea was to use the contact
>> form plugin from the website, making another contact form which sends
>> the results to another email address (e. g. application at ...1107... instead of
>> info at ...1107...) and read the emails from that address.
>>
>> So it all boils down to: how can I read the emails - say once a minute -
>> and place them somewhere where a script of mine - say Gambas - has
>> access and reads them. And how to read them.
>>
>> I thought of leaving everything on the remote server, but it might as
>> well be read from our local server in my firm and processed there. The
>> latter might be the better way, as it is done so for the ordinary
>> contact forms now (they are waiting for my email client to fetch them
>> from the remote server via pop3, so I can fetch them even now when I'm
>> in holidays, with my laptop). I'd just need a script to do with the
>> other ones in regular intervals.
>>
>>> generation capabilities so that is not an issue. Another way to handle this
>>> would be to setup a GAMABS SMTP service and have the emails forwarded to
>>> that service. Then the app could be written to process any email that
>>> arrived in the inbox.
>>
>> Yes, I saw there's an smtp library for Gambas, but I thought it might be
>> easier the other way round.
>>
>>>
>>> As for an easy way.... Well, easy is a qualitative term and so the ease of
>>> development would depend on the programmer's experience and abilities. If
>>> you're using webmail and the front end is something like Squirrel Mail,
>>> then you have a nice table arrangement that can be easily parsed with
>>> GAMBAS. But if your mail account is something like Yahoo or Google I think
>>> a web parsing framework such as those used with Java or Python would ease
>>> development.
>>
>> Neither nor, there's qmail on the server. That's it.
>>
>>>
>>> A lot of my data collection tasks involve writing code in different
>>> languages.
>>
>> I wouldn't mind calling some other script from the Gambas one or vice-versa.
>>
>>
>>> For example, One of my apps is a simple bash script that takes
>>> forms submitted as pdfs, and processes them using python and then stores
>>> the results in a MySQL DB which has some stored procedures for final
>>> processing. Then a cron script runs one every 5 minutes to get any new rows
>>> from the DB and place them in a queue to be reviewed by staff. The staff
>>> app then calls a php script that connects to a asterisk system if the staff
>>> needs to contact the client, and dials the clients number. Sadly, the staff
>>> review portion was not written in Gambas but in C++/Qt.
>>
>> Sounds rather clever, but I hope my idea won't become so extensive :-)
>>
>>>
>>> Don't get bogged down into thinking that if you use GAMBAS for a portion of
>>> the app that you must use it for the whole app. You can create powerful
>>> systems by combining the resources found other tools. Gambas and most Linux
>>> software is designed to allow this kind of inter-connect via pipes,
>>> sockets, and files. So pick the tools that make each part of the process
>>> easiest and you development will be simplified.
>>
>> Yes, that was the base of my idea. I started inventing a whole-in-one
>> app with Gambas: contact form, control, pdf, everything. Then I thought
>> there is a nice contact form plugin already, so why inventing the wheel?
>>
>> Ok, let's get back to the point: reading an email (pop3 from the remote
>> server to the local one) and placing it somewhere to let a Gambas app
>> process it, how should I start? Where can I find the emails? Isn't there
>> a mail command I can use from a bash script? After all, there are
>> scripts on every system that send mails to root. And where are these
>> mails stored then? When I know where, I can examine the files and find a
>> way to process them in Gambas.
>>
>
> So we have two options, right?
>
> a) Run a Gambas CGI script on the webserver which receives the user input
>     via HTTP (GET/POST) from the HTML form.
> b) Have a Gambas daemon on your local computer which checks regularly for
>     new mails dropped by an external program. Or even better: Have a Gambas
>     program which is fed with incoming mail whenever it arrives.
>
> It seems that a) is not the topic here. So, for b) you need a mail daemon. I
> personally use fetchmail for all my mail (IMAP). It also understands POP3,
> according to the manpages. And the best thing is: it has the "-m" switch
> which lets you give it a program (Mail Delivery Agent) to which it will pipe
> its mail. The MDA shall sort/distribute mail correctly but you can
> equivalently well use it to call any program with every incoming mail being
> piped to it. You can then examine the mail and do whatever you want.
>
> I use fetchmail for around 3 years now and the system didn't fail once - or
> it was so unimportant that I didn't notice. The only issue you have is to
> install and configure fetchmail correctly.
>
> I just tested fetchmail's -m option with a self-written program and it works
> as expected.
>
> Regards,
> Tobi
>

Thank you very much for your ideas.

a) could be a topic, and will, when I proceed to the next step, but it 
could be avoided until then

Thanks for the sendmail tipp, will have a look at it later.

Rolf





More information about the User mailing list