email hook now works but you have to

supply the IP address of your sendmail
server and it has to allow email
forwarding from host 's IP. specify
the sendmail server's IP in the Master
Controls.
This commit is contained in:
mwells 2013-10-02 09:36:44 -06:00
parent 45941e4b2f
commit 259ec08e09
4 changed files with 45 additions and 11 deletions

3
Conf.h

@ -369,6 +369,9 @@ class Conf {
// . default about 8?
//float m_queryMaxMultiplier;
// use sendmail to forward emails we send out
char m_sendmailIp[MAX_MX_LEN];
// send emails when a host goes down?
bool m_sendEmailAlerts;
//should we delay when only 1 host goes down out of twins till 9 30 am?

@ -5475,6 +5475,18 @@ void Parms::init ( ) {
m++;
m->m_title = "sendmail IP";
m->m_desc = "We send crawlbot notification emails to this sendmail "
"server which forwards them to the specified email address.";
m->m_cgi = "smip";
m->m_off = (char *)&g_conf.m_sendmailIp - g;
m->m_type = TYPE_STRING;
m->m_def = "10.5.54.47";
m->m_size = MAX_MX_LEN;
m->m_priv = 2;
m->m_group = 0;
m++;
m->m_title = "send email alerts";
m->m_desc = "Sends emails to admin if a host goes down.";
m->m_cgi = "sea";

@ -2739,6 +2739,7 @@ void PingServer::sendEmailMsg ( long *lastTimeStamp , char *msg ) {
//
///////////////////
/*
bool gotMxIp ( EmailInfo *ei ) ;
void gotMxIpWrapper ( void *state , long ip ) {
@ -2750,10 +2751,25 @@ void gotMxIpWrapper ( void *state , long ip ) {
// did not block, call callback
ei->m_callback ( ei->m_state );
}
*/
void doneSendingEmailWrapper ( void *state , TcpSocket *sock ) {
if ( g_errno )
log("crawlbot: error sending email = %s",mstrerror(g_errno));
// log the reply
if ( sock && sock->m_readBuf )
log("crawlbot: got socket reply=%s", sock->m_readBuf);
EmailInfo *ei = (EmailInfo *)state;
ei->m_callback ( ei->m_state );
}
// returns false if blocked, true otherwise
bool sendEmail ( class EmailInfo *ei ) {
// this is often set from XmlDoc.cpp::indexDoc()
g_errno = 0;
char *to = ei->m_toAddress.getBufStart();
char *dom = strstr(to,"@");
if ( ! dom || ! dom[1] ) {
@ -2766,6 +2782,15 @@ bool sendEmail ( class EmailInfo *ei ) {
// ref that for printing HELO line
ei->m_dom = dom;
// just send it to a sendmail server which will forward it,
// because a lot of email servers don't like us connecting directly
// beause i think our IP address does not match that of our
// MX ip for our domain? sendmail must be configured to allow
// forwarding if it receives an email from the IP of host #0
// in the cluster.
ei->m_mxIp = atoip(g_conf.m_sendmailIp);
/*
// prepend a special marker so Dns.cpp returns the mx record
ei->m_mxDomain.safePrintf("gbmxrec-%s",dom);
@ -2780,17 +2805,6 @@ bool sendEmail ( class EmailInfo *ei ) {
return gotMxIp ( ei );
}
void doneSendingEmailWrapper ( void *state , TcpSocket *sock ) {
if ( g_errno )
log("crawlbot: error sending email = %s",mstrerror(g_errno));
// log the reply
if ( sock && sock->m_readBuf )
log("crawlbot: got socket reply=%s", sock->m_readBuf);
EmailInfo *ei = (EmailInfo *)state;
ei->m_callback ( ei->m_state );
}
// returns false if blocked, true otherwise
bool gotMxIp ( EmailInfo *ei ) {
@ -2802,6 +2816,7 @@ bool gotMxIp ( EmailInfo *ei ) {
mstrerror(g_errno));
return true;
}
*/
// wtf?
if ( ei->m_mxIp == 0 ) {

@ -113,6 +113,10 @@
# the logging.
<maxDelayBeforeLoggingACallbackOrHandler>-1</>
# We send crawlbot notification emails to this sendmail server which forwards
# them to the specified email address.
<sendmailIP><![CDATA[10.5.54.47]]></>
# Sends emails to admin if a host goes down.
<sendEmailAlerts>0</>