SMTP Mail Versandt mit AUTH-LOGIN

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Sparx

Betreff: SMTP Mail Versandt mit AUTH-LOGIN

BeitragSo, Jan 25, 2004 15:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Habs nur bei GMX getestet, sollte aber auch bei allen andern smtp server funzen:
Code: [AUSKLAPPEN]
Function smtpSendMail(server$, von_adresse$, password$, an_adresse$, subject$, mailtext$)
  com2 = OpenTCPStream(server$,25)
  ReadLine(com2)
  WriteLine com2,"AUTH LOGIN"
  ReadLine(com2)
  WriteLine com2,b64enc(von_adresse)
  ReadLine(com2)
  WriteLine com2,b64enc(password)
  ReadLine(com2)
  WriteLine com2,"HELO EGAL"
  ReadLine(com2)
  WriteLine com2,"MAIL FROM: " + von_adresse$
  ReadLine(com2)
  WriteLine com2,"RCPT TO: "+an_adresse$
  ReadLine(com2)
  WriteLine com2,"DATA"
  ReadLine(com2)
  WriteLine com2, "Date: " + CurrentDate$ ()
  WriteLine com2, "From: " + von_name$ + " <" + von_adresse$ + ">"
  WriteLine com2, "To: " + an_name$ + " <" + an_adresse$ + ">"
  WriteLine com2, "Subject: " + subject$
  WriteLine com2, "X-Mailer: EGAL"
  i = 0
    Repeat
      WriteLine com2, stringausstring$(mailtext$, i, 0)
       i = i + 1
    Until Len(stringausstring$(mailtext$, i, 0)) = 1 And stringausstring$(mailtext$, i, 0) = "0"
  WriteLine com2, "."
  ReadLine(com2)
  WriteLine com2, "QUIT"
  ReadLine(com2)
  CloseTCPStream(com2)
End Function

Function stringausstring$(s$, stelle, trenncode)
   anzahl = 1 ; Anzahl der Textstellen
   letzteskomma = 1 ; Position des letzten Kommas
   For i = 1 To Len(s$)
      If Asc(Mid(s$, i, 1)) = trenncode Or i = Len(s$) Then ; Wenn ein Trenncode erreicht ist
         If anzahl = stelle Then ; Wenn diese Stelle die angegebene ist...
            s2$ = Mid(s$, letzteskomma, i-letzteskomma) ; Text extrahieren
            If i = Len(s$) Then s2$ = Mid(s$, letzteskomma, i-(letzteskomma-1)) ; Wenn der Text der letzte im String ist, etwas anders extrahieren
           If Len(Mid(s$,letzteskomma,i-letzteskomma)) = 1 Then s2$ = Chr$(0)
         EndIf
         letzteskomma = i+1 ; Weitergehen im String solange der Text noch nicht erreicht ist
         anzahl = anzahl + 1
      EndIf
   Next
   If stelle > (anzahl-1) Then Return "0"
   Return s2$
End Function

Function b64enc$(a$)
   b64$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
   m$=""
   f$=""
   largo=Len(a$)
;Encode a$ into one long string of bits
   cx$=""
   For encode=1 To largo
      x$=Mid$(a$,encode,1)  ;get one char at a time
      Tx=Asc(x$)            ;Tx = ASCII code
      b$=Bin$(Tx)           ;convert Tx into string of 32 bits
      b$=Right$(b$,8)       ;get the right most 8 bits out of the 32 bits
      cx$=cx$+b$            ;add string of 8 bits to cx$
   Next
   ;largo = number of bits stored in cx$
   largo=Len(cx$)
   For encode=1 To largo Step 6
      x$=Mid$(cx$,encode,6)   
      bbb=Len(x$)
      bbbx=6-bbb       ;check for 6 bits
         ;If not full 6 bits at end of bit string, then add "=" to end of encoded string
         If bbbx>0 Then
            f$="="
         EndIf
      x$=x$ + Left$("00000000",bbbx)         ;pad with zeroes to make 6 bits
      res=0
      For y=0 To 5
         by  = Asc(Mid$(x$, 6-y, 1)) - 48   ;get bits from right to left (least significant to most)
         res = res + ( 2^y * by)            ;raise to power of 2 and add to res (result)
      Next
      m$=m$+Mid$(b64$,res+1,1)+f$
   Next
   Return m$
End Function


Dieser Code ist erstellt auf Basis anderer Codes.
User posted image

Markus2

BeitragSo, Jan 25, 2004 17:12
Antworten mit Zitat
Benutzer-Profile anzeigen
Habs noch nicht ausprobiert aber kann ich bestimmt mal gebrauchen ! Smile

Sparx

BeitragSo, Jan 25, 2004 18:54
Antworten mit Zitat
Benutzer-Profile anzeigen
So, hab einige Fehler entdeckt und ausgebessert:
Code: [AUSKLAPPEN]

Function smtpSendMail(server$, von_adresse$, password$, an_adresse$, subject$, mailtext$)
  com2 = OpenTCPStream(server$,25)
  ReadLine(com2)
  WriteLine com2,"AUTH LOGIN"
  ReadLine(com2)
  WriteLine com2,b64enc(von_adresse)
  ReadLine(com2)
  WriteLine com2,b64enc(password)
  ReadLine(com2)
  WriteLine com2,"HELO Chess-Mail"
  ReadLine(com2)
  WriteLine com2,"MAIL FROM: " + von_adresse$
  ReadLine(com2)
  WriteLine com2,"RCPT TO: "+an_adresse$
  ReadLine(com2)
  WriteLine com2,"DATA"
  ReadLine(com2)
  WriteLine com2, "Date: " + CurrentDate$ ()
  WriteLine com2, "From: " + von_name$ + " <" + von_adresse$ + ">"
  WriteLine com2, "To: " + an_name$ + " <" + an_adresse$ + ">"
  WriteLine com2, "Subject: " + subject$
  WriteLine com2, "X-Mailer: Chess-Mail"
  WriteLine com2, ""
  WriteLine com2, mailtext$
  WriteLine com2, "."
  ReadLine(com2)
  WriteLine com2, "QUIT"
  ReadLine(com2)
  CloseTCPStream(com2)
