Jump to content

Problem with _INetSmtpMail


 Share

Recommended Posts

Hi,

my code did work fine with AutoIt 3.3.8.1. I upgraded to 3.3.14.0. After compiling with 3.3.14.0 the program gives return code 50 when using _INetSmtpMail.

I did find this in the changelog:
Fixed: _INetSmtpMail() SmtpServer IPaddr checking.

What does that mean exactly? What do I have to change in my code?

This is the line that gives the error:
$Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress1, $s_Subject, $as_Body)
 

Regards
Dolphins

Link to comment
Share on other sites

Hi.

Show your SciTE console output pane.

mLipok

 

EDIT:

btw.

I upgraded to 3.3.14.0.

Did you notice this: Au3.3.14.2 Released  

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Hi,

I did downgrade to 3.3.14.0 since 3.3.14.2 makes trouble with my AntiVirus; the changelog is also small, and there is nothing related to E-Mails, so I guess this would not fix my Problem.

"Show your SciTE console output pane."
I am not sure what exactly you want. I have a development machine with the au3 source; on this machine I compile the Project (consists of several programs) to exe. Then I copy the exe-files to the target machine. When I start the exe on the target machine I get error 50.
 

Please let me know what more informations you need exactly. Thanks a lot!

Edited by dolphins
Link to comment
Share on other sites

I can show you this:

If $s_ToAddress1 <> "" Then

       $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress1, $s_Subject, $as_Body)
    EndIf



    Local $err = @error

If $Response = 1 Then

Sub_Debug("Sub_E_MailSenden 2a: Mail ok")
Else
Sub_Debug("Sub_E_MailSenden 2a: Mail failed with error code " & $err)
EndIf

And this comes in SciTE in the console output pane:
Sub_E_MailSenden 2a: Mail failed with error code 50

Sorry for the bad formatting of the code.

Regards
Dolphins

Edited by dolphins
Link to comment
Share on other sites

Sub_E_MailSenden 2a: Mail failed with error code 50

From helpfile:

5x - Cannot open SMTP session. x indicates the index number of last command issued to the SMTP server.

so check your parameters used to this function.

and FIREWALLs ,  AV Programs etc....

 

btw.
here you have better formating/written code:

If $s_ToAddress1 <> "" Then
    _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress1, $s_Subject, $as_Body)
    If @error Then
        Sub_Debug("Sub_E_MailSenden 2a: Mail failed with error code " & @error)
    Else
        Sub_Debug("Sub_E_MailSenden 2a: Mail ok")
    EndIf
EndIf

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Thanks for your answer.

Program compiled with 3.3.8.1 works
Program compiled with 3.3.14.0 doesn't work -> error 50

How can this be related to a firewall? The AV program doesn't come up and also has nothing in the log files. To check if it is the AV program: I stopped the AV program fully and the error still comes up. The Firewall Administrator was also so nice to take a look in the firewall log files: nothing.

Something was changed with _INetSmtpMail. As I said in my first post, there is this entry in the changelog:
Fixed: _INetSmtpMail() SmtpServer IPaddr checking.

What exactly was changed? What do I need to change in the code to make it working again? Is there a bug now in the function?

Link to comment
Share on other sites

  • 3 months later...

I just found out that I got the same issue (or very similar)
I used to have a app compiled 09 Aug 2011 (with 3.3.6.1)
For a small enhancement on the logging I compiled it again with 3.3.14.2.

And guess what I got a @error=4 (4 - Unable to create socket)

In case I transfer this to different PC the problem remains.
(both do runthe same AV/FW settings), but using the old compiled version it works on both PCs. So I would also tend to say it is not a matter a AV/FW. But that is just a remark, not something investigated.

I will also try the 3.3.10.2 as in 3.3.12.0 was a change (Fixed: _INetSmtpMail() SmtpServer IPaddr checking.)

(I also saw that in 3.3.10.0 there was a change in  ( InetConstants.au3 for use with Inet functions. See related function documentation for more details.)

Maybe that does not solve the issue, but at least it might help others as well.
I will report back when done. (just to make it complete)
As a example I will use the sample code from the helpfile.

=======================

Ok, here we go (not knowing that if it makes sense), of course here I removed my server address, from and to. But trust me they are always the sam ein all three tests ....

Code compiled with 3.3.8.1 - Working - Mail send

 

#AutoIt3Wrapper_AutoIt3=C:\Autoit3_previousversions\autoit-v3.3.8.1\install\Autoit3.exe
#AutoIt3Wrapper_Autoit3Dir=C:\Autoit3_previousversions\autoit-v3.3.8.1\install
#include <Inet.au3>

Local $s_SmtpServer = "MAILSERVERADRESS.COM"
Local $s_FromName = "Mail test"
Local $s_FromAddress = "FROMADRESS"
Local $s_ToAddress = "TOADRESS"
Local $s_Subject = "Test 3381"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

 

Code compiled with 3.3.10.2 - Working - Mail send

#AutoIt3Wrapper_AutoIt3=C:\Autoit3_previousversions\autoit-v3.3.10.2\install\Autoit3.exe
#AutoIt3Wrapper_Autoit3Dir=C:\Autoit3_previousversions\autoit-v3.3.10.2\install
#include <Inet.au3>

Local $s_SmtpServer = "MAILSERVERADRESS.COM"
Local $s_FromName = "Mail test"
Local $s_FromAddress = "FROMADRESS"
Local $s_ToAddress = "TOADRESS"
Local $s_Subject = "Test 33100"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

Code compiled with 3.3.14.2 - Failed - Mail not send @error=4

I also tried to open the debug window on the _InetSmtpMail but it does not open.

#include <Inet.au3>

Local $s_SmtpServer = "MAILSERVERADRESS.COM"
Local $s_FromName = "Mail test"
Local $s_FromAddress = "FROMADRESS"
Local $s_ToAddress = "TOADRESS"
Local $s_Subject = "Test 33142"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

 

I still consider this not a general fault, I traced down the error to TCPConnect().

In the 3.3.14.2 version the same TCPConnect shows me 10060.

So I checked the sample code on TCPConnect.

I ran the Sample 1 (non-timeout) got the 10060 error, than I tried the timeout-version, and it worked (using PORT 25).

It looks like the used SMTP Server needs some time to conenct to. I tried to include these to INet.au3 , but still it fails.

Currently I stop this, as it looks like this is not a real issue of Autoit (even the timout in _SMTPmail would be nice), and I got a working option (using older Autoit).

I replaced in INet.Au3 (3.3.14.2) the line 145 with this (taken from the sample code of TCPConnect)

; Local $vSocket = TCPConnect($s_IPAddress, 25)
    Local $vSocket
    local $nMaxTimeout
    While 1
        ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
        $vSocket = TCPConnect($s_IPAddress, 25)
        
        ; If an error occurred display the error code and return False.
        If @error = 10060 Then
            ; Timeout occurs try again
            $nMaxTimeout -= 1
            If $nMaxTimeout < 0 Then
                MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, after " & 60 - $nMaxTimeout & " TimeOut" & $s_IPAddress)
                Return False
            EndIf
            ContinueLoop
        ElseIf @error Then
            $iError = @error
            ; The server is probably offline/port is not opened on the server.
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
            Return False
        Else
            MsgBox($MB_SYSTEMMODAL, "", "Connection successful after " & 60 - $nMaxTimeout & " TimeOut")
            ExitLoop
        EndIf

    WEnd


==============

Sorry for posting so much, and not find any good solution except something that relies to my used server, but at least I someone falls in the same pit....try aolder version (but that was already doen by the post of dolphins.

 

Edited by Tankbuster
Additional feedback/Comment
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...