Sign in to follow this  
Followers 0
fromaster123

SMTP Not Working At All

19 posts in this topic

#1 ·  Posted (edited)

i cant use _InetSMTPMail... i always get error code 50 or 51 (help file) which means it cant open SMTP Session. but when i use the verizon smtp (smtp.verizon.net) it says error 3 which means unable to resolve ip. i try to use outgoing.verizon.net but error code 50 or 51 every time. please help heres code and im using latest beta version

can someone please help me so it sends the email?

#include <Inet.au3>

$s_SmtpServer = "smtp.verizon.net"
$s_FromName = "raplsh"
$s_FromAddress = "ada"
$s_ToAddress = "fromaster123@gmail.com"
$s_Subject = "The test"
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)
$err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf
Edited by fromaster123

Share this post


Link to post
Share on other sites



And the question for support is?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

the question is why doesnt it send the email? sorry for not including ques

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here's a working SMTP emailer, You can just copy & Paste.. or check why yours doesnt work. :whistle:

$a = "Your SMTP Server"
$b = "Email Address (Random)"
$c = "Password of the (Random) Email"

Emailx("From@Example.com", "To@Example.com", "Subject", "Text Body")

Func Emailx($d, $e, $f, $g)
$h = ObjCreate ("CDO.Message")
With $h
.Subject = $f
.Sender = $d
.From = $d
.To = $e
.TextBody = $g
;.AddAttachment ("");req full dictonairy
EndWith
With $h.Configuration.Fields
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $a
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $b
.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $c
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
EndWith
$h.Send
Return
EndFunc ;==>Emailx
Edited by AceLoc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

Im using the same shit script as fromaster123 and have the same problems...

Why doesnt this script work??? :whistle:;)

Share this post


Link to post
Share on other sites

The problem is you have to login (authenticate) before you can send.

Share this post


Link to post
Share on other sites

This was from a month ago, Anyways, it would be that verizon isnt your isp server?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

I got fed up with this UDF so i wrote my own MX mailer (you are the SMTP server!). In other words it sends the mail directly from your computer. Also this is a SMTP client as well.

You need 3 files

_Base64.au3

_INetSmtpMail.au3

_INetSmtpMail_Example.au3

Make sure to change the example file so the email goes somewhere!

Share this post


Link to post
Share on other sites

If it sends it right from the computer, why does it need an smtp server?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Here are 2 wikipedia articles about email

http://en.wikipedia.org/wiki/Simple_Mail_T...ty_and_Spamming

http://en.wikipedia.org/wiki/MX_record

There are several reason

  • A reason for a SMTP server is for the reply field. If you don't need to get replies from the email you sent out then you do not need to connect to a SMTP server.
  • Spam control. AOL blocks all incoming email from dynamic IP's. Without a SMTP server to act as a middle man you would not be able to send email to an email Hosts that has aggressive anti spam practices (like AOL).
So when you send email directly to the MX server you cut out the middle man (the SMTP server)

This program doesn't need a SMTP server, but it does have that option. I combined the 2 things into one program because it uses a lot of the same code.

Edited by mikeytown2

Share this post


Link to post
Share on other sites

Isnt send smtp and recv pop3?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I believe your providers SMTP server is normally referred to as the "Smart-Host" and is used as a simple entry point for a client where you deliver your mail without needing to worry about the mail delivery.

When you decide to deliver the mail yourself on the Target domain's SMTP server ( yes still a SMTP server) you will have to do the following:

- retrieve the MX record for the Target domain from your DNS server for each of the recipients of each message.

- Set up a session with the found MX SMTP server and deliver the message directly for each of the recipients of each message.

- In case of unavailability of one of the target MX Servers, you will have to provide some sort of retry mechanism for only those servers.

I wish you luck with these efforts, but if I were you I would install a local "Light" MailServer like Mercury/32 which can take of all these tasks or use you providers Smart-host.

:P

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

When you decide to deliver the mail yourself on the Target domain's SMTP server ( yes still a SMTP server) you will have to do the following:

- retrieve the MX record for the Target domain from your DNS server for each of the recipients of each message.

- Set up as session with the found MX SMTP server and deliver the message directly for each of the recipients of each message.

- In case of unavailability of one of the target MX Servers, you will have to provide some sort of retry mechanism for only those servers.

I got 1.5/3 done with the program i made. I didn't bother making a retry mechanism and i think it only sends the message to one recipient. I'm not sure if it would be a good idea to code the missing parts because of the possibility of abuse.

Overall very informative, thanks for the info/help explaining this.

Share this post


Link to post
Share on other sites

Hi AceLoc,

your script doesn't seem to work for me. I'm only getting the following error:

"Line 0 (File "C:\Mailscript.exe"):

$m_nachricht.Send

$m_nachricht.Send^ ERROR

Error: The requested action with this object has failed."

"$m_nachricht" stands for your "$h".

Does somebody know what the problem is ?

Share this post


Link to post
Share on other sites

This works great - until I try to expand the body to more than 2 lines. If I simply change the example-file array declaration to:

Dim $as_Body[3]

$as_Body[0] = "Testing the new email udf"

