Skip to main content
gamedev.net
🔒 Locked

Sending email with visual CPP

Started by The C modest god Jul 30, 2006 at 8:15 AM 10 replies 2.5k views
Original Post
The C modest god
The C modest god
I have already asked this in the past, but I was unable to find my thread. So I will ask this again. I want to send an email with an attached file with my CPP progrm, to a yahoo email I got. The purpose is that when an error occur at the end user, he will be able to send me an email about this error attached with the core dump my program creates. I think the most reliable way to do this with CPP is using winsocket 2.0 and SMTP? But I am not sure how to get started doing this. So I ask you if you know of a material specifically for sending email with these technoligies? Or maybe I am wrong and I should send the email with a different method? Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Scet
Scet
Quote:
Original post by The C modest god
I have already asked this in the past, but I was unable to find my thread.


Linky McLinkster
DaBono
DaBono
As said in your previous thread, RFC 821 describes the SMTP protocol. It is actually a quite legible RFC, so you should be able to figure out how the communication with the server should look.
The server you need to connect with is either that of the user's ISP (quite difficult to detect automatically in a portable way), or your ISP's SMTP-server.
The C modest god
The C modest god
I have already used linux api for createing sessions of TCP.
So what I need to do here is to look for a server's ip (the computer number) and connect to the program, at the server side, with port 25?
Then start to send text data as desxribed in RFC821?
But what IP do I need to connect to? If I use yahoo mail?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
DaBono
DaBono
Great that you know how to use the Berkeley sockets API (i.e. the Linux API): WinSock is really similar.
Indeed, you let the program connect to port 25 of 'smtp.yahoo.com' (which gives 216.145.54.173 for me, but I guess you'd better use gethostbyname and let the DNS find the IP for you). Make connection, send text as described in the RFC, and close again.
deathkrush
deathkrush
Here is how to Programmatically Send an Email.

(just kidding)
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
The C modest god
The C modest god
Quote:
Original post by DaBono
Great that you know how to use the Berkeley sockets API (i.e. the Linux API): WinSock is really similar.
Indeed, you let the program connect to port 25 of 'smtp.yahoo.com' (which gives 216.145.54.173 for me, but I guess you'd better use gethostbyname and let the DNS find the IP for you). Make connection, send text as described in the RFC, and close again.

Great, thanks.


It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
hplus0603
hplus0603
Quote:
Original post by deathkrush
Here is how to Programmatically Send an Email.

(just kidding)


I thought of that same WTF. It's brillant! :-)
enum Bool { True, False, FileNotFound };
The C modest god
The C modest god
I have a small problem.
I try to do the following, as written in the gamedev tutorial:
		shutdown (this->Socket, SD_SEND);  // s cannot send anymore		// you should check to see if any last data has arrived here		closesocket (this->Socket);

But I get:
e:\Projects\Engine2\V0\Laby\CoreNetwork.cpp(50): error C2065: 'SD_SEND' : undeclared identifier

I have:
#pragma comment(lib,"ws2_32.lib")

And when I try to include winsock2.h I get lots of errors.

What should I do?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
hplus0603
hplus0603
You do not need to shutdown() the socket before you closesocket() it. Just remove the line that calls shutdown() -- it's only needed in rather more complex handshaking situations that what you have.
enum Bool { True, False, FileNotFound };
The C modest god
The C modest god
I solved the problem.
The SD_SEND was the minute problem, because I needed to include winsock2.h.
However, after including winsock2.h I got many errors.
Appranetly, winsock2.h doesnt like being after any #include<>, so I concentrated all the <> includes into one file, in which winsock2.h was the first.
Now all my other .h include this BasicIncludes.h
Its ugly, but it solved the problem.
Or maybe I should have not include winsock2.h anyway?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
hplus0603
hplus0603
The Forum FAQ says that you should use , and that needs to be included before . So, yes, that's the solution.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.