/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static gint verbose = 1;
static gchar smtp_response[MSGBUFSIZE];
-gint smtp_helo(SockInfo *sock, const char *hostname, gboolean use_smtp_auth)
+gint smtp_helo(SockInfo *sock, const gchar *hostname, gboolean esmtp)
{
- if (use_smtp_auth) {
- sock_printf(sock, "EHLO %s\r\n", hostname);
- if (verbose)
- log_print("ESMTP> EHLO %s\n", hostname);
-
- return esmtp_ok(sock);
- } else {
+ if (esmtp)
+ return esmtp_ehlo(sock, hostname);
+ else {
sock_printf(sock, "HELO %s\r\n", hostname);
if (verbose)
log_print("SMTP> HELO %s\n", hostname);
if (use_smtp_auth) {
/* exist AUTH-Type CRAM_MD5 */
- if (esmtp_auth_cram_md5(sock) == SM_ERROR) {
+ if (!smtp_auth_methods[SMTPAUTH_CRAM_MD5]
+ || esmtp_auth_cram_md5(sock) == SM_ERROR) {
/* exist AUTH-Type LOGIN */
- if (esmtp_auth_login(sock) == SM_ERROR)
+ if (!smtp_auth_methods[SMTPAUTH_LOGIN]
+ || esmtp_auth_login(sock) == SM_ERROR)
return SM_ERROR;
else
authtype = SMTPAUTH_LOGIN;
} else
authtype = SMTPAUTH_CRAM_MD5;
- esmtp_auth(sock, authtype, userid, passwd, use_smtp_auth);
+ if (esmtp_auth(sock, authtype, userid, passwd) != SM_OK)
+ return SM_AUTHFAIL;
}
if (strchr(from, '<'))
gint smtp_ok(SockInfo *sock)
{
- while ((sock_read(sock, smtp_response, sizeof(smtp_response) - 1))
- != 1) {
+ while ((sock_gets(sock, smtp_response, sizeof(smtp_response) - 1))
+ != -1) {
if (strlen(smtp_response) < 4)
return SM_ERROR;
strretchomp(smtp_response);
log_print("SMTP< %s\n", smtp_response);
if ((smtp_response[0] == '1' || smtp_response[0] == '2' ||
- smtp_response[0] == '3') && smtp_response[3] == ' ')
+ smtp_response[0] == '3') &&
+ (smtp_response[3] == ' ' || smtp_response[3] == '\0'))
return SM_OK;
else if (smtp_response[3] != '-')
return SM_ERROR;
- else if (smtp_response[0] == '5' && smtp_response[1] == '0' &&
- (smtp_response[3] == '4' || smtp_response[3] == '3' || smtp_response[3] == '1'))
- return SM_ERROR;
+ else if (smtp_response[0] == '5' &&
+ smtp_response[1] == '0' &&
+ (smtp_response[2] == '4' ||
+ smtp_response[2] == '3' ||
+ smtp_response[2] == '1'))
+ return SM_ERROR;
}
return SM_UNRECOVERABLE;