PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD21]SMTP Mail Fails
[WD21]SMTP Mail Fails
Iniciado por guest, 16,nov. 2016 09:33 - 12 respuestas
Publicado el 16,noviembre 2016 - 09:33
Hi

Using Windows 2012 R2.
IIS 7 and IIS 6 for the SMTP Virtual Server
In the past I sent mail through port 25 but now my ISP said I need to use port 587. Easy I thought but not.

Changed the port in IIS 6 SMTP Server. Tested with Telnet and Powershell and the test emails are being delivered.

Created a text file and save it in \mailroot\pickup and it is delivered.

but from Windev no luck.

MyNewSession is EmailSMTPSession
MyNewSession..ServerAddress = "smtp.mweb.co.za"
MyNewSession..Option = emailOptionSecuredTLS
//Tried this as well
//MyNewSession..Option = emailOptionDefault
MyNewSession..Name = "MyEmailAddress"
MyNewSession..Password = "MyPassword"
MyNewSession..Port = 587
EmailSetTimeOut(10)
IF EmailStartSession(MyNewSession) = True THEN
MyMessage is Email
MyMessage..Sender = "MyEmailAddress"
Add(MyMessage..Recipient, "let@iafrica,com")
MyMessage..Subject = "Hello World"
// Send the message
EmailSendMessage(MyNewSession, MyMessage)
EmailCloseSession(MyNewSession)
ELSE
Error("Unable to establish connection", ErrorInfo(), ...
"In case of time-out, check the parameters of the "+ ...
"""Firewall"" on the port used (587)")
END

Nothing is going out. I cannot see anything being placed in the \mailroot\pickup folder or \mailroot\queue folder.

I saw a previous post where DerekT mentioned that 'Allow access from less secure apps' must be turned on in the mail configuration but to get my ISP to look at that seems impossible.

Any help will be much appreciated.



Ericus Steyn
Publicado el 16,noviembre 2016 - 10:21
Hi Ericus,

AFAIK, for SENDING authenticated (tls) emails, you NEED to use EmailStartSMTPSession, and not emailstartsession.

Best regards
Publicado el 16,noviembre 2016 - 12:30
Hallo Fabrice

Thanks. I see that before it was in fact send as

MySession..Option = emailOptionDefault and not authenticated.

In that case it worked using the variable EMailSMTPSession and EMailStartSession.

But, as I say, even using the code exactly as before it just wont go out through port 587.

Regards


Ericus Steyn
Publicado el 16,noviembre 2016 - 13:45
Hi

Have you tried TELNET to port 587 on yr server to see it's blocked or not?

And ensure to open a firewall for this port?

HTH

Cheers

King
Publicado el 16,noviembre 2016 - 13:58
May also try to uncheck TLS encryption on IIS for short to see it can go or not.

HTH

Cheers

King
Publicado el 16,noviembre 2016 - 15:02
Thanks King

Yes the mails are going through with telnet and Powershell. Also if I create a text file in the right format and put it in \mailroot\pickup.

TLS Encryption is not enabled.

Everything seem to be happening correctly. No errors given and the mails seems to go out but it is never delivered.



Ericus Steyn
Publicado el 16,noviembre 2016 - 16:02
Ericus,

can it be the comma in your emailaddress?:

Add(MyMessage..Recipient, "let@iafrica,com")
Publicado el 16,noviembre 2016 - 16:20
Hi

I test on my mailServer and it's fine as below:


sUserName is string= "senderLegitEmail@account.com"
sUserPass is string = "senderPassword"
sUserSmtp is string= "smtp.web.testSite"
nUserPort is int = 587

// Send an email using the secure SMTP protocol
EmailReset()
EmailSetTimeOut(2)
//JUST a test
trace( EmailStartSMTPSession(sUserName, sUserPass, sUserSmtp,nUserPort ,EmailSynchronous,optionSSL) )
Email.NbRecipient = 1
IF EmailStartSMTPSession(sUserName, sUserPass, sUserSmtp,nUserPort ,EmailSynchronous,optionSSL) = True THEN

Email.NbRecipient = 1
IF NoSpace(sUserDest) <> "" THEN
// Email.NbCc = 1
// Email.Cc = NoSpace(sUserDest)
END

Email.Recipient = "tryTestThisToAnyOneWhoHas@hotmail.com" //sUserDest
Email.Subject = "Hi" + timeSys()
Email.Sender = sUserDest
Email.Message = "Test"
END
// Sends the email
IF EmailSendMessage(sUserName) = False THEN
Error()
else
trace("message sent")
END
EmailCloseSession(sUserName)


Give it a shot.

HTH

Cheers
King
Publicado el 16,noviembre 2016 - 23:55
Thanks Derek/King

I have tried what I think is everything now. There is no error in the application but the mails are not going out and I have no idea where they are because no-one are receiving them.

Downloaded a small application SMTPInfo that I can just fire up with a ExeRun and some parameters and my emails are sent out, with attachments, with HTML and everything else I had before so for now going to leave it like this.

Regards



Ericus Steyn
Publicado el 17,noviembre 2016 - 14:51
Hi,

This code works for me !

PROCEDURE SendErrorAlert(sMessage is string, bError is boolean) //Start a SMTP session sSubjectPart is string EmailSetTimeOut(5) MySession is EmailSMTPSession MySession.Name = MySettings.m_EmailConfig.sEmailUser MySession.Password = MySettings.m_EmailConfig.sEmailPassword MySession.ServerAddress = MySettings.m_EmailConfig.sEmailSmtpServer MySession.Port = MySettings.m_EmailConfig.nEmailSmtpPort IF MySettings.m_EmailConfig.bEmailSecure THEN MySession..Option = emailOptionSecuredTLS END IF NOT EmailStartSession(MySession) THEN MyAppLogger.AddMes(ErrorInfo(),2) RETURN END //Reset the email variables to zero MyEmail is Email // Build E-mail Message MyEmail.Sender = MySettings.m_EmailConfig.sEmailFrom Add(MyEmail.Recipient, MySettings.m_EmailConfig.sEmailTo) //Subject and content of message IF bError THEN sSubjectPart = "ALERT" ELSE sSubjectPart = "OK" END MyEmail.Subject = StringBuild("APPLICATION %1 : %2 (%3) - %4 ",sSubjectPart,NetMachineName(),MySettings.m_sNodeName,WXTools::ToSQLDateTime(SysDateTime())) MyEmail.Message = sMessage MyEmail.HTML = "" //Send the message EmailSendMessage(MySession,MyEmail) IF ErrorOccurred THEN Error(ErrorInfo(errSummary)) END //Close the SMTP session EmailCloseSession(MySession)
Hope you get it working !
Danny
Publicado el 18,noviembre 2016 - 22:54
Hi Danny/King

I think I have narrowed the issue down and it is this.

My email account is info@plumaccounting.co.za
My clients send their emails with invoices etc. to their customers through my application. I store every email in a database and forward it every so often.

When I send out the message and my client's customers reply to that mail, the email must go to my client, it must not come to info@plumaccounting.co.za

So I do the following:

MyMessage..Sender = EMAILSTORE.SenderEMail
MyMessage..SenderAddress = "info@plumaccounting.co.za"

But I keep getting this error:

Content of Email.Sender not recognized by server. Transaction denied.
Timeout:
Failure sending recipients.
The last response of SMTP server is:
<503 sender already given
503 sender already given

If I send mails with info@plumaccounting as Sender without a SenderAddress then it works.

Any ideas?

Ericus Steyn
Publicado el 18,noviembre 2016 - 23:37
Ericus

Looks like your Windows Server has the suffix and default to ".co.za".
Check your forest tree/domain name DNS to see if the translation being done
somewhere then uncheck it in order to supply it as full domain name instead.

What version of yr wb/wd (32 or 64-bit)?

Pls ensure yr apps 64-bit running 64-bit machine.

HTH

King
Publicado el 18,noviembre 2016 - 23:46
See this link:

https://technet.microsoft.com/en-us/library/cc731648(v=ws.11).aspx

HTH

King