#include <stdio.h>
#include <config.h>
-#include <sys/types.h>
#include <unistd.h>
#include <string.h>
-#include "socket.h"
#include "fetchmail.h"
+#include "socket.h"
#include "smtp.h"
int smtp_response; /* numeric value of SMTP response code */
{
int ok;
- fprintf(sockfp,"HELO %s\r\n", host);
+ SockPrintf(sockfp,"HELO %s\r\n", host);
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP> HELO %s", host);
ok = SMTP_ok(sockfp);
{
int ok;
- fprintf(sockfp,"MAIL FROM:<%s>\r\n", from);
+ SockPrintf(sockfp,"MAIL FROM:<%s>\r\n", from);
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP> MAIL FROM:<%s>", from);
ok = SMTP_ok(sockfp);
{
int ok;
- fprintf(sockfp,"RCPT TO:<%s>\r\n", to);
+ SockPrintf(sockfp,"RCPT TO:<%s>\r\n", to);
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP> RCPT TO:<%s>", to);
ok = SMTP_ok(sockfp);
{
int ok;
- fprintf(sockfp,"DATA\r\n");
+ SockPrintf(sockfp,"DATA\r\n");
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP> DATA");
ok = SMTP_ok(sockfp);
{
int ok;
- fprintf(sockfp,"QUIT\r\n");
+ SockPrintf(sockfp,"QUIT\r\n");
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP> QUIT");
ok = SMTP_ok(sockfp);
{
int ok;
- fprintf(sockfp,".\r\n");
+ SockPrintf(sockfp,".\r\n");
if (outlevel == O_VERBOSE)
error(0, 0, "SMTP>. (EOM)");
ok = SMTP_ok(sockfp);
{
char buf[SMTPBUFSIZE], *ip;
- while ((ip = fgets(buf, sizeof(buf)-1, sockfp)))
+ while ((ip = SockGets(buf, sizeof(buf)-1, sockfp)))
{
int n = strlen(ip);
+ if (buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ if (buf[strlen(buf)-1] == '\r')
+ buf[strlen(buf)-1] = '\r';
if (n < 4)
return SM_ERROR;
buf[n] = '\0';