$as_Body[1] = "Second Line"

$as_Body[2] = "Third Line"

Then it results in the following error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "M:\My Documents\_INetSmtpMail_Example.au3"

C:\Program Files\AutoIt3\Include\_INetSmtpMail.Au3 (195) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

_SmtpSend($v_Socket, $as_End[$i_Count], $f_trace)

_SmtpSend($v_Socket, ^ ERROR

Any clues?

Thanks.

Share this post


Link to post
Share on other sites

Look at _INetSmtpMailCom().


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

This works great - until I try to expand the body to more than 2 lines. If I simply change the example-file array declaration to:

Dim $as_Body[3]

$as_Body[0] = "Testing the new email udf"

$as_Body[1] = "Second Line"

$as_Body[2] = "Third Line"

Then it results in the following error:

dimension range exceeded.:

you need to change the Array declaration from [3] to how ever many lines you have.

so if you have 20 lines then...

Dim $as_Body[21]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
$as_Body[2] = "Third Line"
.....
$as_Body[20] = "Line 20"

Who's email script are you using just to make support easier for us?

Share this post


Link to post
Share on other sites

@mickeytown2: I'm using your script and i did add somethings to do what i need to and... it's working !

but i got the following error message:

Line 195 (file "...\_INetSmtpMail.Au3"):

_Smtpsend($v_Socket, $as_End[$i_Count], $f_trace)

_SmtpSend($v_Socket, ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

here is the _INetSmtpMail-example.Au3 where did the modification

#include "_INetSmtpMail.Au3"
#include <Constants.au3>
#include "_Base64.Au3"
Opt("TrayIconDebug", 1)
;EXAMPLE CODE

$yyyymd = @MDAY & "/" & @MON & "/" & @YEAR
$PingPasserelle = Ping(GetLanGW(), 1200)
$PingGoogle = Ping("www.google.fr", 1200)

If ($PingPasserelle > 0) Then
    $pingmsg = "OK"
Else
    $pingmsg = "Echec"
EndIf

If ($PingGoogle > 0) Then
    $pingmsg2 = "OK"
Else
    $pingmsg2 = "Echec"
EndIf

;FILL THIS IN START
$s_FromName = "Netoptima Diagnostic"
$s_FromAddress = "diag@netoptima.fr"
$s_ToAddress = "support@netoptima.fr"
$s_Subject = "My Diag Test"
Dim $as_Body[6]
$as_Body[0] = "Date : " & $yyyymd & @CRLF
$as_Body[1] = "Adresse IP de la machine : " & @IPAddress1 & @CRLF
$as_Body[2] = "Adresse IP de la passerelle : " & GetLanGW() & @CRLF
$as_Body[3] = "Adresse IP du serveur DNS : " & GetLanDNS() & @CRLF
$as_Body[4] = "Resultat du ping de la passerelle (si different de 0 = OK) : " & $pingmsg & @CRLF
$as_Body[5] = "Resultat du ping de googgle.fr (si different de 0 = OK) : " & $pingmsg2 & @CRLF

$s_Subject = "Rapport diagnotic de la machine de " & @UserName & " a " & @ComputerName
;FILL THIS IN END


$b_trace = True ;false no trace window, true trace window displayed
$s_helo = @ComputerName ;sometimes WAN IP, localhost or 127.0.0.1
$s_first = "" ;@CRLF ;this is pointless with my UDF, since it will automaticly do it, if need be

$s_UserName = "diag@netoptima.fr" ;just declearing it, no need to fill in
$s_Password = "75diag95" ;just declearing it, no need to fill in
$temp = StringSplit($s_FromAddress, "@")
MsgBox(64,"Resultat du test permettant d'etablir un diagnostic de votre machine", _ 
"Date : " & $yyyymd & @CRLF & _ 
"Adresse IP de la machine : " & @IPAddress1 & @CRLF & _ 
"Adresse IP de la passerelle : " & GetLanGW() & @CRLF & _ 
"Adresse IP du serveur DNS : " & GetLanDNS() & @CRLF & _ 
"Resultat du ping de la passerelle : " & $pingmsg & @CRLF & _
"Resultat du ping de google.fr : " & $pingmsg2 & @CRLF & _ 
"Cliquez sur Ok pour valider ce rapport" & @CRLF)

If MsgBox(4, "SMTP", "Souaitez envoyez ce rapport, par mail, a votre administrateur reseau ?" & @CRLF & "Click no to send from your computer directly to the mx server (may not work!)") = 6 Then
    $s_Server = "smtp.netoptima.fr"
    $s_UserName = _Base64Encode ("diag@netoptima.fr")
    If $s_UserName Then
        $s_Password = _Base64Encode ("75diag95")
    EndIf
Else
    $s_Server = ""
    
    ;domain lookup
    $IP = _INetGetSource ("http://dynupdate.no-ip.com/ip.php")
    If @error Or $IP = "" Then
        $IP = "127.0.0.1"
    EndIf
    $RunPID = Run(@ComSpec & " /c nslookup " & $IP, "", @SW_HIDE, $STDOUT_CHILD)
    $name = StringSplit(StdoutRead($RunPID), "Name:", 1)
    If $name[0] > 1 Then
        $name = StringSplit($name[2], "Address:", 1)
        $name = StringStripWS($name[1], 8)
    Else
        $name = "No Internet Connection"
    EndIf
    
    $domain = StringSplit($name, ".")
    If $domain[0] > 1 Then
        $domain = $domain[$domain[0] - 1] & "." & $domain[$domain[0]]
    Else
        $domain = $domain[$domain[0]]
    EndIf
    
    If $domain <> $temp[$temp[0]] Then
        If MsgBox(4, "MX Servers", "Some MX servers will not accept emails if they don't come from your domain" & @CRLF _
        & "Would you like to change this " & @CRLF & $s_FromAddress & " to this " & @CRLF & $temp[1] & "@" & $domain) = 6 Then
            $s_FromAddress = $temp[1] & "@" & $domain
        EndIf
    EndIf
EndIf

;call udf
If _INetSmtpMail ($s_FromName, $s_FromAddress, $s_ToAddress, $s_Server, $s_Subject, $as_Body, $s_helo, $s_UserName, $s_Password, $b_trace) <> 1 Then
    MsgBox(0, "Error!", "Mail failed with error code " & @error)
Else
    MsgBox(0, "Success!", "Rapport envoye ! Cliquez sur OK pour lancer l'outil de prise en main a distance")
EndIf

$csn = Run("C:\Program Files\TeamViewer\Version4\TeamViewer.exe")

Func GetLanGW()
 Local $colItems = ""
 Local $strComputer = "localhost"
 Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
 Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20)
 If IsObj($colItems) Then
  For $objItem In $colItems
   If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DefaultIPGateway(0)) > 3) Then
    If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0)
    If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0)
    If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0)
    If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DefaultIPGateway(0)
   EndIf
  Next
 Else
  Return @IPAddress1 ; if you dont have Gateway
 EndIf