End Function


Function b64enc$(a$)
   b64$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
   m$=""
   f$=""
   largo=Len(a$)
;Encode a$ into one long string of bits
   cx$=""
   For encode=1 To largo
      x$=Mid$(a$,encode,1)  ;get one char at a time
      Tx=Asc(x$)            ;Tx = ASCII code
      b$=Bin$(Tx)           ;convert Tx into string of 32 bits
      b$=Right$(b$,8)       ;get the right most 8 bits out of the 32 bits
      cx$=cx$+b$            ;add string of 8 bits to cx$
   Next
   ;largo = number of bits stored in cx$
   largo=Len(cx$)
   For encode=1 To largo Step 6
      x$=Mid$(cx$,encode,6)   
      bbb=Len(x$)
      bbbx=6-bbb       ;check for 6 bits
         ;If not full 6 bits at end of bit string, then add "=" to end of encoded string
         If bbbx>0 Then
            f$="="
         EndIf
      x$=x$ + Left$("00000000",bbbx)         ;pad with zeroes to make 6 bits
      res=0
      For y=0 To 5
         by  = Asc(Mid$(x$, 6-y, 1)) - 48   ;get bits from right to left (least significant to most)
         res = res + ( 2^y * by)            ;raise to power of 2 and add to res (result)
      Next
      m$=m$+Mid$(b64$,res+1,1)+f$
   Next
   Return m$
End Function


Wenn man beim mailtext eine neue Zeile haben will, einfach Chr(10) anfuegen.
User posted image
 

walski

Ehemaliger Admin

BeitragSo, Jan 25, 2004 19:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Dabei schenkst du aber einer Tatsache keinerlei Bedeutung:
Bei vielen Provider ist Von_Adresse <> Benutzer

Code: [AUSKLAPPEN]

Function smtpSendMail(server$, user$, password$, von_adresse$, an_adresse$, subject$, mailtext$)
  com2 = OpenTCPStream(server$,25)
  ReadLine(com2)
  WriteLine com2,"AUTH LOGIN"
  ReadLine(com2)
  WriteLine com2,b64enc(user$)


Damit sollte es dann aber gehen Smile
Nichts weltbewegendes aber naja, is halt so.

walski
buh!

Sparx

BeitragSo, Jan 25, 2004 19:34
Antworten mit Zitat
Benutzer-Profile anzeigen
AEHM Walsi: BEi Smtp wird der Login IMMER mit der emailadresse Ausgefuehrt! Jedenfalls habe ich es so verstanden.
User posted image
 

walski

Ehemaliger Admin

BeitragSo, Jan 25, 2004 19:53
Antworten mit Zitat
Benutzer-Profile anzeigen
Nein, das kann ich klar dementieren Wink
Habs ebe getestet, eine User Variable sollte schon drin sein!

walski
buh!
 

lettorTrepuS

BeitragMo, Jan 26, 2004 11:00
Antworten mit Zitat
Benutzer-Profile anzeigen
-aus Sicherheitsgründen gelöscht- Diese Information ist mit Ihrer Sicherheitsfreigabe leider nicht erhältlich, Bürger.

Sparx

BeitragMo, Jan 26, 2004 15:16
Antworten mit Zitat
Benutzer-Profile anzeigen
Nein, das ist falsch. Das ist teil des SMTP-AUTH zb. bei gmx. ohne dieses Auth kann man keine emails versenden.
User posted image
 

lettorTrepuS

BeitragMo, Jan 26, 2004 21:05
Antworten mit Zitat
Benutzer-Profile anzeigen
-aus Sicherheitsgründen gelöscht- Diese Information ist mit Ihrer Sicherheitsfreigabe leider nicht erhältlich, Bürger.

Sparx

BeitragMo, Jan 26, 2004 23:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Ein emailaccoutn ist was ganz naderes als SMTP-AUTH
User posted image
 

darkshadow

BeitragMi, Jan 28, 2004 17:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Es war damals so und hat heut nicht mehr so zu sein. Es gibt sogar Websites, wo, wenn ich meine Mailaddy eingebe und die wohl bestimmte Sachen nicht richtig machen, dass bei der dann nix ankommt und ich gezwungen bin eine Mailaddy von einem anderen Anbieter zu nehmen, da dieser dann gewisse Standarts erfüllt.

mabox

BeitragFr, Sep 28, 2007 22:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo hab das hier grade gefunden.......auch wenn meine Antwort sehr spät kommt.
Bei mit kommt da immer ein Runtime Error: "Stream does not exist" dort wo das erste mal "ReadLine(com2)" vorkommt.

wenn ich das richtig versteh stimmt da was mit der Serveradresse nicht.
Ich hab mir jetzt extra ein GMX konto erstellt aber das hat auch nichts gebracht.
Fujitsu-Siemens Laptop, 2Ghz Intel Core2Duo Prozessor, 2GB Ram, 120GB Festplatte, ATI Mobility Radeon X1400, Windows Vista Ultimate
www.mausoft.de.tl
Dönerfresser Homepage

Tankbuster

BeitragSa, Sep 29, 2007 1:47
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
com2 = OpenTCPStream(server$,25)

Hast du da auch den "server$" angegeben?
[PS:] Oh der Thread ist ja schon alt ^^
Twitter
Download Jewel Snake!
Windows|Android

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group