[Gambas-user] Send Mail In Gambas

Rob Kudla sourceforge-raindog2 at ...94...
Wed Jan 11 19:05:01 CET 2006


On Wed January 11 2006 12:37, SHARMAQ Sistemas wrote:
> How to i can send a Relat by email in Gambas?

A couple of ways.  You can connect to an SMTP server directly and 
just send the mail using SMTP commands:

dim s as new Socket
s.Host = "my.mail.server.com.br"
s.Port = 25
s.Connect

and in the Socket_Ready sub, something like this:
dim s as Socket
s = LAST
print #s, "HELO myhostname.mydomain.com.br\r\n"
print #s, "MAIL FROM:<my at ...1320...>\r\n"
print #s, "RCPT TO:<their at ...1320...>\r\n"
print #s, "DATA\r\n"
print #s, "Subject: Test Mail From Gambas\r\n"
print #s, "Date: Wed, 11 Jan 2006 15:37:07 -0200\r\n"
print #s, "From: my at ...1320...\r\n"
print #s, "To: their at ...1320...\r\n"
print #s, "\r\n"
print #s, "This is the body of the message.\r\n"
print #s, "\r\n"
print #s, ".\r\n"
close s

Or you can check for the existence of the "sendmail" program in 
your user's path, and shell out to that.  That's probably the 
easier way, but in my experience, a sendmail-compatible program 
isn't installed by default on most Linux distributions anymore.

Rob




More information about the User mailing list