Sign in to follow this  
Followers 0
arcker

_INetSmtpMail and @error 4

18 posts in this topic

ok i want to use this function to send email to users of my firm by script

our smtp server doesn't require authlogin

we used the "blat.exe" before, but i want to use autoit now

when i launch the command to test, i've en @error 4

do you have any ideas ?

@ERROR = 4 - Unable to create socket

thx


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites



difficult to help you without a part of the script you are using :">

Share this post


Link to post
Share on other sites

I think it's dying here:

$v_Socket = TCPConnect($s_IPAddress, 25)
    If $v_Socket = -1 Then
        TCPShutdown()
        SetError(4)
        Return (0)
    EndIf

taken from inet.au3


Ben

Share this post


Link to post
Share on other sites

I think it's dying here:

$v_Socket = TCPConnect($s_IPAddress, 25)
    If $v_Socket = -1 Then
        TCPShutdown()
        SetError(4)
        Return (0)
    EndIf

taken from inet.au3

I have no difficulty to understand where the error=4 is set but I cannot help without the script used to call _INetSmtpMail :o:geek:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

hello jpm,

i've just tried the example for now

$s_SmtpServer = "172.20.0.2"
$s_Helo="HELO"; incase needed
$s_FromName = "testname"
$s_FromAddress = "my@email.com"
$s_ToAddress = "my@email.com"
$s_Subject = "Testing"
Dim $s_Body[2]
$s_Body[0] = "Testing the new email udf"
$s_Body[1] = "Second Line"
$Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress)
$err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

and here is the log when i try with blat (i've hidden personnal information)

Sending essai.txt to my@email.com
Login name is essai
<<<getline<<< 220 "smtpserver" ESMTP Service (Lotus Domino Release 6.5
.3FP1) ready at Fri, 24 Feb 2006 12:00:52 +0100

>>>putline>>> EHLO st49709

<<<getline<<< 250-"smtpserver" Hello st49709 ([172.20.100.42]), please
d to meet you
250-HELP
250-SIZE 15360000
250-8BITMIME
250 PIPELINING

>>>putline>>> MAIL From:<essai>

<<<getline<<< 250 essai... Sender OK

>>>putline>>> RCPT To: <my@email.com>

<<<getline<<< 250 my@email.com... Recipient OK

>>>putline>>> DATA

<<<getline<<< 354 Enter message, end with "." on a line by itself

<<<getline<<< 250 Message accepted for delivery

>>>putline>>> QUIT

<<<getline<<< 221 "smtpserver" SMTP Service closing transmission chann
el

thx !

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

Use the b_trace parameter to have a log of what AutoIt is sending/receiving.

The tests I did was only with a smtp server receiving HELO.

Perhaps yours need EHLO

You can search on the forum the thread I was in for debugging this UDF and use EtherReal to trace all the dialog in case of b_trace is not enough.

Good luck.

I was difficult to have the current state working That's all I can say. :o

Share this post


Link to post
Share on other sites

it's really strange because i've just test the function "tcpconnect", and it returns an error when i want to connect to port 25, and not on 80 for example

the problem is here, because when i will be able to connect to this port, i think the rest will follow


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

Thought I would give this a try, it appears i'm connecting ok, but when it gets to the body it errors out

The HELO and intermediate has been x'd out for security reasons

Any ideas?

08:08:00 HELO XXXXXXX
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 2 <- 500 Syntax error, command unrecognized.
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 2 <- 500 Syntax error, command unrecognized.
08:08:00 <-> 250

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thought I would give this a try, it appears i'm connecting ok, but when it gets to the body it errors out

The HELO and intermediate has been x'd out for security reasons

Any ideas?

08:08:00 HELO XXXXXXX
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 2 <- 500 Syntax error, command unrecognized.
08:08:00 HELO XXXXXXX
08:08:00 intermediate->220 xxxxxxxxxxxxxxxxxxxxxxxxx SMTP; Fri, 24 Feb 20
08:08:00 2 <- 500 Syntax error, command unrecognized.
08:08:00 <-> 250
I need the parameter used when calling _InetSmtpMail.

What is send is highly depending on them.

JUst XXX the parameter you don't want to be seen in the post.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

#include <INet.au3>

$s_SmtpServer = "xxxxxxxxxxxx"
$s_FromName = "Gary Frost"
$s_FromAddress = "Gary.Frost@xxxxxxxxxxxxxx"
$s_ToAddress = "xxxxxxxxxxxxxxxxxxxx"
$s_Subject = "My Test UDF"
Dim $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "", " ", 1)
$err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

I know the smpt mail works here I use it in apps daily thru perl scripts, don't know if it will help but here's the perl sub that works

sub Send_EMail_Via_SMTP #- Req = Net::SMTP
{
    my ($mailsvr, $user, $recipient, $mail_subj, $body) = @_;
    my ($smtp) = Net::SMTP->new($mailsvr) || return 1;
    Log("**** Sending E-Mail ****");
    $smtp->mail($user);
    $smtp->to($recipient);
    $smtp->data();
    $smtp->datasend("To: $recipient\n");
    $smtp->datasend("Subject: $mail_subj\n");
    $smtp->datasend("$body\n");
    $smtp->dataend();
    $smtp->quit;
    select (undef, undef, undef, 3);
}
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#include <INet.au3>

