Ok, so i've modified it a bit, i'm not using packets anymore, and i'm now listening for responses:
#include "iostream"
#include "SFML/Network.hpp"
using namespace std;
int main()
{
sf::IpAddress ip("smtp.live.com");
sf::TcpSocket socket;
if(socket.connect(ip, 587)==sf::Socket::Done)
{
cout << "yay" << endl;
}
else
cout << "crap" << endl;
char helo[100] = "HELO server\r\n";
socket.send(helo, 100);
char data[1000];
size_t received;
if(socket.receive(data, 1000, received) == sf::Socket::Done)
{
cout << data << endl;
}
char mailFrom[100] = "MAIL FROM: someone@something.com\r\n";
socket.send(mailFrom, 100);
char mailD[1000];
size_t mailR;
if(socket.receive(mailD, 1000, mailR) == sf::Socket::Done)
{
cout << mailD << endl;
}
char rcptTo[100] = "RCPT TO: me@live.com\r\n";
socket.send(rcptTo, 100);
char dataC[100] = "DATA\r\n";
socket.send(dataC, 100);
char msg[100] = "Message blabablabla\r\n";
socket.send(msg, 100);
char endC[100] = "\r\n.\r\n";
socket.send(endC, 100);
char dataD[1000]; // I've placed a response listener after every message send, I only get a reponse when I put it here, and not sooner.
size_t dataR;
if(socket.receive(dataD, 1000, dataR) == sf::Socket::Done)
{
cout << dataD << endl;
}
char quit[100] = "QUIT\r\n";
socket.send(quit, 100);
return 0;
}
Not very clean, but I get a response :
220 BLU436-SMTP168.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9
200.16384 ready at Thu, 19 Jun 2014 03:43:19 -0700
o
250 BLU436-SMTP168.smtp.hotmail.com Hello [xxx.xx.xxx.xxx] // This is my ip, I hid it
∟☺
530 5.7.0 Must issue a STARTTLS command first
The problem now is that last line, I don't know how to issue a STARTTLS command, i've tried sending STARTTLS to the server at each possible position, still get this message.