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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Using "SendSmtpEmail" 1

Status
Not open for further replies.

gmattox

Programmer
Nov 5, 2001
15
US
I have just started trying to use email with VFP. Liked the looks of SendSmtpEmail. But, I have run into a couple of problems right off the bat. First it would not connect if I put a port number on the servername, second, I am now getting "Failed HELO" message. I believe I have the latest version and was wondering if there may be more documentation on this somewhere.
Thanks
Gary in Alabama
 
Mike,
Thanks for replying. I think I do 1and1.com hosts my website and emails and bellsouth dsl provides my service. I have been developing in fox since '84 but just now getting into this web stuff.
Gary
 
Try using smtp.bellsouth.net as the outgoing server and leave the port as it was default
wjwjr
 
Using "smtp.bellsouth.net" didn't help either.
Thanks though.
 
Usually, service providers associate your account with one IP. For instance, if you sign up with Bellsouth for your home ISP, they will associate that IP with your account. Your web host will of course, have a different IP. The issue there is that trying to send mail from your web host, which is using a different IP, you would be in effect trying to relay mail from your web host. (Spam alert!)

You may have to set up some sort of a deal with Bellsouth to allow you to relay from your web host.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
The routine was connecting fine, it was after it connected and hit the HELO statement when I got the message "HELO Failed".
Thanks Again
Gary
 

I think I too has tried that method from wgcs and found it was not able to make it work for me either, so I reverted to different method.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Is there another email method that does not require any third party software? This package is to be distributed to many different users. They will be emailing batches of emails and single emails with and without attachments. And, we don't want to require that they have other software.

Thanks
Gary
 

Well, if you consider a DLL a third party then no. You need a transport of some kind. Winsock is one of them, although it comes with Windows, CDO is another that you can distribute with your application, MAPI is another (which comes mostly with Windows), which is limited. Blat is another, which is a DLL that does not require registration. Most of the solutions are free, but they all require a third party of somekind and in some case are not part Windows.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Hi... I haven't been around as often as in the past, so I just now saw this thread.

The latest version of SendSmtpEmail is usually at .. I try to keep faq184-3840 up to date, too, but I sometimes make mistakes.

I'm always interested in troubles people have making it work, because we have it in a shipping product, and want it to be as robust as possible.

It seems someone else already found the problem with SendSmtpEmail not handling ":port" on the server name, and fixed it on the fox wiki.
..
One reason I've seen HELO fail is that some smtp servers require use of EHLO instead, (which enabled other features), such as when a login is required.

However, authentication wasn't part of the code when I released it to the public... we worked on that internally and had multiple issues. Here is a code snippet that can be inserted into the public code (I don't really have time to integrate it now... my private code is in a framework (of sorts), so it isn't simply a matter of chopping out the whole function). (This code uses STRCONV to do Base64 encoding, so it requires VFP7 or 8 (I forget which introduced that...). You could make it use instead if you are using VFP6):

Code:
** SMTP authentication code:
    THIS.GiveFeedback( 'CONNECTED TO SMTP SERVER' )
    
    IF EMPTY(tcUser+tcPwd)
      if not THIS.ReadWrite("HELO " + alltrim(lcServ)) = 250  && v12.19 wgcs..was StrServ
        THIS.GiveFeedback( [ERROR: "HELO ] + alltrim(lcServ) +[" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
        RETURN .F.
      endif
    else
      if not THIS.ReadWrite("EHLO " + alltrim(lcServ)) = 250  && v12.19 wgcs..was StrServ
        THIS.GiveFeedback( [ERROR: "EHLO ] + alltrim(lcServ) +[" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
        RETURN .F.
      endif
  
      THIS.GiveFeedback( 'AUTHENTICATING TO SMTP SERVER' )
      
*!*	      lcResp = STRCONV(tcUser+CHR(0)+tcUser+CHR(0)+tcPwd,13)
*!*	      if not THIS.ReadWrite("AUTH PLAIN "+lcResp ) = 235
*!*	        THIS.GiveFeedback( [ERROR: "AUTH PLAIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
*!*	        RETURN .F.
*!*	      ENDIF
      DO CASE
        CASE UPPER(ALLTRIM(tcAuthMeth))=='PLAIN'
          if not THIS.ReadWrite("AUTH PLAIN" ) = 334
            THIS.GiveFeedback( [ERROR: "AUTH PLAIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
            RETURN .F.
          ENDIF
          if not THIS.ReadWrite(tcUser) = 334
            THIS.GiveFeedback( [ERROR: "AUTH PLAIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
            RETURN .F.
          endif
          if not THIS.ReadWrite(tcPwd) = 235
            THIS.GiveFeedback( [ERROR: "AUTH PLAIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])
            RETURN .F.
          ENDIF
          
        CASE UPPER(tcAuthMeth)='PLAIN (TYPE 2)' && Base64Encode( CHR(0)+cUserName+CHR(0)+cPwd )
          if not THIS.ReadWrite("AUTH PLAIN "+STRCONV(CHR(0)+tcUser+CHR(0)+tcPwd,13)  ) = 334
            THIS.GiveFeedback( [ERROR: "AUTH PLAIN" TYPE 2 FAILED], [(Server Returned "]+THIS.SrvRet+[")])  && v12.27 wgcs
            RETURN .F.
          ENDIF
          
        CASE UPPER(tcAuthMeth)='LOGIN'  && v12.26 wgcs
          if not THIS.ReadWrite("AUTH LOGIN" ) = 334
            THIS.GiveFeedback( [ERROR: "AUTH LOGIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])   && v12.27 wgcs
            RETURN .F.
          ENDIF
          
          if not THIS.ReadWrite( STRCONV(tcUser,13) ) = 334
            THIS.GiveFeedback( [ERROR: "AUTH LOGIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])  && v12.27 wgcs
            RETURN .F.
          endif
          if not THIS.ReadWrite( STRCONV(tcPwd,13) ) = 235
            THIS.GiveFeedback( [ERROR: "AUTH LOGIN" FAILED], [(Server Returned "]+THIS.SrvRet+[")])  && v12.27 wgcs
            RETURN .F.
          endif
      ENDCASE



- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Okay Guys, I got SendSmtpEmail routine working if I set all the variables in the top of the routine and run it as a pgm. If I setup a form to set the variables and call the routine I get nothing. What am I doing wrong.

Thanks for your patience,
Gary
 
Try putting a line in the beginning of the routine that shows what the parameters it received are...
( something like:
Code:
STRTOFILE(TTOS(DATETIME())+' SendSmtpEmail( '+Tran(strServ)+', '+tran(strFrom)+', '+tran(strTo)+', '+tran(strSubj)+', '+tran(strMsg)+' )', 'c:\temp\Debug.txt')
... then, after running, open c:\temp\Debug.txt and see exactly what the parameter values were. )

First, put this right after where you manually set the parameters. Take careful note of the value of each parameter.

Then, comment out your manual varible set code, and run it again from the form, and carefully compare the parameter values as they appear this time.

I expect that there is a problem in the way you are retreiving the values from the form fields.


- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Bill, Mike and the rest,
Thanks for the help. Got it working perfectly (so far). Sending one or sending mass amounts one at a time. I do appreciate it.
Gary
 
Glad you got it working!

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top