Jump to content



Photo

code of sending Email through Telnet


  • Please log in to reply
14 replies to this topic

#1 Clever1mba

Clever1mba

    Prodigy

  • Banned (NOT IN USE)
  • 177 posts

Posted 01 July 2005 - 02:42 PM

hello i hope u guyz like this email sending code
but i need to improve this code
i have problem in tcpRecv need to get all recv command and display
any one like to improve this code then it will be gr8


#include <GUIConstants.au3>
GUICreate("SMTP 25 1.1 by AsimZameer")
GUICtrlCreateLabel ("Smtp :",  20, 10, 50)
GUICtrlCreateLabel ("From :",  20, 40, 50)
GUICtrlCreateLabel ("To :",  20, 70, 50)
GUICtrlCreateLabel ("Name :",  20, 100, 50)
GUICtrlCreateLabel ("Subject :",  20, 130, 50)
GUICtrlCreateLabel ("Body :",  20, 160, 50)
GUICtrlCreateLabel ("Status :",  5, 215, 50)

$input1 = GUICtrlCreateInput("mx1.mail.yahoo.com",70,10,250,20)
$input2 = GUICtrlCreateInput("snip",70,40,250,20)
$input3 = GUICtrlCreateInput("snip",70,70,250,20)
$input4 = GUICtrlCreateInput("asimzameer",70,100,250,20)
$input5 = GUICtrlCreateInput("test message",70,130,250,20)
$input6 = GUICtrlCreateInput("Hello WOW ASIM SMTP really Works",70,160,250,20)
$myedit=GUICtrlCreateEdit ("Readme: After click on Send Button Wait Until status = 3 When Status = 3 it Means Email Successfully sent & Please Fill all Boxs Correctly If SMTP Address Not Works Automatically Exit and Close "& @CRLF, 1,230,400,70,$WS_DISABLED)
$btn = GUICtrlCreateButton ("Send", 160, 310, 60, 20)
GUISetState ()
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $btn Then
$g_IP = GUICtrlRead($input1)
$sData1  = "HELO " & GUICtrlRead($input4) & @CRLF
$sData2  = "MAIL FROM: <" & GUICtrlRead($input2) &">" & @CRLF
$sData3  = "RCPT TO: <" & GUICtrlRead($input3) &"> "& @CRLF
$sData4  = "DATA" & @CRLF
$sData5  = "From:" & GUICtrlRead($input4) & "< " & GUICtrlRead($input2) &" >" & @CRLF
$sData6  = "To:" & GUICtrlRead($input3) & @CRLF
$sData7  = "Subject:" & GUICtrlRead($input5) & @CRLF
$sData8  = "Sender: Microsoft Outlook Express 6.00.2800.1158" & @CRLF
$sData9  = "Mime-Version: 1.0" & @CRLF
$sData10 = "Content-Type: text/plain; charset=US-ASCII" & @CRLF
$sData11 = @CRLF
$sData12 = GUICtrlRead($input6) & @CRLF
$sData13 = "." & @CRLF
TCPStartUp()
$socket = TCPConnect(TCPNameToIP($g_IP), 25)
If $socket = -1 Then Exit
$ret1  = GUICtrlSetData ($myedit,TCPSend($socket, $sData1) )
sleep(100)
$ret2  = GUICtrlSetData ($myedit,TCPSend($socket, $sData2) )
sleep(100)
$ret3  = GUICtrlSetData ($myedit,TCPSend($socket, $sData3) )
sleep(100)
$ret4  = GUICtrlSetData ($myedit,TCPSend($socket, $sData4) )
sleep(100)
$ret5  = GUICtrlSetData ($myedit,TCPSend($socket, $sData5) )
sleep(100)
$ret6  = GUICtrlSetData ($myedit,TCPSend($socket, $sData6) )
sleep(100)
$ret7  = GUICtrlSetData ($myedit,TCPSend($socket, $sData7) )
sleep(100)
$ret8  = GUICtrlSetData ($myedit,TCPSend($socket, $sData8) )
sleep(100)
$ret9  = GUICtrlSetData ($myedit,TCPSend($socket, $sData9) )
sleep(100)
$ret10 = GUICtrlSetData ($myedit,TCPSend($socket, $sData10) )
sleep(100)
$ret11 = GUICtrlSetData ($myedit,TCPSend($socket, $sData11) )
sleep(100)
$ret12 = GUICtrlSetData ($myedit,TCPSend($socket, $sData12) )
sleep(100)
$ret13 = GUICtrlSetData ($myedit,TCPSend($socket, $sData13) )
sleep(100)
EndIf
Wend




