Send mail, console mode

570 views
Skip to first unread message

Daniel Du Pré

unread,
Feb 4, 2016, 10:26:30 AM2/4/16
to Harbour Users
Hello Foro,

I have an application
made harbor in console mode for billing, and I need to add the ability to send data by mail, but I'm lost.
I searched the forum and I found something to send only from Gmail and do not know where to start.

Could someone give me a help or tell me where I can study the subject?

Thank you

Daniel

Qatan

unread,
Feb 4, 2016, 10:47:34 AM2/4/16
to harbou...@googlegroups.com
Hi Daniel,
 
I suggest you to use hb_sendmail()
 
Click on the link to find some examples.
You can also see the example in the contrib hbtip – you just have to replace the email configuration to use your email account (this you can find with the email provider).
 
I hope it helps you.
 
Qatan
 

JoséQuintas

unread,
Feb 4, 2016, 11:03:50 AM2/4/16
to harbou...@googlegroups.com
Check folder harbour\contrib\hbtip\tests

José M. C. Quintas
--

Ramon Prior

unread,
Feb 4, 2016, 11:05:48 AM2/4/16
to harbou...@googlegroups.com
I use sendemail for a while without any problem:. http://caspian.dotconf.net/menu/Software/SendEmail/

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Du Pré

unread,
Feb 4, 2016, 5:20:03 PM2/4/16
to Harbour Users
Qatan, José and Ramon.

Thank you very much for your help, I will investigate these options

best regards

Daniel

Daniel Du Pré

unread,
Feb 6, 2016, 6:12:51 PM2/6/16
to Harbour Users
Hello Forum,
I'm trying hb_sendmail () and the code that I use is this:

   hb_SendMail( ;
      alltrim(mail->smtp),;       // IP or domain name of the mail server
      val(alltrim(mail->port)),;   // Port used my email server
      alltrim(mail->from),;        // Email address of the sender
      alltrim(wpara),;               // Character string or array of email addresses to send the email to
      NIL,;                              // Character string or array of email addresses for CC (Carbon Copy)
      {},;                                 // Character string or array of email addresses for BCC (Blind Carbon Copy)
      alltrim(mail->mensaje),;   // The body message of the email as text, or the filename of the HTML message to send.
      alltrim(mail->asunto),;     // Subject of the sending email
      NIL,;                              // Array of attachments to the email to send
      alltrim(mail->user),;         // User name for the POP3 server
      alltrim(mail->password),;  // Password for User
      alltrim(mail->pop3),;        // POP3 server name or address
      3,;                                // Email priority: 1=High, 3=Normal (Standard), 5=Low
      .F.,;                              // If set to .T., a confirmation request is send. Standard setting is .F.
      .T.,;                              // If set to .T., a log file is created (smtp-<n>.log). Standard setting is .F.
      .T.,;                              // Do POP3 authentication before sending mail.
      NIL,;                             // Disable Autentication methods
      NIL,;                             // Number os ms to wait default 10000 (10s)
      NIL,;                             // cReplyTo
      .F. )                              // Need SSL at connect time (TLS need this param set to False)

In the attachment I send the logs I get and I did not realize what I'm doing wrong, I have not been able to send any mail.

I appreciate if you can give me an idea what my error.

thank you

Best regards
Daniel
smtp-1.log
pop3-1.log

Klas Engwall

unread,
Feb 7, 2016, 1:11:07 PM2/7/16
to harbou...@googlegroups.com
Hi Daniel,

> In the attachment I send the logs I get and I did not realize what I'm
> doing wrong, I have not been able to send any mail.
>
> I appreciate if you can give me an idea what my error.

You get "250" responses for the sender, the recipient and the email,
which is perfect. The log says that the email was received and queued by
the mail server. So, so far no error. Any problems at the recipient end?

20160206-19:53:00 :INETRECVLINE( <pointer>, , 512 )
>> 250 Mail queued for delivery. <<

Regards,
Klas

Daniel Du Pré

unread,
Feb 8, 2016, 7:07:58 PM2/8/16
to Harbour Users
Klas, José, Qathan, Ramon

finally I have my application sending mail with hb_sendmail (), many thanks for the help.

I could do to gmail.com and other servers


Best regards
Daniel

TV do Povo TV do Povo

unread,
Feb 9, 2016, 3:17:24 PM2/9/16
to Harbour Users
Hello ... good night / afternoon / morning / morning !!
lol
The thing is, I'm testing for the first time an example in harbor 3.4 TIP_MAILSEND () as follows, but the response by the ALERT () that was not sent the email.
Daniel and other teachers can give me an idea?
see my code:
=========
func main ()
...
   
enviaemail: hb_dirbase = () + "DBatualiza.log"
   
envia_email_pos (enviaemail)
...
return
Function envia_email_pos (email)
   
// CSubject site: = hb_oemtoansi ( "sale Pas -") + User
   
Local cSubject: = "System Error sicca v3.6.03"
   
