Logo Search packages:      
Sourcecode: nbsmtp version File versions  Download package

int nbsmtp_rcpts ( servinfo_t serverinfo,
string_t rcpts 
)

Send Recipients to the server.

Parameters:
[in] serverinfo Pointer to a servinfo_t struct with the server information
[in,out] rcpts Pointer to a string_t matrix with all recipients
Returns:
1 in command success and -1 in case of error

Definition at line 257 of file nbsmtp.c.

References log_msg(), servinfo::num_rcpts, smtp_last_message(), smtp_okay(), smtp_write(), and str_free().

Referenced by send_mail().

{
      char *local_out_buf;
      int i;
      bool_t validrcpts = False;

      for( i=0 ; i<serverinfo->num_rcpts ; i++ )
      {
            asprintf(&local_out_buf,"RCPT TO:<%s>", rcpts[i].str);

            if (smtp_write(serverinfo, local_out_buf)<1)
            {
                  log_msg(LOG_ERR,"Error writting RCPT command to the socket");
                  return -1;
            }

            free(local_out_buf);

            if (!smtp_okay(serverinfo))
            {
                  log_msg(LOG_WARNING,"Recipient REJECTED [%s] -> '%s'",
                              rcpts[i].str,smtp_last_message());
            }
            else
            {
                  log_msg(LOG_INFO,"Recipient accepted [%s]",rcpts[i].str);

                  validrcpts = True;
            }

            str_free(&rcpts[i]);
      }

      /* We check for, at least, one valid recipient */
      if (validrcpts==False)
      {
            log_msg(LOG_ERR,"No recipients were accepted by the server, exiting");
            return -1;
      }

      return 1;
}


Generated by  Doxygen 1.6.0   Back to index