pshankland Posted July 25, 2007 Share Posted July 25, 2007 I have the following script which is simply meant to send an Email with the users current private IP address, but when I run it I keep getting an @error value of 0 returned: #include <Inet.au3> $PublicIP = _GetIP() $PrivateIP = @IPAddress1 $SMTPServer = "192.168.1.1" $FromName = @UserName $FromAddress = $FromName & "@SOMEWHERE.COM" $ToAddress = "SOMEONE@SOMEWHERE.COM" $Subject = $FromName & "'s Private IP Address" $Body = $FromName & "'s IP Address is: " & $PrivateIP $Err = @error $Response = _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body) If $Response = 1 Then MsgBox(0, "Success", "Completed") Else MsgBox(0, "Error", "Failed - Please contact whoever sent you this program" & @CRLF & "Error Code: " & $Err) EndIf As I said, I always get the error but with a value of 0. I have checked through the SMTP servers logs and this program isn't even getting as far as connecting. Any suggestions? Thanks. Link to comment Share on other sites More sharing options...
lod3n Posted July 25, 2007 Share Posted July 25, 2007 What happens when you try to connect to your mail server using Telnet? At the Command Prompt, type this: telnet 192.168.1.1 25 Your mail server should respond in some way. If that isn't happening, then your mail server is not running on 192.168.1.1, or it's not working correctly. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
pshankland Posted July 26, 2007 Author Share Posted July 26, 2007 When I telnet to the SMTP server it responds immediatly. Any other suggestions? Thanks. Link to comment Share on other sites More sharing options...
pshankland Posted July 26, 2007 Author Share Posted July 26, 2007 Have attached the response from a telnet connection to my SMTP server. Does anyone know what might be wrong with the script I have written? Thanks. Link to comment Share on other sites More sharing options...
lod3n Posted July 26, 2007 Share Posted July 26, 2007 (edited) Okay, it looks like you don't have any fundamental connectivity issues. I suspect that your mail server is expecting something from a mail sending connection that your system just isn't sending. Try typing this into your telnet session, and post the results here. HELO MAIL FROM: <your.address@domain.com> RCPT TO: <target.address@domain.com> DATA From: Your Name <your.address@domain.com> To: Target Name <target.address@domain.com> Subject: Your Subject Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII . {this line inserted to indicate a carriage return after the period is required.} You have to type all of the carriage returns as shown for it to work. This is exactly what the _INetSmtpMail script is doing, but this way you can see exactly what your mail server is doing with it. Edited July 26, 2007 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
lod3n Posted July 26, 2007 Share Posted July 26, 2007 Looking at the _INetSmtpMail function more closely, I see that it has a Trace option, which you can turn on to see the same information. Do that instead, it's much easier. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 26, 2007 Share Posted July 26, 2007 Do you have a software firewall that is restricting access to either the AutoIt3 executable or the compiled script? When I tried running a local mail server, my software firewall caught it even though it was connecting to the local computer. Link to comment Share on other sites More sharing options...
pshankland Posted July 26, 2007 Author Share Posted July 26, 2007 Have attached the telnet output. I received the Email at my inbox no problems. Have no software firewall sitting in between my machine and the SMTP server and the server has no restrictions on accepting connections. Haven't look at the trace option, but will take a look now. Thanks for the help... keep it coming Link to comment Share on other sites More sharing options...
pshankland Posted July 26, 2007 Author Share Posted July 26, 2007 No clue on how to use the trace param within _INetSmtpMail, sorry. Link to comment Share on other sites More sharing options...
lod3n Posted July 26, 2007 Share Posted July 26, 2007 Well, it's in the manual. But here you go: $Response = _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body,"","",1) ; the 1 turns on trace, default is 0 [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
pshankland Posted July 27, 2007 Author Share Posted July 27, 2007 Attached is the output from trace. Is there anything obviously wrong? Thanks. Link to comment Share on other sites More sharing options...
lod3n Posted July 27, 2007 Share Posted July 27, 2007 Yes. There should be more there. Try the first thing I said, about typing the commands into the Telnet session. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
pshankland Posted July 27, 2007 Author Share Posted July 27, 2007 Yes. There should be more there. Try the first thing I said, about typing the commands into the Telnet session.I have done this already and posted the results here. In post 8 you will see the telnet session where I typed in exactly as you suggested. Link to comment Share on other sites More sharing options...
lod3n Posted July 27, 2007 Share Posted July 27, 2007 (edited) Oops, sorry I must have missed that. Good that your SMTP server is working, but I am clueless why the function behaves as it does. Here's another approach. This function should work in place of the one you are using, but it uses COM instead. Func _CDOSendMail($SMTPServer, $FromAddress, $ToAddress, $Subject, $Body, $attachment="") $objEmail = ObjCreate("CDO.Message") $objEmail.From = $from $objEmail.To = $to $objEmail.Subject = $subject ;$objEmail.HTMLBody = $body $objEmail.Textbody = $body if $attachment <> "" then if fileexists($attachment) Then $objEmail.AddAttachment($attachment) EndIf EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ;cdoSendUsingPort $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $SMTPServer $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 $objEmail.Configuration.Fields.Update $objEmail.Send if @error then ConsoleWrite("Email send error!" & @crlf) ;should do something else too... maybe a netmessage? EndIf EndFunc Edited July 27, 2007 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now