$s_SmtpServer = "xxxxxxxxxxxx"
$s_FromName = "Gary Frost"
$s_FromAddress = "Gary.Frost@xxxxxxxxxxxxxx"
$s_ToAddress = "xxxxxxxxxxxxxxxxxxxx"
$s_Subject = "My Test UDF"
Dim $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "", " ", 1)
$err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf

I know the smpt mail works here I use it in apps daily thru perl scripts, don't know if it will help but here's the perl sub that works

sub Send_EMail_Via_SMTP #- Req = Net::SMTP
{
    my ($mailsvr, $user, $recipient, $mail_subj, $body) = @_;
    my ($smtp) = Net::SMTP->new($mailsvr) || return 1;
    Log("**** Sending E-Mail ****");
    $smtp->mail($user);
    $smtp->to($recipient);
    $smtp->data();
    $smtp->datasend("To: $recipient\n");
    $smtp->datasend("Subject: $mail_subj\n");
    $smtp->datasend("$body\n");
    $smtp->dataend();
    $smtp->quit;
    select (undef, undef, undef, 3);
}
I imagine your perl stuff work but that does not help to understand why _InetSmtpMail is not working in a specific case.

Does the AutoIT script above is working. I have difficulty to help

Share this post


Link to post
Share on other sites

is there another way to send e-mail instead of establish the connection to port 25 using tcp connect ?

blat just send the message without establish a connection before, so how to do it with autoit, to force the message ?


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

is there another way to send e-mail instead of establish the connection to port 25 using tcp connect ?

blat just send the message without establish a connection before, so how to do it with autoit, to force the message ?

I think it is doing the same with the right parameters

Share this post


Link to post
Share on other sites

i know, but the function tcpconnect doesn't work, and that's a fact, and i don't know why, i don't know so much on tcp protocol

if you have an idea of a workaround, please tell me


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

i know, but the function tcpconnect doesn't work, and that's a fact, and i don't know why, i don't know so much on tcp protocol

if you have an idea of a workaround, please tell me

to help you you need to do as Wooltown did to debug it's connection.

see this topic

You will took a lot of effort for something I didn't write.

Basically I need the script you are using and the trace with etherreal free tool

Good luck :o

Share this post


Link to post
Share on other sites

i've tried with ethereal, and what is really strange is that he didn't record anything when i try tcpconnect with port 25...really strange

but when i try with port 80, ok no problem, but 80 is for the web site, it was just a verification

so, i would think that even if the port 25 is blocked or another, it would return something in ethereal, and i've nothing, just some arp packets a lot

i will retry tomorrow, but for now i've missed


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

here is the "superdebug" with blat

so his connection to 172.20.0.2 port 25 successful

so why tcpconnect ("172.20.0.2",25) doesn't work ?

superDebug: Hostname <shmnotes> resolved to ip address 172.20.0.2
superDebug: Official hostname is shmnotes.xxxxx
superDebug: Attempting to connect to ip address 172.20.0.2
superDebug: Received 114 bytes:
220 shmnotes.xxxxx ESMTP Service (Lotus Domino Release 6.5.3FP1) ready at Wed, 1 Mar 2006 10
<<<getline<<< 220 shmnotes.xxxxxx ESMTP Service (Lotus Domino Release 6.5.3FP1) ready at Wed,
superDebug: Attempting to send 14 bytes:
EHLO st49709
>>>putline>>> EHLO st49709
superDebug: Received 140 bytes:
250-shmnotes.xxxxx Hello st49709 ([172.20.100.42]), pleased to meet you
250-HELP
250-SIZE 15360000
250-8BITMIME
250 PIPELINING
<<<getline<<< 250-shmnotes.xxxx Hello st49709 ([172.20.100.42]), pleased to meet you
<<<getline<<< 250-HELP
<<<getline<<< 250-SIZE 15360000
<<<getline<<< 250-8BITMIME
<<<getline<<< 250 PIPELINING
Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

here is the "superdebug" with blat

so his connection to 172.20.0.2 port 25 successful

so why tcpconnect ("172.20.0.2",25) doesn't work ?

superDebug: Hostname <shmnotes> resolved to ip address 172.20.0.2
superDebug: Official hostname is shmnotes.xxxxx
superDebug: Attempting to connect to ip address 172.20.0.2
superDebug: Received 114 bytes:
220 shmnotes.xxxxx ESMTP Service (Lotus Domino Release 6.5.3FP1) ready at Wed, 1 Mar 2006 10
<<<getline<<< 220 shmnotes.xxxxxx ESMTP Service (Lotus Domino Release 6.5.3FP1) ready at Wed,
superDebug: Attempting to send 14 bytes:
EHLO st49709
>>>putline>>> EHLO st49709
superDebug: Received 140 bytes:
250-shmnotes.xxxxx Hello st49709 ([172.20.100.42]), pleased to meet you
250-HELP
250-SIZE 15360000
250-8BITMIME
250 PIPELINING
<<<getline<<< 250-shmnotes.xxxx Hello st49709 ([172.20.100.42]), pleased to meet you
<<<getline<<< 250-HELP
<<<getline<<< 250-SIZE 15360000
<<<getline<<< 250-8BITMIME
<<<getline<<< 250 PIPELINING
Post the script or PM me it so I can see the arguments you are using with _InetSmtpMail.

It could be you are not sending EHLO but HELO.

Share this post


Link to post
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
Sign in to follow this  
Followers 0