🔒 Locked
Sending email with visual CPP
Advertisement
Original Post
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.
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
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 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.
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?
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?
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.
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.
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.
Quote:
Original post by deathkrush
Here is how to Programmatically Send an Email.
(just kidding)
I thought of that same WTF. It's brillant! :-)
I have a small problem.
I try to do the following, as written in the gamedev tutorial:
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?
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?
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?
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?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement