Changes that are broken
This commit is contained in:
1 parent
c9cdc822a2
commit
0a4d17e6e6
9 files changed
+110
-60
No files matched your search
+39
-7
@@ -1,20 +1,52 @@
|
||||
#include "SendMail.h"
|
||||
#include <chrono>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
namespace mail {
|
||||
|
||||
SendMail::SendMail(core::EPoll &ePoll, std::string from, std::string recipient, std::string mailFileName)
|
||||
: core::TCPSession2(ePoll, "Send Mail Agent"), from(from), recipient(recipient), mailFileName(mailFileName),
|
||||
mailData(mailFileName), Timer(ePoll, 0.00f), ePoll(ePoll) {
|
||||
mailData(mailFileName), Timer(ePoll, 0.00f), ePoll(ePoll) {
|
||||
|
||||
core::IPAddress mxAddress("127.0.0.1", 9025);
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << this->recipient;
|
||||
this->recipient.split("@");
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << this->recipient[1];
|
||||
|
||||
connect(mxAddress);
|
||||
ePoll.registerSocket((TCPSession2 *)(this));
|
||||
u_char nsbuff[4096];
|
||||
char *domain = this->recipient[1].c_str();
|
||||
int len = res_query(domain, ns_c_any, ns_t_mx, nsbuff, sizeof(nsbuff));
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << ">" << len;
|
||||
ns_msg msg;
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "SendMail initiated...";
|
||||
ns_initparse(nsbuff, len, &msg);
|
||||
len = ns_msg_count(msg, ns_s_an);
|
||||
|
||||
}
|
||||
char dispbuf[4096];
|
||||
ns_rr rr;
|
||||
for (int i = 0; i < 1; i++) {
|
||||
ns_parserr(&msg, ns_s_an, i, &rr);
|
||||
ns_sprintrr(&msg, &rr, NULL, NULL, dispbuf, sizeof(dispbuf));
|
||||
printf ("%s\n", dispbuf);
|
||||
}
|
||||
|
||||
coreutils::ZString mxArray(dispbuf);
|
||||
mxArray.split("\t");
|
||||
mxArray[3].split(" ");
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "MX: " << mxArray[3][1];
|
||||
|
||||
core::IPAddress mxAddress(mxArray[3][1].c_str(), 25);
|
||||
connect(mxAddress);
|
||||
ePoll.registerSocket((TCPSession2 *)(this));
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "SendMail initiated...";
|
||||
|
||||
}
|
||||
|
||||
SendMail::SendMail(const SendMail ©) : core::TCPSession2(ePoll, "Send Mail Agent"), from(copy.from), recipient(copy.recipient), mailFileName(copy.mailFileName),
|
||||
mailData(mailFileName), Timer(ePoll, 0.00f), ePoll(copy.ePoll) {}
|
||||
|
||||
SendMail::~SendMail() {
|
||||
ePoll.unregisterSocket((TCPSession2 *)(this));
|
||||
@@ -40,7 +72,7 @@ namespace mail {
|
||||
// open tcpsocket with connect
|
||||
// wait for greeting
|
||||
if(data.asInteger() == 220) {
|
||||
out << "EHLO " << from << CRLF;
|
||||
out << "EHLO " << "mail.barant.com" << CRLF;
|
||||
state = READY;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user