EndFunc   ;==>GetLanGW

Func GetLanDNS()
 Local $colItems = ""
 Local $strComputer = "localhost"
 Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
 Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", 0x10 + 0x20)
 If IsObj($colItems) Then
  For $objItem In $colItems
   If (StringLen($objItem.IPAddress(0)) > 3) And (StringLen($objItem.DNSServerSearchOrder(0)) > 3) Then
    If @IPAddress1 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0)
    If @IPAddress2 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0)
    If @IPAddress3 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0)
    If @IPAddress4 = $objItem.IPAddress(0) Then Return $objItem.DNSServerSearchOrder(0)
   EndIf
  Next
 Else
  Return @IPAddress1 ; if you dont have DNS
 EndIf
EndFunc   ;==>GetLanDNS
;===============================================================================
;
; Function Name:    _INetGetSource()
; Description:      Gets the source from an URL without writing a temp file.
; Parameter(s):     $s_URL = The URL of the site.
; Requirement(s):   DllCall/Struct & WinInet.dll
; Return Value(s):  On Success - Returns the source code.
;                   On Failure - 0  and sets @ERROR = 1
; Author(s):        Wouter van Kesteren.
;
;===============================================================================
Func _INetGetSource($s_URL, $s_Header = '')
    
    If StringLeft($s_URL, 7) <> 'http://' And StringLeft($s_URL, 8) <> 'https://' Then $s_URL = 'http://' & $s_URL
    
    Local $h_DLL = DllOpen("wininet.dll")
    
    Local $ai_IRF, $s_Buf = ''
    
    Local $ai_IO = DllCall($h_DLL, 'int', 'InternetOpen', 'str', "AutoIt v3", 'int', 0, 'int', 0, 'int', 0, 'int', 0)
    If @error Or $ai_IO[0] = 0 Then
        DllClose($h_DLL)
        SetError(1)
        Return ""
    EndIf
    
    Local $ai_IOU = DllCall($h_DLL, 'int', 'InternetOpenUrl', 'int', $ai_IO[0], 'str', $s_URL, 'str', $s_Header, 'int', StringLen($s_Header), 'int', 0x80000000, 'int', 0)
    If @error Or $ai_IOU[0] = 0 Then
        DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
        DllClose($h_DLL)
        SetError(1)
        Return ""
    EndIf
    
    Local $v_Struct = DllStructCreate('udword')
    DllStructSetData($v_Struct, 1, 1)
    
    While DllStructGetData($v_Struct, 1) <> 0
        $ai_IRF = DllCall($h_DLL, 'int', 'InternetReadFile', 'int', $ai_IOU[0], 'str', '', 'int', 256, 'ptr', DllStructGetPtr($v_Struct))        
        $s_Buf &= StringLeft($ai_IRF[2], DllStructGetData($v_Struct, 1))
    WEnd
    
    DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IOU[0])
    DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
    DllClose($h_DLL)
    Return $s_Buf
EndFunc   ;==>_INetGetSource

I guess there is no need to say that i'm a newbie with AutoIT

Any help or guidance would be appreciate.

Thanks

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Updated version of Smtp ?

Could you be more specific because i don't know what you mean !

Edited by Kkweit

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