Directly inject email into the epistula mail que.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzEmail::SendEpistula | (hzChain&,) |
Declared in file: hzMailer.h
Defined in file : hzMailer.cpp
Function Logic:
Function body:
hzEcode hzEmail::SendEpistula (hzChain& report)
{
// Directly inject email into the epistula mail que.
//
// Arguments: 1) report The error report of the send operation
_hzfunc("hzEmail::SendEpistula") ;
static uint32_t nSeq = 1000;
hzList<hzEmaddr>::Iter R ; // Recipients iterator
ofstream os ; // Output stream
hzChain Z ; // Working output chain
hzString S ; // Working string
hzEmaddr ema ; // Email address
char cvId[12]; // Mail-id
// Create mail-id
sprintf(cvId, "%04x.%04x", getpid(), ++nSeq) ;
// Create body file
Z.Printf("/usr/epistula/mailque/%s_body", cvId) ;
S = Z ;
os.open(*S) ;
if (os.fail())
{
hzerr(E_WRITEFAIL, "Cannot open mail item file (%s) for writing", *S) ;
return E_WRITEFAIL ;
}
os << m_Final ;
os.close() ;
os.clear() ;
// Create header file
Z.Clear() ;
Z.Printf("/usr/epistula/mailque/%s_head", cvId) ;
S = Z ;
os.open(*S) ;
if (os.fail())
{
hzerr(E_WRITEFAIL, "Cannot open mail item file (%s) for writing", *S) ;
return E_WRITEFAIL ;
}
// Record delivery info
os << "from : " << m_AddrFrom << "\r\n" ;
if (m_RealFrom.Length())
os << "announce : " << m_RealFrom << "\r\n" ;
else
os << "announce : " << m_AddrFrom << "\r\n" ;
os << "ip_addr : " << "127.0.0.1" << "\r\n" ;
// os << "resolved : " << m_AddrFrom.GetDomain() << "\r\n" ;
os << "resolved : " << m_AddrFrom << "\r\n" ;
os << "mail_id : " << cvId << "\r\n" ;
// Group recipients by domain
for (R = m_Recipients ; R.Valid() ; R++)
{
ema = R.Element() ;
os << "relay_to : " << ema.GetDomain() << "\r\n" ;
}
os.close() ;
return E_OK ;
}