Jump to content

Sending mail using TCPsend


nobby
 Share

Recommended Posts

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

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

Hello,

This works and Show the Sender and the TOer. I have found an exemple in

this 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 by Francis Lennert (France)
Link to comment
Share on other sites

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

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

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...