Send Email using C++

Aug 21, 2012 at 11:24am
Hi I'm using Dev C++ and am trying to figure out how to send an email from it. I've searched all over the internet but found nothing. Does anyone here know how? I'm using gmail if it helps. Thanks
Aug 21, 2012 at 12:32pm
You're looking for an smtp library. There are many.
Aug 22, 2012 at 8:21am
I've tried to use some and can't seem to get it working. Any suggestions?
Aug 22, 2012 at 9:06am
show us what you have got so far ?
Aug 23, 2012 at 2:38am
Right now? Nothing. Everything I do either won't compile, or won't send an email.
Aug 23, 2012 at 2:40am
Yeah show us the code that either won't compile, or won't send an email please.
Aug 23, 2012 at 3:22am
Here it is: I'm sure I'm doing something very wrong. This is the only one which compiles however.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<fstream>
#include<conio.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <winable.h>
#include <cmath>
#include<string>
using namespace std;

int main(){
FILE *email= popen( "/usr/lib/sendmail", "wb" );

fprintf( email, "To: xxxxxxx@xxxxxxx.com\r\n" );
fprintf( email, "From: xxxxxx@xxxxxx.com\r\n" );
fprintf( email, "\r\n" );
fprintf( email, "Hello!\r\n" );

pclose( email );
system("pause");
return 0;
}
Aug 23, 2012 at 3:34am
Okay I don't know about SMTP libraries but you're program does nothing network-related!
Aug 23, 2012 at 8:57am
all the piece of code does is to write those strings to a file.
nothing network-related indeed.

here is an example
http://stackoverflow.com/questions/58210/c-smtp-example

hope that helps
Topic archived. No new replies allowed.