1
0

sendmail_test.c 667 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. #include "smtp.h"
  3. int main(int argc, char** argv) {
  4. if (argc < 8) {
  5. printf("Usage: sendmail smtp_server username password from to subject body\n");
  6. return -10;
  7. }
  8. const char* smtp_server = argv[1];
  9. const char* username = argv[2];
  10. const char* password = argv[3];
  11. mail_t mail;
  12. mail.from = argv[4];
  13. mail.to = argv[5];
  14. mail.subject = argv[6];
  15. mail.body = argv[7];
  16. int status_code = sendmail(smtp_server, username, password, &mail);
  17. printf("sendmail: %d %s\n", status_code, smtp_status_str((enum smtp_status)status_code));
  18. return status_code == SMTP_STATUS_OK ? 0 : status_code;
  19. }