/[monit]/monit/sendmail.c
ViewVC logotype

Diff of /monit/sendmail.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by hauk, Thu Jul 24 00:35:25 2003 UTC revision 1.17 by hauk, Sat Jul 26 00:22:55 2003 UTC
# Line 62  Line 62 
62    
63  static Socket_T S;  static Socket_T S;
64  static char *server;  static char *server;
65    static int did_timeout;
66  static sigjmp_buf timeout;  static sigjmp_buf timeout;
67    
68    
# Line 80  static void do_send(const char *, ...); Line 81  static void do_send(const char *, ...);
81    
82  /**  /**
83   * Send SMTP mail messages   * Send SMTP mail messages
84   * @param mail A mymail struct object   * @param mail A Mail object
85   */   */
86  void sendmail(Mail_T mail) {  void sendmail(Mail_T mail) {
87    
# Line 88  void sendmail(Mail_T mail) { Line 89  void sendmail(Mail_T mail) {
89    char *now = get_RFC822date(NULL);    char *now = get_RFC822date(NULL);
90    char *localhost= get_localhostname();    char *localhost= get_localhostname();
91    
92      ASSERT(mail);
93      
94    if(!initialize_server()) {    if(!initialize_server()) {
       
95      goto exit;      goto exit;
   
96    }    }
97        
98    if(sigsetjmp(timeout, TRUE)) {    if(sigsetjmp(timeout, TRUE)) {
   
99      goto exit;      goto exit;
   
100    }    }
101    
102    do_status();    do_status();
# Line 122  void sendmail(Mail_T mail) { Line 121  void sendmail(Mail_T mail) {
121      do_send("Content-Transfer-Encoding: quoted-printable\r\n");      do_send("Content-Transfer-Encoding: quoted-printable\r\n");
122      do_send("\r\n");      do_send("\r\n");
123      do_send("%s\r\n", m->message);      do_send("%s\r\n", m->message);
124      if(m->opt_message)      if(m->opt_message) {
125          do_send("%s\r\n", m->opt_message);        do_send("%s\r\n", m->opt_message);
126        }
127      do_send(".\r\n");      do_send(".\r\n");
128      do_status();      do_status();
129    
# Line 136  void sendmail(Mail_T mail) { Line 136  void sendmail(Mail_T mail) {
136    exit:    exit:
137    free(now);    free(now);
138    free(localhost);    free(localhost);
139      if(did_timeout) {
140        log("Sendmail: Connection to mailserver timed out\n");
141      }
142    finalize_server();    finalize_server();
143        
144  }  }
# Line 149  static int initialize_server() { Line 152  static int initialize_server() {
152    struct sigaction sa;    struct sigaction sa;
153    
154    S= NULL;    S= NULL;
155      did_timeout= FALSE;
156    server= Run.mailserver?Run.mailserver:LOCALHOST;    server= Run.mailserver?Run.mailserver:LOCALHOST;
157        
158    sa.sa_flags= 0;    sa.sa_flags= 0;
# Line 181  static void finalize_server() { Line 185  static void finalize_server() {
185    
186    
187  static void do_timeout(int sig) {  static void do_timeout(int sig) {
188      
189    log("Sendmail: Connection to mailserver timed out\n");    did_timeout= TRUE;
190    siglongjmp(timeout, TRUE);    siglongjmp(timeout, TRUE);
191        
192  }  }
# Line 190  static void do_timeout(int sig) { Line 194  static void do_timeout(int sig) {
194    
195  void do_send(const char *format, ...) {  void do_send(const char *format, ...) {
196        
   char msg[2048];  
197    va_list ap;    va_list ap;
198      char msg[2048];
199        
200    va_start(ap,format);    va_start(ap,format);
201    vsnprintf(msg, 2048, format, ap);    vsnprintf(msg, 2048, format, ap);

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26