#include "gtkutils.h"
#include "inc.h"
#include "log.h"
+#include "passwordstore.h"
typedef struct _SendProgressDialog SendProgressDialog;
* because it's editable. */
fp_pos = ftell(fp);
- tmp_msginfo = procheader_parse_stream(fp, flags, FALSE, FALSE);
- fseek(fp, fp_pos, SEEK_SET);
-
- if (tmp_msginfo && tmp_msginfo->from) {
+ if (fp_pos < 0) {
+ perror("ftell");
+ return -1;
+ }
+ tmp_msginfo = procheader_parse_stream(fp, flags, TRUE, FALSE);
+ if (fseek(fp, fp_pos, SEEK_SET) < 0) {
+ perror("fseek");
+ return -1;
+ }
+
+ if (tmp_msginfo && tmp_msginfo->extradata && tmp_msginfo->extradata->resent_from) {
+ strncpy2(spec_from, tmp_msginfo->extradata->resent_from, BUFFSIZE-1);
+ extract_address(spec_from);
+ } else if (tmp_msginfo && tmp_msginfo->from) {
strncpy2(spec_from, tmp_msginfo->from, BUFFSIZE-1);
extract_address(spec_from);
} else {
strncpy2(spec_from, ac_prefs->address, BUFFSIZE-1);
}
if (tmp_msginfo) {
- procmsg_msginfo_free(tmp_msginfo);
+ procmsg_msginfo_free(&tmp_msginfo);
}
if (!ac_prefs->session) {
/* we can't reuse a previously initialised session */
session = smtp_session_new(ac_prefs);
+ session->ssl_cert_auto_accept = ac_prefs->ssl_certs_auto_accept;
+
smtp_session = SMTP_SESSION(session);
if (ac_prefs->set_domain && ac_prefs->domain && strlen(ac_prefs->domain)) {
smtp_session->hostname = NULL;
}
+#ifdef USE_GNUTLS
+ port = ac_prefs->set_smtpport ? ac_prefs->smtpport :
+ ac_prefs->ssl_smtp == SSL_TUNNEL ? SSMTP_PORT : SMTP_PORT;
+ session->ssl_type = ac_prefs->ssl_smtp;
+ if (ac_prefs->ssl_smtp != SSL_NONE)
+ session->nonblocking = ac_prefs->use_nonblocking_ssl;
+ if (ac_prefs->set_gnutls_priority && ac_prefs->gnutls_priority &&
+ strlen(ac_prefs->gnutls_priority))
+ session->gnutls_priority = g_strdup(ac_prefs->gnutls_priority);
+#else
+ if (ac_prefs->ssl_smtp != SSL_NONE) {
+ if (alertpanel_full(_("Insecure connection"),
+ _("This connection is configured to be secured "
+ "using SSL, but SSL is not available in this "
+ "build of Claws Mail. \n\n"
+ "Do you want to continue connecting to this "
+ "server? The communication would not be "
+ "secure."),
+ GTK_STOCK_CANCEL, _("Con_tinue connecting"),
+ NULL, FALSE, NULL, ALERT_WARNING,
+ G_ALERTDEFAULT) != G_ALERTALTERNATE) {
+ session_destroy(session);
+ return -1;
+ }
+ }
+ port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT;
+#endif
+
if (ac_prefs->use_smtp_auth) {
smtp_session->forced_auth_type = ac_prefs->smtp_auth_type;
if (ac_prefs->smtp_userid && strlen(ac_prefs->smtp_userid)) {
smtp_session->user = g_strdup(ac_prefs->smtp_userid);
- if (ac_prefs->smtp_passwd)
- smtp_session->pass =
- g_strdup(ac_prefs->smtp_passwd);
- else {
+ if (password_get(smtp_session->user,
+ ac_prefs->smtp_server, "smtp", port,
+ &(smtp_session->pass))) {
+ /* NOP */;
+ } else if ((smtp_session->pass =
+ passwd_store_get_account(ac_prefs->account_id,
+ PWS_ACCOUNT_SEND)) == NULL) {
smtp_session->pass =
input_dialog_query_password_keep
(ac_prefs->smtp_server,
}
} else {
smtp_session->user = g_strdup(ac_prefs->userid);
- if (ac_prefs->passwd)
- smtp_session->pass = g_strdup(ac_prefs->passwd);
- else {
+ if (password_get(smtp_session->user,
+ ac_prefs->smtp_server, "smtp", port,
+ &(smtp_session->pass))) {
+ /* NOP */;
+ } else if ((smtp_session->pass = passwd_store_get_account(
+ ac_prefs->account_id, PWS_ACCOUNT_RECV)) == NULL) {
smtp_session->pass =
input_dialog_query_password_keep
(ac_prefs->smtp_server,
smtp_session->pass = NULL;
}
-#ifdef USE_GNUTLS
- port = ac_prefs->set_smtpport ? ac_prefs->smtpport :
- ac_prefs->ssl_smtp == SSL_TUNNEL ? SSMTP_PORT : SMTP_PORT;
- session->ssl_type = ac_prefs->ssl_smtp;
- if (ac_prefs->ssl_smtp != SSL_NONE)
- session->nonblocking = ac_prefs->use_nonblocking_ssl;
- if (ac_prefs->set_gnutls_priority && ac_prefs->gnutls_priority &&
- strlen(ac_prefs->gnutls_priority))
- session->gnutls_priority = g_strdup(ac_prefs->gnutls_priority);
-#else
- if (ac_prefs->ssl_smtp != SSL_NONE) {
- if (alertpanel_full(_("Insecure connection"),
- _("This connection is configured to be secured "
- "using SSL, but SSL is not available in this "
- "build of Claws Mail. \n\n"
- "Do you want to continue connecting to this "
- "server? The communication would not be "
- "secure."),
- GTK_STOCK_CANCEL, _("Con_tinue connecting"),
- NULL, FALSE, NULL, ALERT_WARNING,
- G_ALERTDEFAULT) != G_ALERTALTERNATE) {
- session_destroy(session);
- return -1;
- }
- }
- port = ac_prefs->set_smtpport ? ac_prefs->smtpport : SMTP_PORT;
-#endif
-
send_dialog = send_progress_dialog_create();
send_dialog->session = session;
smtp_session->dialog = send_dialog;
switch (smtp_session->state) {
case SMTP_READY:
- case SMTP_CONNECTED:
return 0;
case SMTP_HELO:
g_snprintf(buf, sizeof(buf), _("Sending HELO..."));
state_str = _("Quitting");
break;
case SMTP_ERROR:
- g_warning("send: error: %s\n", msg);
+ g_warning("send: error: %s", msg);
return 0;
default:
return 0;