enjoy !!!!!!!!!!!!!

-----------------------------------------------------------------------

Edited by Melba23, 08 November 2012 - 09:18 AM.






#2 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 01 July 2005 - 06:59 PM

You should probably post this code in

AutoIt Forums > AutoIt v3 > Scripts and Scraps

this is where people post programs.. and helpful stuff

8)

Posted Image

Clic The Pic!!!


#3 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 8,925 posts

Posted 05 December 2005 - 10:35 PM

move to Scripts and Scraps

#4 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 06 December 2005 - 03:08 AM

ERROR
---
Line 38

TCPStartUp()
^ ERROR

Error: Unknown function name.
---

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#5 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 06 December 2005 - 03:12 AM

ERROR
---
Line 38

TCPStartUp()
^ ERROR

Error: Unknown function name.
---



requires Beta version

http://www.autoitscript.com/forum/index.php?showtopic=10256#

8)

Edited by Valuater, 06 December 2005 - 03:13 AM.

Posted Image

Clic The Pic!!!


#6 Shinies

Shinies

    Adventurer

  • Active Members
  • PipPip
  • 100 posts

Posted 06 December 2005 - 10:57 AM

doesnt even work for me :S

#7 memnon

memnon

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 06 December 2005 - 02:14 PM

it works perfect and i use some of this code now for my syslog server :P
das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

#8 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 07 December 2005 - 01:50 AM

Thanks I got it too work, but my status keeps going to 0 and won't change how do i fix this?

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#9 Walkabout

Walkabout

    Seeker

  • Active Members
  • 37 posts

Posted 08 December 2005 - 09:56 AM

Asimzameer,

Cool. I was so excited by this I've started to turn it into a UDF. I'll post it here when it's working. I've got a problem with the server unexpectely terminating the connection, and I'll be stuffed if I can work out why. Might have to post in support.

Regards
Walkabout.

#10 Walkabout

Walkabout

    Seeker

  • Active Members
  • 37 posts

Posted 08 December 2005 - 07:53 PM

Asimzameer,

Cool. I was so excited by this I've started to turn it into a UDF. I'll post it here when it's working. I've got a problem with the server unexpectely terminating the connection, and I'll be stuffed if I can work out why. Might have to post in support.

Regards
Walkabout.

Here it is (Thanks to MHz for his help)

