nobby Posted December 5, 2005 Share Posted December 5, 2005 I have a little script that checks for free disk space and sends the result via email using TCPsend The problem is that when the email arrives to the intended recipient, the FROM and TO fields are empty. Using the same sintax via telnet, TO and FROM are full. Could someone offer any advice? #include <GUIConstants.au3> #include<file.au3> $Free = DriveSpaceFree ( "c:" ) $Free = Round($Free, 2) $g_IP = "mailserver" Dim $sData[6] $sData[0] = "HELO domain" & @CRLF $sData[1] = "MAIL FROM: sender" & @CRLF $sData[2] = "RCPT TO: someone@domain" & @CRLF $sData[3] = "DATA" & @CRLF $sData[4] = "Subject: " & $Free & " MB free on C Drive" & @CRLF $sData[5] = "." & @CRLF TCPStartup() $socket = TCPConnect(TCPNameToIP($g_IP), 25) If $socket = -1 Then Exit Dim $ret[6] For $x = 0 To 5 $ret[$x] = TCPSend($socket, $sData[$x]) sleep(100) Next Thanks CheersNobby Link to comment Share on other sites More sharing options...
poisonkiller Posted December 5, 2005 Share Posted December 5, 2005 I think, that sending email with TCPSend() is not possible... Because usually TCPSend() needs TCPRecv() too. Im sorry if im wrong! Link to comment Share on other sites More sharing options...
themax90 Posted December 5, 2005 Share Posted December 5, 2005 Actually randallc it is quite possible if you go read my thread about Server communicator. Link to comment Share on other sites More sharing options...
Francis Lennert (France) Posted December 5, 2005 Share Posted December 5, 2005 Hello I agree...It's possible to do that an you are à 95% of the result. With you code, I receive the email with the "FROM" but not the "TO". But it arrives, so I am sure that it's just a question of one character less or more. I will try to find where with the help of Rebol (Internet script) because the sources of the "Send" command are readable. Regards, Francis Link to comment Share on other sites More sharing options...
svennie Posted December 5, 2005 Share Posted December 5, 2005 Not tested it, but try to replace sleep(100) with this: While 1 $Recv = TCPRecv($socket,1024) If $Recv <> "" Then ExitLoop WEnd Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
Francis Lennert (France) Posted December 5, 2005 Share Posted December 5, 2005 (edited) Hello,This works and Show the Sender and the TOer. I have found an exemple inthis forum which detailed how to send an Email with AutoIt ( I have searched HELO ).HTH,Regards,Francis #include <GUIConstants.au3> #include<file.au3> $Free = DriveSpaceFree ( "c:" ) $Free = Round($Free, 2) $g_IP = "MySmtp" Dim $sData[8] $sData[0] = "HELO MyDomain" & @CRLF $sData[1] = "MAIL FROM: <MyEmail> " & @CRLF $sData[2] = "RCPT TO: <MyEmail>" & @CRLF $sData[3] = "DATA" & @CRLF $sData[4] = "Subject: " & $Free & " Mb free on C Drive" & @CRLF $sData[5] = "From :<MyEmail>" & @CRLF $sData[6] = "To :<MyEmail>" & @CRLF $sData[7] = "." & @CRLF TCPStartup() $socket = TCPConnect(TCPNameToIP($g_IP), 25) If $socket = -1 Then Exit Dim $ret[8] For $x = 0 To 7 $ret[$x] = TCPSend($socket, $sData[$x]) sleep(100) Next Edited December 5, 2005 by Francis Lennert (France) Link to comment Share on other sites More sharing options...
nobby Posted December 7, 2005 Author Share Posted December 7, 2005 Thanks for your help et merci de votre aide...I found that it is very sensitive to syntax, such as the placement of colon#include <GUIConstants.au3>#include<file.au3>$Free = DriveSpaceFree ( "c:" )$Free = Round($Free, 2) $g_IP = "MySmtp" Dim $sData[8] $sData[0] = "HELO MyDomain" & @CRLF $sData[1] = "MAIL FROM: <MyEmail> " & @CRLF $sData[2] = "RCPT TO: <MyEmail>" & @CRLF $sData[3] = "DATA" & @CRLF $sData[4] = "Subject: " & $Free & " Mb free on C Drive" & @CRLF $sData[5] = "From :<MyEmail>" & @CRLF $sData[6] = "To :<MyEmail>" & @CRLF - does not work $sData[5] = "From: <MyEmail>" & @CRLF $sData[6] = "To: <MyEmail>" & @CRLF - works $sData[7] = "." & @CRLF TCPStartup() $socket = TCPConnect(TCPNameToIP($g_IP), 25) If $socket = -1 Then Exit Dim $ret[8] For $x = 0 To 7 $ret[$x] = TCPSend($socket, $sData[$x]) sleep(100)Next CheersNobby Link to comment Share on other sites More sharing options...
Nathan Posted December 7, 2005 Share Posted December 7, 2005 Sending a quit at the end is more stable. #include <GUIConstants.au3> #include<file.au3> $Free = DriveSpaceFree ( "c:" ) $Free = Round($Free, 2) $MailServer = "Server" $sender = "me@domain.com" $rcpt = "you@domain.com" $subject = "Free Space on C" $body = $Free & " Mb free on C Drive" Dim $sData[11] $sData[0] = "HELO" & @CRLF $sData[1] = "MAIL FROM: " & $sender & @CRLF $sData[2] = "RCPT TO: " & $rcpt & @CRLF $sData[3] = "DATA" & @CRLF $sData[4] = "Subject: " & $subject & @CRLF $sData[5] = "From: " & $sender & @CRLF $sData[6] = "To: " & $rcpt & @CRLF $sData[7] = "" & @CRLF $sData[8] = $body & @CRLF $sData[9] = "." & @CRLF $sData[10] = "QUIT" & @CRLF TCPStartup() $socket = TCPConnect(TCPNameToIP($MailServer), 25) If $socket = -1 Then Exit Dim $ret[11] For $x = 0 To 10 $ret[$x] = TCPSend($socket, $sData[$x]) sleep(100) Next Someone an idea how to AUTH LOGIN? 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