Web Connection
SMTP calls in VFP dev vs IIS EXE/COM
Gravatar is a globally recognized avatar based on your email address. SMTP calls in VFP dev vs IIS EXE/COM
  Richard Kaye
  All
  Jan 8, 2020 @ 12:55pm

OK. This is another fun one. I use the standard wwSMTP class to send emails from the application; both for sending error reports internally as well as sending emails to users of the application. The same internal relay is being used for all environments. When I run a process that sends an email in the VFP dev environment it works as expected and mail gets delivered. But when I do the same process via the compiled EXE in either file or COM mode, the mail does not get delivered. Here's a snippet from my email handler method:

LOCAL loIP as wwSMTP
DO wwSMTP
loIP = CREATEOBJECT([wwSMTP])
loIp.nMailMode = 0 && I've tried both classic and .net mode
loIP.cMailServer = THIS.oServer.oConfig.cAdminMailServer
loIP.cSenderName = m.sendername
loIP.cSenderEmail = m.senderemail
loIP.cContentType=[text/html]
loIP.cAttachment = ALLT(m.attachment)
loIP.cRecipient = ALLT(m.recipient)
loIP.cCCList = ALLT(m.cclist)
loIP.cBCCList = ALLT(m.bcclist)	
loIP.cSubject = ALLT(m.subject)
loIP.cMessage = ALLT(m.msg)
loIP.cAttachment = ALLT(m.attachment)
m.lRetval=loIP.SendMail() 
RELEASE m.loIP
IF m.lRetval
...<snip>
   m.lcMessage=[no errors from smtp service]
ELSE
   m.lcMessage=m.loIP.cErroRMSG 
ENDIF
this.logEvent(m.lcMessage)

(logEvent writes to a text file in the deploy/temp folder.) Every sendmail() call I've tested returns .t. regardless of which server/environment I am testing with. I've even done packet sniffing with my IT/network genies and verified that when the same code runs in VFP, I see SMTP packets. But when I do the same thing in the IIS application environment, no SMTP packets are captured. Any thoughts on what I'm missing? Location of DLLs? Execute permissions in folders?

Gravatar is a globally recognized avatar based on your email address. re: SMTP calls in VFP dev vs IIS EXE/COM
  Rick Strahl
  Richard Kaye
  Jan 8, 2020 @ 05:38pm

If you get a .t. result value, that means that the processing succeeded - the client communicated with the server and went through the whole process of submitting the message.

I suspect that you're maybe being blocked by your Mail Service or the receiving server...

If there was a connection issue or even a send error you wouldn't get a .t. result from SendMail().

I would check your mail server logs, to see how the requests are bounced. I've had issues like this with my mail provider (MailGun), and I had to make I use the right accounts and IP restrictions (if any)... all of those errors were trapped on the server, not while sending which is frustrating because you think all is well when it's really not.

Also make sure you are using the same accounts when testing.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP calls in VFP dev vs IIS EXE/COM
  Richard Kaye
  Rick Strahl
  Jan 9, 2020 @ 05:56am

Thanks, Rick. My logical brain agrees with you that if the SendMail() call returns .t. then the request was accepted by the SMTP service. I made the same point to my IT guys whilst looking at the raw TCPIP data. But my observational brain sees that when I test this in the VFP IDE I see SMTP packets and mail is delivered, and when I test via the IIS application there are no SMTP packets and the mail is not delivered. Still poking away at this and will update as I have more information. Perhaps I need to packet capture a different interface...

Gravatar is a globally recognized avatar based on your email address. re: SMTP calls in VFP dev vs IIS EXE/COM
  Rick Strahl
  Richard Kaye
  Jan 9, 2020 @ 01:15pm

Are you testing on the same machine?

You should also verify that the same data is sent. Are you setting the same target mail server domain etc. you might want to verfiy that the settings you're using are good.

But again - if any of that was truly invalid you'd see errors and SendMail() would either crash or return .F. or hang 20 seconds for a network timeout. Since you're seeing none of that I'm inclined to think that it's working.

How are you checking network traffic? Unless you're looking at connection data at the network card level you may not be able to monitor traffic since it'll be running in a different user context. If you're checking locally something like WireShark might be better to ensure you're looking at everything that's being sent/received. At minimum you should see SOMETHING getting sent to the target server for the handshake. If nothing at all gets sent that's highly suspect of a problem with whatever you're using to monitor the connection.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP calls in VFP dev vs IIS EXE/COM
  Richard Kaye
  Rick Strahl
  Jan 9, 2020 @ 01:26pm

Yes, all testing is on the same machine.
I'm using the same page to send the same message with the same attachment.
I'm using Wireshark and looking at all traffic on the ethernet interface.

Gravatar is a globally recognized avatar based on your email address. re: SMTP calls in VFP dev vs IIS EXE/COM
  Rick Strahl
  Richard Kaye
  Jan 9, 2020 @ 01:49pm

How are you checking for success of SendMail()? Are you logging the actual result?

I wonder if some error handler gets in the way and the call never completes and bypasses error handling/messages. You should log out the actual result with loServer.Trace() perhaps?

+++ Rick ---

© 1996-2024