Plain Text         
;=============================================================================== ; ; Function Name:    _INetSmtpMail() ; Description:    Sends an email using SMTP over TCP IP. ; Parameter(s):  $s_SmtpServer  - SMTP server to be used for sending email ;                  $s_FromName      - Name of sender ;                  $s_FromAddress   - eMail address of sender ;                  $s_ToAddress - Address that email is to be sent to ;                  $s_Subject       - Subject of eMail ;                   $as_Body        - Single dimension array containing the body of eMail as strings ; Requirement(s):   None ; Return Value(s):  On Success - Returns 1 ;                  On Failure - 0  and sets ;                                           @ERROR = 1  -   Invalid Parameters ;                                           @ERROR = 2  -   Unable to start TCP ;                                           @ERROR = 3  -   Unable to resolve IP ;                                           @ERROR = 4  -   Unable to create socket ;                                           @ERROR = 5  -   Data send or SMTP Protocol error ; Authors:      Original function to send email via TCP     - Asimzameer ;                   Conversion to UDF                       - Walkabout ; ;=============================================================================== Func _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)         Local $i_ReturnErrorCode     Local $i_LocalErrorCode     Local $v_Socket     Local $s_IPAddress     Local $i_SendReturn     Local $i_Count     Local $s_Send[10]         If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then         SetError(1)         Return 0     EndIf     $i_LocalErrorCode = TCPStartup()     If $i_LocalErrorCode = 0 Then         SetError(2)         Return 0     EndIf     StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")     If @extended Then         $s_IPAddress = $s_SmtpServer     Else         $s_IPAddress = TCPNameToIP($s_SmtpServer)     EndIf     If $s_IPAddress = "" Then         TCPShutdown()         SetError(3)         Return 0     EndIf     $v_Socket = TCPConnect($s_IPAddress, 25)     If $v_Socket = -1 Then         TCPShutdown()         SetError(4)         Return (0)     EndIf     Sleep(100)     $s_Send[0] = "HELO " & $s_FromAddress & @CRLF     $s_Send[1] = "MAIL FROM: <" & $s_FromAddress & ">" & @CRLF     $s_Send[2] = "RCPT TO: <" & $s_ToAddress & ">" & @CRLF     $s_Send[3] = "DATA" & @CRLF     $s_Send[4] = "From:" & $s_FromName & "< " & $s_FromAddress & " >" & @CRLF     $s_Send[5] = "To:" & $s_ToAddress & @CRLF     $s_Send[6] = "Subject:" & $s_Subject & @CRLF ;$s_Send[7] = "Sender: AutoIt3" & @CRLF     $s_Send[7] = "Mime-Version: 1.0" & @CRLF     $s_Send[8] = "Content-Type: text/plain; charset=US-ASCII" & @CRLF     $s_Send[9] = @CRLF         For $i_Count = 0 To UBound($s_Send) - 1         $i_SendReturn = TCPSend($v_Socket, $s_Send[$i_Count])         If $i_SendReturn = 0 Then             TCPCloseSocket($v_Socket)             TCPShutdown()             SetError(5)             Return 0         EndIf         Sleep(100)         $s_Receive = TCPRecv($v_Socket, 1000)     Next     Sleep(100)     For $i_Count = 0 To UBound($as_Body) - 1         $i_SendReturn = TCPSend($v_Socket, $as_Body[$i_Count] & @CRLF)         Sleep(100)         If $i_SendReturn = 0 Then             TCPCloseSocket($v_Socket)             TCPShutdown()             SetError(5)             Return 0         EndIf         $s_Receive = TCPRecv($v_Socket, 1000)         Sleep(100)     Next     $i_SendReturn = TCPSend($v_Socket, @CRLF & "." & @CRLF)     If $i_SendReturn = 0 Then         TCPCloseSocket($v_Socket)         TCPShutdown()         SetError(5)         Return 0     EndIf     Sleep(100)     TCPCloseSocket($v_Socket)     TCPShutdown()     Return 1 EndFunc  ;==>_INetSmtpMail

And simple wrapper script is:

#include <INetSmtpMail.au3> $s_SmtpServer = "mysmtpserver.com.au" $s_FromName = "My Name" $s_FromAddress = "From eMail Address" $s_ToAddress = "To eMail Address" $s_Subject = "My Test UDF" 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, $s_Subject, $s_Body) $err = @error msgbox(0,"email",$Response) msgbox(0,"error",$err)


#11 Walkabout

Walkabout

    Seeker

  • Active Members
  • 37 posts

Posted 18 December 2005 - 08:06 PM

Added to the UDF thread at the top of this forum

Latest version of function (plus associated files)

Walkabout.

#12 Skrip

Skrip

    Psychonaut

  • Active Members
  • PipPipPipPipPipPip
  • 2,340 posts

Posted 19 December 2005 - 11:16 PM

how do you attach a file to the e-mail?

We're trapped in the belly of this horrible machine.And the machine is bleeding to death...


#13 Walkabout

Walkabout

    Seeker

  • Active Members
  • 37 posts

Posted 20 December 2005 - 11:29 AM

how do you attach a file to the e-mail?


Firestorm,

At this stage you can't.

Walkabout

#14 mikidutza

mikidutza

    Seeker

  • Active Members
  • 42 posts

Posted 25 February 2007 - 02:18 PM

you are a genius, i love your program!!!!!!!!!!!!!!!!!! keep up the good work :) :whistle:

#15 raquien

raquien

    Seeker

  • Active Members
  • 41 posts

Posted 25 April 2007 - 08:49 AM

this is not working for me.. i am in a network where we are using http proxy authentification for internet access...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users