Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing Function or Am I missing Something?

Status
Not open for further replies.

codetyko

Programmer
May 26, 2001
73
MY
I downloaded the faq "Sending Email without any third party OCX'. I took the code and put it in my project. Upon compiling, an error message pops up informing me that function "GetTimeZone" was not found and function "MID" was also not found. I manage to get the "GetTimeZone" function but not the "MID" function. It is contained in the Function UUDecode(strUUCodeData) and the code line is:

strDataLine = Mid(strDataLine, 2, intSymbols)

any guidance on this is appreciated.
 
codetyko

There is no mid function in Foxpro. Its more a VB function. Instead of strDataLine = Mid(strDataLine, 2, intSymbols) try

strDataLine = substr(strDataLine, 2, intSymbols)

I can only assume the author has replicated the mid function with a procdure of their own.

 
I shall try the vfp version provided. I believe that the author might have overlooked the vb function and has not converted it to vfp
 
My aplogies... I don't know exactly how that is still in there: I found it during my first test of UUDecode.... I must have posted an earlier copy of the code.

I converted UUDecode from VB code, and missed that in the first several passes. It'll be fixed soon.
 
to wgcs

Since we are in the subject of the sendmail program, I think I shall continue the thread from here. I tried to run your sendmail program from within my application using the following example syntax provided in the said program:


lRes=SendMail( 'My.mail.server.com', 'myReturnAddress@MyServer.com', 'DestinationAddress@YourServer.com', 'My Message Subject', 'My Message Body, line 1'+chr(13)+chr(10)+'Line 2, etc...', 'C:\My\Attached\File.dbf,C:\My\Other\Attached\File.pdf',oMyFeedBackObject)


The attachment was encoded by the program successfully (based on the message provided) and I managed to connect to the mail server but was met with a message "failed helo". What could be the cause?

Another point worth mentioning is that the following explanation was also provided in the program:



* oFeedBack: An object with a method "FeedBack" that
* expects one string property.
* If not provided, the feedback messages will
* be output to the console through "?".
* Pass .NULL. (or an object without "Feedback"
* method) to turn off all feedback.


Question: By "object" do you mean I have to define a form using the "createobject" command to direct the output of the progress messages? If so, where shall I put this code on the feedback object?

Kindly pardon my questions since this is my first project in VFP6 after migrating from FPW2.6a. Still have a steep ladder to climb.
 
The failed "HELO" message means that it connected to the server, and send the first handshake message "HELO ",
but it did not receive the "220 " response.

Possibly, but unlikely, the server that was specified is listening on the proper port (hence it connected), but is not a mail server, and so won't respond to a HELO command.

More likely, the server is just slow, and TIME_OUT needs to be increased. Someone else said they had to increase it to more than 10 before it would connect.


As for the feedback object, it can be any object. It just needs a method called "FeedBack" which accepts one String parameter. So, if you're calling SendMail from a form, you could just add a custom method to the form called "Feedback", and give it a parameter line:
Code:
LPARAMETERS cMsg

