EMAIL System with SMTP AUTH LOGIN

Previous topic - Next topic

Marmor

HI ,
This Demo shows the login for email accounts with password.
i have created a testaccount on web.de.
If you need the password send me a PN !

gtx
have fun....


show me if it works  :o :o

works with win7
works with hp touchpad webos last version

working SMTP Server
Web.de (Marmor)
GMX.de (Marmor
yahoo (Kanonet)
1&1    (Mentalthink)

- modifyed version 0.1   thx to Kanonet
- added brackets for from /to mail $


Code (glbasic) Select



//  EMAIL SYSTEM for GLB  version  0.001

// This Demo use a full Account from Email Provider  "WEB.DE"
// You can use this to sending emails from GLB  without having a Freemailer
//
// Create your own Account on web.de  and other Mailsystems with SMTP Auth Login
//

// send a PN if you need the password for some Tests

// thx for the base64 function in the GLB Code Forum



//---------------------------------------------------------------------------------------------------------------------

GLOBAL      to$     =    "powerasm1@web.de"                             // Put your own Email ADDY here !!!!!!!!!

GLOBAL      mode    =      1                         // 1 Shows the Serverreply if DEBUGMODE ON
GLOBAL      delay   =     50                                            // Test your own (100 ms run on the most Devices)

GLOBAL      subj$    =   "MAIL from MYGAME Vers: 0.1"                   // Subject
GLOBAL      mess1$   =   "GLB GAME STARTET at :" +PLATFORMINFO$("time") // Messagestrings
GLOBAL      mess2$   =   "PLATFORM :"+PLATFORMINFO$("")                 //
GLOBAL      mess3$   =   "DEVICE   :"+PLATFORMINFO$("DEVICE")           //
GLOBAL      mess4$   =   "ID       :"+PLATFORMINFO$("ID")               //
GLOBAL      mess5$   =   "Locale   :"+PLATFORMINFO$("LOCALE")           // last  Message



//--------------------------- dont touch this -------------------------------------------------------------------------



GLOBAL      port    =     25                                            // Standard smtp port
GLOBAL      server$ =    "smtp.web.de"                                  // Serveradresse for web.de
GLOBAL      from$   =    "onlyforglb@web.de"                            // EMAIL ADRESS  dont change it !!!!!!!!!
GLOBAL      pass$   =    "xyz!?).../hs"                               // Password for Email ADRESS      send PN
GLOBAL      LFCR$   =  CHR$(13)+CHR$(10)                                //  0dh +0ah
GLOBAL      socket%                                                     // Socketnumber from TCPCONNECT
GLOBAL       reply$                                                     // needed for the famouse base64encode$ function (THX)

GLOBAL      from64$ = Base64_encode$(from$)                             // we need base64 from sender
GLOBAL      pass64$ = Base64_encode$(pass$)                             // we need base64 from password

//---------------------------------------------------------------------------------------------------------------------



IF SOCK_INIT()=FALSE THEN END                                       // ups

           socket% = SOCK_TCPCONNECT(server$,port)




IF socket%<> -1                                                  // start sending !! BEWARE the correct Order

        SOCK_TCPSEND (socket%, "HELO GLB MAILSYSTEM 0.1 "+LFCR$)
        check()
            SOCK_TCPSEND (socket%, "AUTH LOGIN"+LFCR$)
            check()
            SOCK_TCPSEND (socket%,  from64$+LFCR$)
            check()
            SOCK_TCPSEND (socket%,  pass64$+LFCR$)
            check()
            SOCK_TCPSEND(socket%,  "MAIL FROM:<"+from$ +">"+LFCR$)
            check()
            SOCK_TCPSEND (socket%, "RCPT TO:<"   +to$ +">"  +LFCR$)
            check()
            SOCK_TCPSEND (socket%, "DATA"+LFCR$)
            check()

            SOCK_TCPSEND (socket%, "TO   :< "    +to$  +">"  +LFCR$)
            check()
            SOCK_TCPSEND (socket%, "Subject: "  +subj$+LFCR$)
            check()
            SOCK_TCPSEND (socket%, "MAILER:  "+"GLB MAIL SYSTEM"+LFCR$)
            check()
SOCK_TCPSEND (socket%,  ""+LFCR$)
   
    SOCK_TCPSEND (socket%,  "START OF MESSAGE"+LFCR$)
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    check()
    SOCK_TCPSEND (socket%,   mess1$+ LFCR$)
    SOCK_TCPSEND (socket%,   mess2$+ LFCR$)
    SOCK_TCPSEND (socket%,   mess3$+ LFCR$)
    SOCK_TCPSEND (socket%,   mess4$+ LFCR$)
    SOCK_TCPSEND (socket%,   mess5$+ LFCR$)
    check()    
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    SOCK_TCPSEND (socket%,  "END OF MESSAGE "  +  LFCR$)
    check()
    SOCK_TCPSEND (socket%,  " "+LFCR$)
    check()
    SOCK_TCPSEND (socket%, "."+LFCR$)
    check()
    SOCK_TCPSEND (socket%, "QUIT"+LFCR$)
    SOCK_CLOSE   (socket%)                                                      //WOOOOT
        ENDIF


END



// GENIUS BASE64 Function
FUNCTION Base64_encode$:source$




LOCAL result$, group$
LOCAL t, n, i, u, ant, pad
LOCAL Base64$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" // Normal


FOR n = 0 TO LEN(source$)-1 STEP 3
t = 0 // temp holder of the three bytes
ant = 3
FOR i = 0 TO 2
u = 0
IF n+i > LEN(source$)-1 // Do we have enough characters left?
DEC ant, 1 // No, remove one byte from result
ELSE
u = ASC(MID$(source$, n+i, 1)) // yes, add it
ENDIF
t = (t*0x100) + u // shift left and add character to temp-group
NEXT
pad = 3-ant // How many characters padding?
group$ = ""
FOR i = 0 TO 3
u = bAND(t, 0x3F) // Single out the bottom 6 bits
t = t / 0x40 // shift right by 6 bits
IF pad > 0
// IF url = FALSE

group$ = "=" + group$ // add padding
// ELSE // or skip if we are encoding for an url
// ENDIF
DEC pad, 1
ELSE
group$ = MID$(Base64$, u, 1) + group$ // add to encoded temp-group
ENDIF
NEXT
result$ = result$ + group$ // add temp-group to final result
NEXT


RETURN result$
ENDFUNCTION



// SIMPLE DELAY and DEBUG Function
FUNCTION check:

SLEEP delay

    IF mode =1
    LOCAL rv% = SOCK_RECV(socket%, reply$, 1024)
        DEBUG  "Recv: " + rv% +" : " +reply$+"\n"
    ENDIF

ENDFUNCTION




READY.


ampos

check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

kanonet

#2
Hello Marmor, thanks for your great work!


I wasnt able to get this working with yahoo mail, it took me some time to find the point where your implementation was non standard:
Code (glbasic) Select
            SOCK_TCPSEND(socket%,  "MAIL FROM: "+from$ +LFCR$)
            check()
            SOCK_TCPSEND (socket%, "RCPT TO:"   +to$    +LFCR$)
            check()

This may work with some mail servers, but others may have problems (like yahoo), better make it that way:
Code (glbasic) Select
            SOCK_TCPSEND(socket%,  "MAIL FROM:<"+from$ +">"+LFCR$)
            check()
            SOCK_TCPSEND (socket%, "RCPT TO:<"   +to$    +">"+LFCR$)
            check()

This works on yahoo servers (tested) and should work without problems on any other server too (testing needed).


I would recommand to change
Code (glbasic) Select
            SOCK_TCPSEND (socket%, "TO   : "    +to$    +LFCR$)
            check()

to
Code (glbasic) Select
            SOCK_TCPSEND (socket%, "From: <"    +to$    +">"+LFCR$)
            check()
            SOCK_TCPSEND (socket%, "To: <"    +to$    +">"+LFCR$)
            check()

but i thats not needed, more for style.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

mentalthink

I repeat from the another post..
1and1 servers works too,  not it´s free, but it´s very chaper and very good....

Thanks again...  :good: :good: