hb_sendmail()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

hb_sendmail()

Post by Roberto Lopez »

Hi All,

Has anyone a working sample of hb_sendmail()?

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Re: hb_sendmail()

Post by Alex Gustow »

Hi Roberto!

I created "mail robot" :) few months ago (recieving mails with attaches, analyzing mail's content, saving attaches to pre-defined subfolders, send "auto-answers", creating HTML-log).

If needed I can translate this (from Rus to Eng) and "designed" as a sample.
(it's console app compiled with xHarbour - I had some strange troubles with compiling it with "simple" Harbour)

What's the question(s) you have about Hb-SendMail()?
User avatar
gfilatov
Posts: 1068
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: hb_sendmail()

Post by gfilatov »

Roberto Lopez wrote:Hi All,

Has anyone a working sample of hb_sendmail()?
Sure.

Please take a look for the following working code using free mail server with authentication:

Code: Select all

   cSMTPServer   := "smtp.freemail.ru"
   cPopServer    := "pop.freemail.ru"
   cFrom         := "gfilatov@freemail.ru"
   cTo           := "recipient@domain.com"
   cSMTPPassWord := "MySmtpPassword"

// hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPass, cCharset, cEncoding )

   MsgInfo( iif(hb_SendMail( cSMTPServer,;
                  NIL,;
                  cFrom,;
                  cTo,;
                  NIL /* CC */,;
                  NIL /* BCC */,;
                  "test: body",;
                  "test: subject",;
                  {"sendmail.prg"} /* attachment */,;
                  cFrom,;
                  cSMTPPassword,;
                  cPopServer,;
                  NIL /* nPriority */,;
                  NIL /* lRead */,;
                  .F. /* lTrace */,;
                  .T. /* lPopAuth */,;
                  .F. /* lNoAuth */,;
                  NIL /* nTimeOut */,;
                  NIL /* cReplyTo */,;
                  .F. /* lTLS */,;
                  cSMTPPassWord ), "Successfully", "Unsuccessfully"), "Result" )
Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: hb_sendmail()

Post by Roberto Lopez »

gfilatov wrote:
Roberto Lopez wrote:Hi All,

Has anyone a working sample of hb_sendmail()?
Sure.

Please take a look for the following working code using free mail server with authentication:

Code: Select all

   cSMTPServer   := "smtp.freemail.ru"
   cPopServer    := "pop.freemail.ru"
   cFrom         := "gfilatov@freemail.ru"
   cTo           := "recipient@domain.com"
   cSMTPPassWord := "MySmtpPassword"

// hb_SendMail( cServer, nPort, cFrom, xTo, xCC, xBCC, cBody, cSubject, aFiles, cUser, cPass, cPopServer, nPriority, lRead, bTrace, lPopAuth, lNoAuth, nTimeOut, cReplyTo, lTLS, cSMTPPass, cCharset, cEncoding )

   MsgInfo( iif(hb_SendMail( cSMTPServer,;
                  NIL,;
                  cFrom,;
                  cTo,;
                  NIL /* CC */,;
                  NIL /* BCC */,;
                  "test: body",;
                  "test: subject",;
                  {"sendmail.prg"} /* attachment */,;
                  cFrom,;
                  cSMTPPassword,;
                  cPopServer,;
                  NIL /* nPriority */,;
                  NIL /* lRead */,;
                  .F. /* lTrace */,;
                  .T. /* lPopAuth */,;
                  .F. /* lNoAuth */,;
                  NIL /* nTimeOut */,;
                  NIL /* cReplyTo */,;
                  .F. /* lTLS */,;
                  cSMTPPassWord ), "Successfully", "Unsuccessfully"), "Result" )
Hope that helps :idea:
Thanks!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: hb_sendmail()

Post by Roberto Lopez »

Alex Gustow wrote:Hi Roberto!

I created "mail robot" :) few months ago (recieving mails with attaches, analyzing mail's content, saving attaches to pre-defined subfolders, send "auto-answers", creating HTML-log).

If needed I can translate this (from Rus to Eng) and "designed" as a sample.
(it's console app compiled with xHarbour - I had some strange troubles with compiling it with "simple" Harbour)

What's the question(s) you have about Hb-SendMail()?
Thanks for the offer.

My needs are simpler. I'm only need to send a message to a list of recipients.

I'll try with Grigory sample.

I've posted the question, because I receive astrange error message. I guess that I've missed the parameters.

Thanks Again!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: hb_sendmail()

Post by Roberto Lopez »

Roberto Lopez wrote: Thanks!
Ok.

The problem was I've attempted to activate TLS, since that I'm testing with a gmail account.

When you set TLS to .t., you'll get an error 'operation not supported'.

So, there is no errors, but the operation is unsuccessful. I guess the TLS is mandatory for Google.

Anyway, there is a way to know the error code, to find what exactly is happening?
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: hb_sendmail()

Post by Roberto Lopez »

Roberto Lopez wrote:
Anyway, there is a way to know the error code, to find what exactly is happening?
I've activated trace and I've found the error 512.

If someone can successfully access gmail smtp, please, let me know.

At the moment, I'm using blat. It connects google without problems.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Alex Gustow
Posts: 290
Joined: Thu Dec 04, 2008 1:05 pm
Location: Yekaterinburg, Russia
Contact:

Re: hb_sendmail()

Post by Alex Gustow »

OK, Roberto, I understood your needs.
Sorry, but I hasn't gmail account and can't help in such situation :(
User avatar
gfilatov
Posts: 1068
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: hb_sendmail()

Post by gfilatov »

Roberto Lopez wrote:
Roberto Lopez wrote:
Anyway, there is a way to know the error code, to find what exactly is happening?
I've activated trace and I've found the error 512.

If someone can successfully access gmail smtp, please, let me know.

At the moment, I'm using blat. It connects google without problems.
Roberto,

AFAIR you will need to recompile the Harbour contrib hbtip library with HB_HAS_OPENSSL option for SSL support.
...
2009-08-07 04:11 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/sendmail.prg
! Raised timeout to 1000 from 100.
This was the remaining error, now it should be okay.
; This means Harbour now support SMTP through SSL, which
practically means "gmail support", Google Apps for
Domain mailboxes also work.
Remember to build hbtip with HB_HAS_OPENSSL option and
link with hbssl lib + openssl libs. On *nixes this is
a no-brainer. On Windows, OpenSSL either needs to be
built from source, or pre-built binaries downloaded
(from this file: http://www.slproweb.com/download/Win32O ... 0_9_8k.exe
from this link: http://www.slproweb.com/products/Win32OpenSSL.html)
and linked. Due to usual chaos regarding lib names
on Windows, default names in contrib\hbssl\hbssl.hbc may
need to be adjusted to local environment.
MinGW and MSVC are supported by OpenSSL on Windows for
static linking, the .dll version should work for all
compilers, I've only tested MinGW and MSVC though.

+ contrib/hbtip/tests/gmail.prg
+ Added simple test program to send mails through gmail.
...
Hope that give you an idea :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: hb_sendmail()

Post by Roberto Lopez »

gfilatov wrote: Roberto,

AFAIR you will need to recompile the Harbour contrib hbtip library with HB_HAS_OPENSSL option for SSL support.
I don't knew that.

I'll try.

Thanks for the info.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply