Senden von E-Mails mittels SMTP-Protokoll und boost-Bibliotheken

Ich bin versucht, senden Sie eine E-Mail mit Hilfe des SMTP-Protokolls-und boost-Bibliotheken
aber aus irgendeinem Grund bin ich nicht in der Lage, um die Verbindung zum hotmail-smtp-server und senden E-Mail an mich..

dies ist mein code:
was mache ich falsch?

    DNS_RECORD* ppQueryResultsSet = NULL;

    //dns mx lookup
    DnsQuery(L"hotmail.com", DNS_TYPE_MX, DNS_QUERY_STANDARD, NULL, &ppQueryResultsSet, NULL);

    if (ppQueryResultsSet == NULL)
        return false;

    //i am getting the mx servers (i.e: mx3.hotmail.com)
    wcout << "MX Host name: " << ppQueryResultsSet->Data.MX.pNameExchange << endl;
    DnsRecordListFree(ppQueryResultsSet, DnsFreeRecordList);

    string host_name = String_Convertion::WStringToString(ppQueryResultsSet->Data.MX.pNameExchange);

    //setting up socket connection
    boost::asio::io_service io_service;
    tcp::resolver resolver(io_service);
    tcp::resolver::query query(host_name, "25");
    tcp::resolver::iterator endpoint_iterator = resolver.resolve(query), end;
    tcp::socket socket(io_service);

    //connecting to the server
    boost::system::error_code error_code_connect;
    boost::asio::connect(socket, endpoint_iterator, end, error_code_connect);
    if (error_code_connect)
    {
        cout << "Error connecting to SMTP Server" << endl;
        return false;
    }

    boost::system::error_code error;
    std::string temp_buf;
    boost::array<char, 128> buf;
    size_t len;

    //settings the packets to send
    list<string> packets;
    packets.push_back("HELO");
    packets.push_back("MAIL FROM: [email protected]");
    packets.push_back("VRFY [email protected]");
    packets.push_back("RCPT TO: [email protected]"); 
    packets.push_back("DATA");
    packets.push_back("Subject: subject!");
    packets.push_back("hi how are you doing?.");
    packets.push_back("QUIT");
    list<string>::iterator it;
    //iterating to send the packets
    for (it = packets.begin(); it != packets.end(); it++)
    {
        socket.write_some(boost::asio::buffer(*it+"\r\n"));
        len = socket.read_some(boost::asio::buffer(buf), error);
        temp_buf = buf.data();
        temp_buf = temp_buf.substr(0, len);
        cout << temp_buf << endl;
    }
Gibt es einen SMTP-server, die Antworten zu VRFY Befehle?

InformationsquelleAutor Dan Revah | 2011-12-09

Schreibe einen Kommentar