sendmail_test.c 624 B

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