masqmail-0.2

view src/smtpsend.c @ 170:0f0e4e7cd762

added misc/list-versions This script helps to check if the versions numbers in the project are the same as the one for the release. This script is motivated by the 0.2.27 release in which masqmail introduces itself as being version 0.2.26.
author meillo@marmaro.de
date Mon, 19 Jul 2010 14:01:13 +0200
parents 9104234a56a5
children
line source
1 /* MasqMail
2 Copyright (C) 1999 Oliver Kurth
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
19 #include <stdio.h>
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
25 #include <glib.h>
27 #include "masqmail.h"
28 #include "smtp_out.h"
30 masqmail_conf conf;
32 extern char *optarg;
33 extern int optind, opterr, optopt;
35 void
36 logwrite(int pri, const char *fmt, ...)
37 {
38 va_list args;
39 va_start(args, fmt);
41 vfprintf(stdout, fmt, args);
43 va_end(args);
44 }
46 void
47 debugf(const char *fmt, ...)
48 {
49 va_list args;
50 va_start(args, fmt);
52 vfprintf(stdout, fmt, args);
54 va_end(args);
55 }
57 int
58 main(int argc, char *argv[])
59 {
60 gchar *helo_name = g_malloc(64);
61 gchar *server_name = g_strdup("localhost");
62 gint server_port = 25;
63 GList *resolve_list = g_list_append(NULL, resolve_byname);
65 gethostname(helo_name, 63);
67 conf.host_name = g_strdup(helo_name);
69 while (1) {
70 int c;
71 c = getopt(argc, argv, "d:p:s:H:");
72 if (c == -1)
73 break;
74 switch (c) {
75 case 'd':
76 conf.debug_level = atoi(optarg);
77 break;
78 case 'p':
79 server_port = atoi(optarg);
80 break;
81 case 's':
82 g_free(server_name);
83 server_name = g_strdup(optarg);
84 break;
85 case 'H':
86 g_free(helo_name);
87 helo_name = g_strdup(optarg);
88 break;
89 default:
90 break;
91 }
92 }
94 if (optind < argc) {
95 gint ret;
96 message *msg = create_message();
98 while (optind < argc) {
99 msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(argv[optind++], TRUE, conf.host_name));
100 }
102 if ((ret = accept_message(stdin, msg, ACC_DOT_IGNORE)) == AERR_OK) {
103 if ((ret = smtp_deliver(server_name, server_port, resolve_list, msg, NULL, NULL)) == smtp_ok) {
104 exit(EXIT_SUCCESS);
105 }
106 fprintf(stderr, "deliver failed: %d\n", ret);
107 }
108 fprintf(stderr, "accept failed: %d\n", ret);
109 exit(ret);
110 } else {
111 fprintf(stderr, "no recipients given.\n");
112 exit(-1);
113 }
114 }