** Copyright (c) 1983 Eric P. Allman
** Copyright (c) 1983 Regents of the University of California.
** All rights reserved. The Berkeley software License Agreement
** specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char SccsId
[] = "@(#)mconnect.c 5.2 (Berkeley) 7/13/85";
struct sockaddr_in SendmailAddress
;
extern u_long
inet_addr();
(void) signal(SIGINT
, finis
);
s
= socket(AF_INET
, SOCK_STREAM
, 0, 0);
sp
= getservbyname("smtp", "tcp");
SendmailAddress
.sin_port
= sp
->s_port
;
register char *p
= *++argv
;
SendmailAddress
.sin_port
= htons(atoi(*++argv
));
case 'r': /* raw connection */
TtyBuf
.sg_flags
&= ~CRMOD
;
TtyBuf
.sg_flags
|= CRMOD
;
SendmailAddress
.sin_addr
.s_addr
= inet_addr(host
);
register struct hostent
*hp
= gethostbyname(host
);
fprintf(stderr
, "mconnect: unknown host %s\r\n", host
);
bcopy(hp
->h_addr
, &SendmailAddress
.sin_addr
, hp
->h_length
);
SendmailAddress
.sin_family
= AF_INET
;
printf("connecting to host %s (0x%x), port 0x%x\r\n", host
,
SendmailAddress
.sin_addr
.s_addr
, SendmailAddress
.sin_port
);
if (connect(s
, &SendmailAddress
, sizeof SendmailAddress
, 0) < 0)
/* good connection, fork both sides */
printf("connection open\n");
/* child -- standard input to sendmail */
while ((c
= fgetc(stdin
)) >= 0)
/* parent -- sendmail to standard output */
while (fgets(buf
, sizeof buf
, f
) != NULL
)