I'm aware of that, thank you for the advice! Rolf
Am 16.07.2013 00:57, schrieb Sebastian Kulesz: > You could use a cron tab to run the script Randall just sent. There is a > POP3Client example you can open with the gambas IDE to know how it works. > Just execute the app every x minutes and you are done! > > Remember not to hardcode your username and password. You will regret later > > > On Mon, Jul 15, 2013 at 7:37 PM, Randall Morgan <[email protected]> wrote: > >> Here's a really quick and dirty sample of using the gd.net.pop3 mail client >> using the command line project type: >> >> ' Gambas module file >> >> Public Sub Main() >> Dim hConn As New Pop3Client >> Dim sMailIds As String[] >> Dim sMailId As String >> Dim Stats As Integer[] >> Dim iCount As Integer >> Dim iSize As Integer >> Dim sMessage As String >> >> >> 'Set mail server connection parameters >> With hConn >> .Host = '"<your mail server host name>" >> .Port = 110 '<your mail server port 110 is common for non ssl. 995 for >> ssl. > >> .User = '"<your mail account username>" >> .Password = '"<your mail account password>" 'May want to store in, and >> retrieve this from an encrypted file >> End With >> >> Try hConn.Open >> >> If Error Then >> Print "Mail Error: "; Error.Text; "\nat "; Error.Where 'May want to log >> this.... >> Else >> If hConn.Status = -16 Then >> Print "Cannot Authenticate Mail Account." >> Stop >> Else If hConn.Status = 7 Then >> Print "Connected to mail server...." >> Print hConn.Welcome >> Endif >> Endif >> >> >> Stats = hConn.Stat() >> >> Print "There are "; Stats[0]; " Messages in your inbox." >> Print "You inbox contains "; Stats[1]; " bytes of data." >> >> ' Show all mail ids >> sMailIds = hConn.List() >> >> For Each sMailId In sMailIds >> Print sMailId >> Next >> >> ' Get each mail and display >> For Each sMailId In sMailIds >> sMessage = hConn.Exec("RETR " & sMailId) >> Print "Message: "; sMailId; "\n" >> Print "----------------------------------------------------" >> Print sMessage; "\n\n" >> Next >> >> Print "Closing Connection." >> hConn.Close >> >> End >> >> >> >> You may also find these links helpful: >> >> >> http://www.arclab.com/products/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html >> >> http://www.electrictoolbox.com/article/networking/pop3-commands/ >> >> >> On Mon, Jul 15, 2013 at 2:12 PM, Tobias Boege <[email protected]> wrote: >> >>> 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@... instead of >>>> info@...) 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 >>> >>> >>> >> ------------------------------------------------------------------------------ >>> See everything from the browser to the database with AppDynamics >>> Get end-to-end visibility with application monitoring from AppDynamics >>> Isolate bottlenecks and diagnose root cause in seconds. >>> Start your free trial of AppDynamics Pro today! >>> >> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> Gambas-user mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/gambas-user >>> >> >> >> >> -- >> If you ask me if it can be done. The answer is YES, it can always be done. >> The correct questions however are... What will it cost, and how long will >> it take? >> >> ------------------------------------------------------------------------------ >> See everything from the browser to the database with AppDynamics >> Get end-to-end visibility with application monitoring from AppDynamics >> Isolate bottlenecks and diagnose root cause in seconds. >> Start your free trial of AppDynamics Pro today! >> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk >> _______________________________________________ >> Gambas-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/gambas-user >> > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