Or, you could make an object just for feedback:
Code:
oFB = CREATEOBJECT('MyFBObjClass')
IF SendMail(myserver', 'from@me.com', 'to_you@home.com', 'subject here', 'msg here', 'c:\File1.txt,c:\file2.exe', oFB)
  MESSAGEBOX('The send was a success')
ENDIF

DEFINE CLASS MyFBObjClass
  FUNCTION Feedback( cMsg )
    * Be careful that this function doesn't
    *   put VFP into a user input wait-state,
    *   since this method will be called many times
    *   during the email send, as chunks of the
    *   attachments are sent.
    WAIT WINDOW NOWAIT NOCLEAR cMsg
  ENDFUNC
ENDDEFINE
 
Dear wgcs
thanks very much. I'll try it out and let you know the outcome.
 
Hi there again

tested the sendmail code. increased the timeout variable to 40 with no success. The mail server name is valid. Is it possible that the mail server is expecting a username and password string? If it is, how do to provide it with the necessary parameters? Thanks in advance. Your great work will benefit vfp users worldwide.
 
That is possible: Our SMTP sender assumes the server validates by incoming IP instead of by username/password.

I'm looking back to the SMTP spec to see how user/pass is to be provided...

(thanks for giving feedback on this: Our company is already using this code commercially (since it's been stable in all tests) and I'll be very glad to iron our this wrinkle!)
 
A quick way (since I don't have an SMTP server that requires AUTH to test on) to determine if what is going wrong is the lack of authentication is to load this SMTPAUTH program, set it's SMTP server name to your SMTP server, and try using sendmail.prg telling it 127.0.0.1 is the SMTP server.

If it works properly, then your server does require authentication, and we can try to add this to SendMail.prg (and can test it on your server).

Here's where to get SMTPAUTH.EXE: (bin download: ftp://ftp.netwinsite.com/pub/authent/smtpauth102.exe )

In my research on SMTP, the HELO or EHLO (sendmail.prg uses HELO, which doesn't request the server to send extended information) statements SHOULD complete WITHOUT authentication. The AUTH statement should be the next-expected statement.
(and it's parameter should be encoded... so I need the encoding algorithm... anyone know it yet?)

You say:
and I managed to connect to the mail server but was met with a message "failed helo". What could be the cause?

The first thing an SMTP server is supposed to do is send "220 "+something-or-other... if it doesn't, or the connection is closed before SendMail.prg can send the "HELO " statement, then SendMail.prg will show "Failed HELO", Authentication doesn't come till later, so I'm leaning toward authentication not being the issue.


Give this a try: At the Command prompt, establish a telnet session to your SMTP server, and see how it responds to different commands.... you can do this by:

1) At Start->Run, type: COMMAND, Click "OK"

2) At the prompt, type: Telnet my.server.name 25 [enter]
(this will tell it to connect to port 25--SMTP;
From now on, you WON'T see anything you type, so type carefully.)

3) Note, first of all, if at the top of the screen is information starting with "220 "... if so, you are now connected to the SMTP server... if not, you are not, and all bets are off.

4) Type: HELO [enter]
(let us know how it responds... it should be the server's domain name preceeded by "250 " )

5) Type: EHLO [enter]
(let us know how it responds... it should be several lines starting with "250-", followed by the server's domain name preceeded by "250 ". if one of the "250-" lines has "AUTH" in it, then we DO need authentication)

6) Type: HELP [enter]
(...let us know... this should list all the available commands this server supports, each on a line starting with "214-")

With this info, we will know what we're dealing with.
 
SMTP supports multiple challenge-response authentication algorithms, and most of them are rather difficult to implement. Even the PLAIN TEXT method requires the password (and username? there's only one string!) to be encoded in base64 (which I think is built in STRCONV in VFP7 & 8, but we've got to code for v6... I'm sure there's one laying around somewhere... Anyone?),

Plus, I have no server to test with, So I'm really not looking forward to trying to write AUTH support for SMTP SendMail.prg..... And welcome any contributors..... Really....
 
wgcs,
I tried the first option using the SMTPAUTH program and setting the smtp server as '127.0.0.1' in the sendmail command 'lRes=SendMail( '127.0.0.1'...'. No connection could be established.

I tried your second suggestion but using another ISP's server (which I do not subscribe to) and manage to connect and see the details you described. The word '250-AUTH' is not there and only appear after typing 'HELP' with '214-AUTH'. Does this mean that I can 'piggyback' on this server to sent my email? Efforts using my subscribed mail server does not even connect. I wonder why.

Next, I changed my server to the working one and everything seems to be working fine until an error of 'failed data' was encountered. What could be the problem? The file is there and I used the old 8.3 format.

I used the syntax provided in your faq. Thanks in advance.
 
You should be able to use that other server..

After sending the DATA command, followed by the email headers (such as TO:, FROM:, SUBJECT:, etc), the SMTP server should return a "250 OK" response. The result from SendMail.prg saying "failed data" means it is NOT returning the "250 OK" response.

However, any of the following are also possible responses:
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
450 Requested mail action not taken: mailbox unavailable
[E.g., mailbox busy]
550 Requested action not taken: mailbox unavailable
[E.g., mailbox not found, no access]
451 Requested action aborted: error in processing
551 User not local; please try <forward-path>
452 Requested action not taken: insufficient system storage
552 Requested mail action aborted: exceeded storage allocation
553 Requested action not taken: mailbox name not allowed
[E.g., mailbox syntax incorrect]
354 Start mail input; end with <CRLF>.<CRLF>
554 Transaction failed

I suspect it's returning 551, because the SMTP server will accept mail addressed to one of its own subscribers from anywhere, but it won't &quot;relay&quot; mail from just anywhere to anywhere else. (otherwise, anyone could use it to send spam)

Have you tried the Telnet method of testing what your server's response is? What are the settings in your Email software, which do work? is the mail server just called &quot;Mail&quot;? I've heard that DNS sometimes has trouble with the unqualified &quot;mail&quot; name... it's better to use the fully qualified &quot;popmail.somesubdomain.myispdomain.com&quot; form.
 
using the telnet method, my mail server responded for a brief second then display a message &quot;connection lost&quot;. However, using another pc (XP), I could connect to the server. I am using Win2000. What could be the problem?
 
wgcs,
I reproduced the response I get when using the other pc (Windows XP Pro):

c:>telnet smtp.time.net.my 25
220 toman.time.net.my ESMTP
helo
250 toman.time.net.my
ehlo
250-toman.time.net.my
250-PIPELINING
250-8BITMINE
250 SIZE 30000000
HELP
214 qmail home page:
hope this will give some insight. thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top