how to send e-mail

This is a discussion on how to send e-mail within the Windows Programming forums, part of the Platform Specific Boards category; how to send e-mail not using any smtp server...

  1. #1
    metamp
    Guest

    Question how to send e-mail

    how to send e-mail not using any smtp server

  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    go to a free email website, such as hotmail.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    2
    I want my application to send e-mail withoutusing any smtp server
    I'm looking for a programming technique how to do this

  4. #4
    Unregistered
    Guest
    I want my application to send e-mail without using any smtp server
    I'm looking for a programming technique how to do this
    You actually want to post a reqular mail without to submit the leter to the post office. So you will need to deliver it manually.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    2

    re

    do you mean push the message directly to the pop server of the recepient

  6. #6
    Registered User Italia's Avatar
    Join Date
    Feb 2002
    Posts
    13
    Sounds like Winsock...

  7. #7
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    You wanna use winsock yer, you simply need to open a connectio to an smtp server e.g

    freeserve.com on port 25

    Then where your connected you need to send it commands, such as

    mail from: bllalalala@whitehouse.gov

    For more info on these commands you should look up smtp telnet tutorials, when you open up a raw connection to an smtp server in telnet, ur doing the same thing in your prog.

    I would post you some source, but im on my other pc and my programming folder isnt shared on my network, and i cant go down other end of house... so if you still cant do it by tommorow then i will post you some code.

    Hope that helps,
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  8. #8
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    Ok i take it you havnt done it yet, below is some code of mine to make a simple connection to a server. Sorry, i dont have time at the moment to make it send an email. All you need to do is change the port and the host your connecting to.

    Then use Send() and recv() to send and recieve

    You must make sure you call recv() after you send somthing and when you first connect, otherwise it will mess up. Here are the smtp commands you need to look up to send to the smtp server:

    helo //say hello to the server

    mail from: blblllalala@sdfsd.com //whos it from

    rcpt to: gbggfdgdf@sdfdsf.net //whos it to

    data
    lalalal //must end with a . on its own line
    .


    If you wanna go into more depth like Subjects and CCs i dont remember them off hand but there pretty easy to find.

    Any way heres the simple winsock code:


    Code:
    //simple winsock connection
    
    #include "stdafx.h"
    #include <windows.h>
    #include <tchar.h>
    #include <winsock.h>
    
    
    
    #define PORT 25
    #define MAXDATASIZE 100
    
    struct       hostent *he;        
    struct       sockaddr_in server;    
    int            numbytes;      	   
    char         buf[MAXDATASIZE];     
    
    WSADATA  wsdata;
    SOCKET   sock;
    DWORD    wsock;
    
    
    LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    
    int APIENTRY WinMain(HINSTANCE hInstance,
    		     HINSTANCE hPrevInstance,
    		     LPSTR lpCmdLine,
    		     int nCmdShow)
    {
    		WNDCLASSEX win = {0};
    win.cbSize = sizeof(WNDCLASSEX);
    static TCHAR szAppName[] = ("Basic Raw connection");
    
    win.style = CS_HREDRAW | CS_VREDRAW;
    
    win.lpfnWndProc = WindowProc;
    win.cbClsExtra = 0;
    win.cbWndExtra = 0;
    win.hInstance = hInstance;
    win.hIcon = LoadIcon(NULL, IDI_WINLOGO);
    win.hCursor = LoadCursor(NULL, IDC_CROSS); 
    win.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1); 
    win.lpszMenuName = NULL;
    win.lpszClassName = szAppName;
    
    
    RegisterClassEx(&win);
    
    HWND hWnd = CreateWindowEx(
    WS_EX_CLIENTEDGE,
    szAppName,
    _T("Winsock Demo"),
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hInstance,
    NULL
    );
    
    
    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);
    
    MSG msg;
    while(GetMessage(&msg, NULL, 0, 0) == TRUE)
    {
    	TranslateMessage(&msg);	
    	DispatchMessage(&msg);
    }
    return msg.wParam;
    } 
    
    LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    
    switch(message)
    {
    
    case WM_LBUTTONDOWN:
    	{
    
    WSAStartup(0x0101,&wsdata); 
            	      	   
       sock = socket(AF_INET, SOCK_STREAM, 0);
      
       he = gethostbyname("localhost"); 
       server.sin_family = AF_INET;
       server.sin_port = htons(PORT);      	                
       server.sin_addr = *((struct in_addr *)he->h_addr);    
     
       if(connect(sock,(struct sockaddr *)&server,sizeof(server)) == SOCKET_ERROR)
       {
    	   MessageBox(hWnd, "Error Connecting","",MB_OK);
    	   return 0;
       }
       
       numbytes = recv(sock, buf, MAXDATASIZE, 0);
       buf[numbytes] = '\0';
      
       MessageBox(hWnd, buf, "Server response:", MB_OK);
       
       closesocket(sock);
       WSACleanup();
       
        return 1;
    	}
    	break;
    
    case WM_CREATE:
    	{
    	MessageBeep(0);
    	}
    
    break;
    
    case WM_PAINT:
    	{
    	PAINTSTRUCT paintst;
    	HDC hdc = BeginPaint(hWnd, &paintst);
    
    
    
    
    	EndPaint(hWnd, &paintst);
    	return 0;
    	}
    
    break;
    
    case WM_CLOSE:
    	{
    	SendMessage(hWnd, WM_DESTROY, wParam, lParam);
    	}
    	
    break;
    
    case WM_DESTROY :
    {
    	PostQuitMessage(0);
    
       WSACleanup();
    	return 0;
    	}
    
    default:
    	{
    	return DefWindowProc(hWnd, message, wParam, lParam);
    	}
    } 
    
    return 0;
    }
    TNT
    You Can Stop Me, But You Cant Stop Us All

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tuncated uint8_t
    By Coens in forum C Programming
    Replies: 14
    Last Post: 11-24-2008, 06:57 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  3. LISP (DrScheme) any one?
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-31-2004, 11:52 AM
  4. A send mail application with source code
    By Rizwan Rafique in forum Windows Programming
    Replies: 8
    Last Post: 01-11-2002, 09:22 AM
  5. Send Mail
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 11-26-2001, 05:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21