how to send e-mail not using any smtp server
Printable View
how to send e-mail not using any smtp server
go to a free email website, such as hotmail.
I want my application to send e-mail withoutusing 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.Quote:
I want my application to send e-mail without using any smtp server
I'm looking for a programming technique how to do this
do you mean push the message directly to the pop server of the recepient
Sounds like Winsock...
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: [email protected]
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
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 :D
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: [email protected] //whos it from
rcpt to: [email protected] //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;
}