Act Local: = { "ende...@provedor.com.br"}
   
Local cServerIp: = "smtp.yahoo.com.br"
   
cFrom site: = "estudio....@yahoo.com.br"
   
Local cUser: = "microv...@hotmail.com"
   
Local cmsg: = "email test" + // email memoread ( "carta1.txt")
   
cPass: = alltrim ( "1234567890") // password is another, I moved here just to catch any hacker true.
   
door: = 25
   
pop3: = "pop.yahoo.com.br:587"
   
if Tip_MailSend (cServerIP, door cFrom, act ,,, cmsg, cSubject ,, cUser, cPass, pop3,1, .F.,. T.,. T.,. F.) = .T.
      
alert ( 'Email sent successfully !!!')
   
else
      
alert ( 'Failed to send the mail.')
   
endif
return
=========
Otherwise, the log that displays "pop3-1.log" contains the following information:
----------------
20160209-17: 33: 42: INETERRORCODE (<pointer>)
0 >> <<

20160209-17: 33: 42: INETRECVLINE (<pointer>, 128)
>> <<

20160209-17: 33: 42: INETERRORCODE (<pointer>)
>> << -4
----------------


earned and hugs!

Milan Mehta

unread,
Apr 11, 2016, 7:05:32 AM4/11/16
to Harbour Users

I am trying to execute hb32\contrib\hbtip\tests\gmail.prg.
But when I run the application it gives me error :

The program can't start because LIBEAY32.dll is missing from your computer. Try reinstalling the program to fix this problem.

Can someone guide me on the subject ?

TIA
Milan.

Andi Jahja

unread,
Apr 11, 2016, 7:37:28 AM4/11/16
to harbou...@googlegroups.com
Download/install LIBEAY32.DLL from here: http://slproweb.com/products/Win32OpenSSL.html

Andi


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Milan Mehta

unread,
Apr 11, 2016, 10:59:28 AM4/11/16
to Harbour Users

hb-Sendmail() is returning .T., but mail is not getting delivered.

I have attached the log file. Can someone guide me, what am I doing wrong ?

TIA

Milan.
smtp-21.log
smtp-22.log

Klas Engwall

unread,
Apr 11, 2016, 4:22:14 PM4/11/16
to harbou...@googlegroups.com
Hi Milan,

> hb-Sendmail() is returning .T., but mail is not getting delivered.
> I have attached the log file. Can someone guide me, what am I doing wrong ?

This is the original problem:

>> 550 <lotusi...@gmail.com> No such user here <<

The recipient email account does not exist, so the mail server is
complaining and not processing further commands. Then there is a bug in
hb_SendMail() around line 240-245 ...

oInMail:Write( hb_MailAssemble( cFrom, xTo, xCC, cBody, cSubject,;
aFiles, nPriority, lRead, cReplyTo, cCharset, cEncoding ) )
oInMail:Commit()
oInMail:Close()
RETURN .T.

... where hb_SendMail() commit()s and returns .T. whether the sender and
recipients are accepted or not, causing the two >> 500 command
unrecognized << error messages in the log file.

A better solution would be for hb_SendMail() to do something like this:

nResult := oInMail:Write( hb_MailAssemble( cFrom, xTo, xCC, cBody,;
cSubject, aFiles, nPriority, lRead, cReplyTo, cCharset,;
cEncoding ) )
if nResult == F_ERROR // Catches the original 550 problem
oInMail:Close()
RETURN .F.
else
oInMail:Commit()
oInMail:Close()
endif
RETURN .T.


Regards,
Klas

Milan Mehta

unread,
Apr 12, 2016, 2:01:03 AM4/12/16
to Harbour Users
Dear Klas,

Can you explain me in more details, what exactly I should do ?
Should I change the source of Hb_SendMail() or make a work around function.

Kindly guide.

TIA
Milan.

Klas Engwall

unread,
Apr 12, 2016, 6:37:35 AM4/12/16
to harbou...@googlegroups.com
Hi Milan,

> Can you explain me in more details, what exactly I should do ?
> Should I change the source of Hb_SendMail() or make a work around function.

You can

1) Leave it as it is and just make sure that the email addresses you use
are correct. That is probably what most people do.

or you can

2) Borrow sendmail.prg into your project, rename the function to
my_SendMail() or whatever you like and make the changes I suggested.

or finally

3) We could fix the bug and post a .dif file here

Regards,
Klas

Milan Mehta

unread,
Apr 12, 2016, 7:31:53 AM4/12/16
to Harbour Users
Dear Klas,

I will be very happy if you can share the modified PRG here.

With best regards,

TIA
Milan

Klas Engwall

unread,
Apr 13, 2016, 7:19:56 PM4/13/16
to harbou...@googlegroups.com
Hi Milan,

> I will be very happy if you can share the modified PRG here.

I already shared the code in my previous message, but I have now posted
a patch in the Harbour-Devel newsgroup.

Regards,
Klas
Reply all
Reply to author
Forward
0 new messages