Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Anybody know about a working smtp email program WITH source ? What's wrong with this one ?

Anybody know about a working smtp email program WITH source ? What's wrong with this one ?

Scheduled Pinned Locked Moved The Lounge
c++announcementcomsysadminbeta-testing
11 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kamal Shankar
    wrote on last edited by
    #1

    Hello I am looking for source (preferably Visual C++) to a SMTP mailer which works correctly. The email module for http:\\www.codeproject.com\internet\ipemailannc.asp does not seem to work, atleast in my modified version: I am posting the modified version (picked from parts of a program that I wrote) : Source: ----------------------- #include "stdafx.h" #include "baseheader.h" #define BUFFER_DEFAULT_SIZE 4096 #define CMD_BUFF 256 #define SMTP_DEFAULT_PORT 25 #define TARGET_ADDRESS "a@b.com" #define SOURCE_ADDRESS "c@d" #define DEFAULT_SUBJECT "Subz " #define DEFAULT_SERVER_ADD "mail.x.y" SmtpMsg msg; TCPServer srv; SOCKET ssmtp; char szBuffer[BUFFER_DEFAULT_SIZE]; //Buffer to get response from server bool setSmtpMessage(char*); int connectToSmtpSrv(void); bool sendSmtpAnnounce(void); bool init(void); bool quit(void); int _tmain(int argc, _TCHAR* argv[]) { init(); char szMessage[2048]={0}; printf("\nEnter the message body (Hello World) \n"); fflush(stdin); scanf("%[^\n\r]",szMessage); if(*szMessage==0) { lstrcpy(szMessage,"Hello World"); } setSmtpMessage (szMessage); initConn(srv.address, srv.port, &ssmtp); sendSmtpAnnounce(); quit(); return 0; } bool init(void) { char* pszFrom,*pszTo,*pszMailServer; pszMailServer=new char[257]; pszFrom=new char[257]; pszTo=new char[257]; *pszFrom=0; *pszTo=0; *pszMailServer=0; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszTo); if(*pszTo==0) { msg.ToAdd = TARGET_ADDRESS; delete[] pszTo; } else msg.ToAdd = pszTo; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszFrom); if(*pszFrom==0) { msg.FromAdd = SOURCE_ADDRESS; delete[] pszFrom; } else msg.FromAdd = pszFrom; //Here define the subject of the announcement msg.Subject = new char[CMD_BUFF]; strcpy(msg.Subject, DEFAULT_SUBJECT); strcat(msg.Subject, getNowTime()); printf("\nEnter the mail server : "); fflush(stdin); scanf("%[^\n\r]",pszMailServer); if(*pszMailServer==0) { srv.address = DEFAULT_SERVER_ADD; delete[] pszMailServer; } else srv.address = pszMailServer; srv.port = SMTP_DEFAULT_PORT; return true; } bool quit(void) { closeConn(ssmtp); return true; } bool setSmtpMessage (char* body) { msg.MsgBody = body; return true; } bool sendSmtpAnnounce (void) { char Data2Srv[BUFFER_DEFAULT_SIZE]; char FeedBack[BUFFER_DEFAULT_SIZE]; char* CRLF = "\r\n";

    N S T 3 Replies Last reply
    0
    • K Kamal Shankar

      Hello I am looking for source (preferably Visual C++) to a SMTP mailer which works correctly. The email module for http:\\www.codeproject.com\internet\ipemailannc.asp does not seem to work, atleast in my modified version: I am posting the modified version (picked from parts of a program that I wrote) : Source: ----------------------- #include "stdafx.h" #include "baseheader.h" #define BUFFER_DEFAULT_SIZE 4096 #define CMD_BUFF 256 #define SMTP_DEFAULT_PORT 25 #define TARGET_ADDRESS "a@b.com" #define SOURCE_ADDRESS "c@d" #define DEFAULT_SUBJECT "Subz " #define DEFAULT_SERVER_ADD "mail.x.y" SmtpMsg msg; TCPServer srv; SOCKET ssmtp; char szBuffer[BUFFER_DEFAULT_SIZE]; //Buffer to get response from server bool setSmtpMessage(char*); int connectToSmtpSrv(void); bool sendSmtpAnnounce(void); bool init(void); bool quit(void); int _tmain(int argc, _TCHAR* argv[]) { init(); char szMessage[2048]={0}; printf("\nEnter the message body (Hello World) \n"); fflush(stdin); scanf("%[^\n\r]",szMessage); if(*szMessage==0) { lstrcpy(szMessage,"Hello World"); } setSmtpMessage (szMessage); initConn(srv.address, srv.port, &ssmtp); sendSmtpAnnounce(); quit(); return 0; } bool init(void) { char* pszFrom,*pszTo,*pszMailServer; pszMailServer=new char[257]; pszFrom=new char[257]; pszTo=new char[257]; *pszFrom=0; *pszTo=0; *pszMailServer=0; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszTo); if(*pszTo==0) { msg.ToAdd = TARGET_ADDRESS; delete[] pszTo; } else msg.ToAdd = pszTo; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszFrom); if(*pszFrom==0) { msg.FromAdd = SOURCE_ADDRESS; delete[] pszFrom; } else msg.FromAdd = pszFrom; //Here define the subject of the announcement msg.Subject = new char[CMD_BUFF]; strcpy(msg.Subject, DEFAULT_SUBJECT); strcat(msg.Subject, getNowTime()); printf("\nEnter the mail server : "); fflush(stdin); scanf("%[^\n\r]",pszMailServer); if(*pszMailServer==0) { srv.address = DEFAULT_SERVER_ADD; delete[] pszMailServer; } else srv.address = pszMailServer; srv.port = SMTP_DEFAULT_PORT; return true; } bool quit(void) { closeConn(ssmtp); return true; } bool setSmtpMessage (char* body) { msg.MsgBody = body; return true; } bool sendSmtpAnnounce (void) { char Data2Srv[BUFFER_DEFAULT_SIZE]; char FeedBack[BUFFER_DEFAULT_SIZE]; char* CRLF = "\r\n";

      N Offline
      N Offline
      Nnamdi Onyeyiri
      wrote on last edited by
      #2

      The answer is available here[^]. :)


      To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
      Another Post by NnamdiOnyeyiri

      J C B M K 5 Replies Last reply
      0
      • N Nnamdi Onyeyiri

        The answer is available here[^]. :)


        To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
        Another Post by NnamdiOnyeyiri

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        Ouch. :) --------------------------- He who knows that enough is enough will always have enough. -Lao Tsu

        1 Reply Last reply
        0
        • K Kamal Shankar

          Hello I am looking for source (preferably Visual C++) to a SMTP mailer which works correctly. The email module for http:\\www.codeproject.com\internet\ipemailannc.asp does not seem to work, atleast in my modified version: I am posting the modified version (picked from parts of a program that I wrote) : Source: ----------------------- #include "stdafx.h" #include "baseheader.h" #define BUFFER_DEFAULT_SIZE 4096 #define CMD_BUFF 256 #define SMTP_DEFAULT_PORT 25 #define TARGET_ADDRESS "a@b.com" #define SOURCE_ADDRESS "c@d" #define DEFAULT_SUBJECT "Subz " #define DEFAULT_SERVER_ADD "mail.x.y" SmtpMsg msg; TCPServer srv; SOCKET ssmtp; char szBuffer[BUFFER_DEFAULT_SIZE]; //Buffer to get response from server bool setSmtpMessage(char*); int connectToSmtpSrv(void); bool sendSmtpAnnounce(void); bool init(void); bool quit(void); int _tmain(int argc, _TCHAR* argv[]) { init(); char szMessage[2048]={0}; printf("\nEnter the message body (Hello World) \n"); fflush(stdin); scanf("%[^\n\r]",szMessage); if(*szMessage==0) { lstrcpy(szMessage,"Hello World"); } setSmtpMessage (szMessage); initConn(srv.address, srv.port, &ssmtp); sendSmtpAnnounce(); quit(); return 0; } bool init(void) { char* pszFrom,*pszTo,*pszMailServer; pszMailServer=new char[257]; pszFrom=new char[257]; pszTo=new char[257]; *pszFrom=0; *pszTo=0; *pszMailServer=0; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszTo); if(*pszTo==0) { msg.ToAdd = TARGET_ADDRESS; delete[] pszTo; } else msg.ToAdd = pszTo; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszFrom); if(*pszFrom==0) { msg.FromAdd = SOURCE_ADDRESS; delete[] pszFrom; } else msg.FromAdd = pszFrom; //Here define the subject of the announcement msg.Subject = new char[CMD_BUFF]; strcpy(msg.Subject, DEFAULT_SUBJECT); strcat(msg.Subject, getNowTime()); printf("\nEnter the mail server : "); fflush(stdin); scanf("%[^\n\r]",pszMailServer); if(*pszMailServer==0) { srv.address = DEFAULT_SERVER_ADD; delete[] pszMailServer; } else srv.address = pszMailServer; srv.port = SMTP_DEFAULT_PORT; return true; } bool quit(void) { closeConn(ssmtp); return true; } bool setSmtpMessage (char* body) { msg.MsgBody = body; return true; } bool sendSmtpAnnounce (void) { char Data2Srv[BUFFER_DEFAULT_SIZE]; char FeedBack[BUFFER_DEFAULT_SIZE]; char* CRLF = "\r\n";

          S Offline
          S Offline
          Steve Thresher
          wrote on last edited by
          #4

          Search google for blat Systems AXIS Ltd - Software for Business ...

          1 Reply Last reply
          0
          • N Nnamdi Onyeyiri

            The answer is available here[^]. :)


            To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
            Another Post by NnamdiOnyeyiri

            C Offline
            C Offline
            ColinDavies
            wrote on last edited by
            #5

            LOL !! Unexpected !! Regardz Colin J Davies

            *** WARNING *
            This could be addictive
            **The minion's version of "Catch :bob: "

            It's a real shame that people as stupid as you can work out how to use a computer. said by Christian Graus in the Soapbox

            1 Reply Last reply
            0
            • N Nnamdi Onyeyiri

              The answer is available here[^]. :)


              To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
              Another Post by NnamdiOnyeyiri

              B Offline
              B Offline
              Bee Master
              wrote on last edited by
              #6

              :laugh: Never comment ur code. If it was hard to write, it should be hard to understand !!!

              1 Reply Last reply
              0
              • N Nnamdi Onyeyiri

                The answer is available here[^]. :)


                To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
                Another Post by NnamdiOnyeyiri

                M Offline
                M Offline
                Maxwell Chen
                wrote on last edited by
                #7

                How did you do that hiding the real URL ? :wtf: Maxwell Chen

                B 1 Reply Last reply
                0
                • M Maxwell Chen

                  How did you do that hiding the real URL ? :wtf: Maxwell Chen

                  B Offline
                  B Offline
                  Bee Master
                  wrote on last edited by
                  #8

                  Maxwell Chen wrote: How did you do that hiding the real URL ? Real url is not hidden. It is redirected to the image file from that url. It uses free service provided by babyurl[^] which converts any long URL to a short one. Click here for new link showing same image using babyurl service[^] Never comment ur code. If it was hard to write, it should be hard to understand !!!

                  M 1 Reply Last reply
                  0
                  • B Bee Master

                    Maxwell Chen wrote: How did you do that hiding the real URL ? Real url is not hidden. It is redirected to the image file from that url. It uses free service provided by babyurl[^] which converts any long URL to a short one. Click here for new link showing same image using babyurl service[^] Never comment ur code. If it was hard to write, it should be hard to understand !!!

                    M Offline
                    M Offline
                    Maxwell Chen
                    wrote on last edited by
                    #9

                    Thanks! It's interesting. :-D Maxwell Chen

                    1 Reply Last reply
                    0
                    • N Nnamdi Onyeyiri

                      The answer is available here[^]. :)


                      To those who didn't make it, we will remember you. To those who did :bob: is back. - Megan Forbes in Black Friday
                      Another Post by NnamdiOnyeyiri

                      K Offline
                      K Offline
                      Kamal Shankar
                      wrote on last edited by
                      #10

                      Nice picture anyway. Got it... :) Cheers Kamal "God then made two great lights; the greater light to rule the day, and the less light to rule the night" - Genesis 47:3

                      1 Reply Last reply
                      0
                      • K Kamal Shankar

                        Hello I am looking for source (preferably Visual C++) to a SMTP mailer which works correctly. The email module for http:\\www.codeproject.com\internet\ipemailannc.asp does not seem to work, atleast in my modified version: I am posting the modified version (picked from parts of a program that I wrote) : Source: ----------------------- #include "stdafx.h" #include "baseheader.h" #define BUFFER_DEFAULT_SIZE 4096 #define CMD_BUFF 256 #define SMTP_DEFAULT_PORT 25 #define TARGET_ADDRESS "a@b.com" #define SOURCE_ADDRESS "c@d" #define DEFAULT_SUBJECT "Subz " #define DEFAULT_SERVER_ADD "mail.x.y" SmtpMsg msg; TCPServer srv; SOCKET ssmtp; char szBuffer[BUFFER_DEFAULT_SIZE]; //Buffer to get response from server bool setSmtpMessage(char*); int connectToSmtpSrv(void); bool sendSmtpAnnounce(void); bool init(void); bool quit(void); int _tmain(int argc, _TCHAR* argv[]) { init(); char szMessage[2048]={0}; printf("\nEnter the message body (Hello World) \n"); fflush(stdin); scanf("%[^\n\r]",szMessage); if(*szMessage==0) { lstrcpy(szMessage,"Hello World"); } setSmtpMessage (szMessage); initConn(srv.address, srv.port, &ssmtp); sendSmtpAnnounce(); quit(); return 0; } bool init(void) { char* pszFrom,*pszTo,*pszMailServer; pszMailServer=new char[257]; pszFrom=new char[257]; pszTo=new char[257]; *pszFrom=0; *pszTo=0; *pszMailServer=0; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszTo); if(*pszTo==0) { msg.ToAdd = TARGET_ADDRESS; delete[] pszTo; } else msg.ToAdd = pszTo; printf("\nEnter the mail address : "); fflush(stdin); scanf("%[^\n\r]",pszFrom); if(*pszFrom==0) { msg.FromAdd = SOURCE_ADDRESS; delete[] pszFrom; } else msg.FromAdd = pszFrom; //Here define the subject of the announcement msg.Subject = new char[CMD_BUFF]; strcpy(msg.Subject, DEFAULT_SUBJECT); strcat(msg.Subject, getNowTime()); printf("\nEnter the mail server : "); fflush(stdin); scanf("%[^\n\r]",pszMailServer); if(*pszMailServer==0) { srv.address = DEFAULT_SERVER_ADD; delete[] pszMailServer; } else srv.address = pszMailServer; srv.port = SMTP_DEFAULT_PORT; return true; } bool quit(void) { closeConn(ssmtp); return true; } bool setSmtpMessage (char* body) { msg.MsgBody = body; return true; } bool sendSmtpAnnounce (void) { char Data2Srv[BUFFER_DEFAULT_SIZE]; char FeedBack[BUFFER_DEFAULT_SIZE]; char* CRLF = "\r\n";

                        T Offline
                        T Offline
                        Terry ONolley
                        wrote on last edited by
                        #11

                        Programming questions? In the LOUNGE???? Oh my, how you have offended me sir. Good day to you.


                        Glano perictu com sahni delorin!

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups