Directly inject email into the epistula mail que.

Return TypeFunction nameArguments
hzEcodehzEmail::SendEpistula(hzChain&,)

Declared in file: hzMailer.h
Defined in file : hzMailer.cpp

Function Logic:

0:START 1:items items S items 2:unknown 3:items 4:Return E_WRITEFAIL 5:items items items items items S items 6:unknown 7:items 8:Return E_WRITEFAIL 9:items 10:unknown 11:items 12:items 13:items items items 14:unknown 15:ema items 16:items 17:Return E_OK

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 ;
}