Do not require SMTP authentication: Closes #6357
SMTP authentication is now entirely optional, distinct from not requiring a password (#5668).
This commit is contained in:
parent
95c96e42cc
commit
9f4b423b9b
6 changed files with 111 additions and 13 deletions
1
THANKS
1
THANKS
|
|
@ -11,6 +11,7 @@ Joanmarie Diggs <jdiggs@igalia.com>
|
|||
Christian Dywan <christian@twotoasts.de>
|
||||
Victor Eduardo <victor@elementaryos.org>
|
||||
Daniel Foré <daniel@elementaryos.org>
|
||||
Sven Hagemann <sven@rednose.nl>
|
||||
Timo Kluck <tkluck@infty.nl>
|
||||
Thomas Moschny <thomas.moschny@gmx.de>
|
||||
Robert Park <rbpark@exolucere.ca>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,12 @@ public class AddEditPage : Gtk.Box {
|
|||
combo_smtp_encryption.active = Encryption.STARTTLS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool smtp_noauth {
|
||||
get { return check_smtp_noauth.active; }
|
||||
set { check_smtp_noauth.active = value; }
|
||||
}
|
||||
|
||||
// these are tied to the values in the Glade file
|
||||
private enum Encryption {
|
||||
NONE = 0,
|
||||
|
|
@ -145,7 +150,11 @@ public class AddEditPage : Gtk.Box {
|
|||
private Gtk.Entry entry_smtp_username;
|
||||
private Gtk.Entry entry_smtp_password;
|
||||
private Gtk.ComboBox combo_smtp_encryption;
|
||||
|
||||
private Gtk.CheckButton check_smtp_noauth;
|
||||
|
||||
private string smtp_username_store;
|
||||
private string smtp_password_store;
|
||||
|
||||
private bool edited_imap_port = false;
|
||||
private bool edited_smtp_port = false;
|
||||
|
||||
|
|
@ -191,7 +200,8 @@ public class AddEditPage : Gtk.Box {
|
|||
entry_smtp_username = (Gtk.Entry) builder.get_object("entry: smtp username");
|
||||
entry_smtp_password = (Gtk.Entry) builder.get_object("entry: smtp password");
|
||||
combo_smtp_encryption = (Gtk.ComboBox) builder.get_object("combo: smtp encryption");
|
||||
|
||||
check_smtp_noauth = (Gtk.CheckButton) builder.get_object("check: smtp no authentication");
|
||||
|
||||
// Build list of service providers.
|
||||
foreach (Geary.ServiceProvider p in Geary.ServiceProvider.get_providers())
|
||||
combo_service.append_text(p.display_name());
|
||||
|
|
@ -219,6 +229,8 @@ public class AddEditPage : Gtk.Box {
|
|||
combo_imap_encryption.changed.connect(on_imap_encryption_changed);
|
||||
combo_smtp_encryption.changed.connect(on_smtp_encryption_changed);
|
||||
|
||||
check_smtp_noauth.toggled.connect(on_smtp_no_auth_changed);
|
||||
|
||||
entry_imap_port.insert_text.connect(on_port_insert_text);
|
||||
entry_smtp_port.insert_text.connect(on_port_insert_text);
|
||||
|
||||
|
|
@ -246,7 +258,8 @@ public class AddEditPage : Gtk.Box {
|
|||
info.default_smtp_server_host,
|
||||
info.default_smtp_server_port,
|
||||
info.default_smtp_server_ssl,
|
||||
info.default_smtp_server_starttls);
|
||||
info.default_smtp_server_starttls,
|
||||
info.default_smtp_server_noauth);
|
||||
}
|
||||
|
||||
// Can use this instead of set_account_information(), both do the same thing.
|
||||
|
|
@ -267,7 +280,8 @@ public class AddEditPage : Gtk.Box {
|
|||
string? initial_default_smtp_host = null,
|
||||
uint16 initial_default_smtp_port = Geary.Smtp.ClientConnection.DEFAULT_PORT_SSL,
|
||||
bool initial_default_smtp_ssl = true,
|
||||
bool initial_default_smtp_starttls = false) {
|
||||
bool initial_default_smtp_starttls = false,
|
||||
bool initial_default_smtp_noauth = false) {
|
||||
|
||||
// Set defaults
|
||||
real_name = initial_real_name ?? "";
|
||||
|
|
@ -292,6 +306,7 @@ public class AddEditPage : Gtk.Box {
|
|||
smtp_password = initial_smtp_password ?? "";
|
||||
smtp_ssl = initial_default_smtp_ssl;
|
||||
smtp_starttls = initial_default_smtp_starttls;
|
||||
smtp_noauth = initial_default_smtp_noauth;
|
||||
|
||||
if (Geary.String.is_empty(real_name))
|
||||
entry_real_name.grab_focus();
|
||||
|
|
@ -322,13 +337,17 @@ public class AddEditPage : Gtk.Box {
|
|||
// TODO: Only reset if not manually set by user.
|
||||
private void on_email_changed() {
|
||||
entry_imap_username.text = entry_email.text;
|
||||
entry_smtp_username.text = entry_email.text;
|
||||
|
||||
if (entry_smtp_username.sensitive)
|
||||
entry_smtp_username.text = entry_email.text;
|
||||
}
|
||||
|
||||
// TODO: Only reset if not manually set by user.
|
||||
private void on_password_changed() {
|
||||
entry_imap_password.text = entry_password.text;
|
||||
entry_smtp_password.text = entry_password.text;
|
||||
|
||||
if (entry_password.sensitive)
|
||||
entry_smtp_password.text = entry_password.text;
|
||||
}
|
||||
|
||||
private void on_changed() {
|
||||
|
|
@ -386,6 +405,25 @@ public class AddEditPage : Gtk.Box {
|
|||
edited_smtp_port = false;
|
||||
}
|
||||
|
||||
private void on_smtp_no_auth_changed() {
|
||||
if (check_smtp_noauth.active) {
|
||||
smtp_username_store = entry_smtp_username.text;
|
||||
smtp_password_store = entry_smtp_password.text;
|
||||
|
||||
entry_smtp_username.text = "";
|
||||
entry_smtp_password.text = "";
|
||||
|
||||
entry_smtp_username.sensitive = false;
|
||||
entry_smtp_password.sensitive = false;
|
||||
} else {
|
||||
entry_smtp_username.text = smtp_username_store;
|
||||
entry_smtp_password.text = smtp_password_store;
|
||||
|
||||
entry_smtp_username.sensitive = true;
|
||||
entry_smtp_password.sensitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
private uint16 get_default_smtp_port() {
|
||||
switch (combo_smtp_encryption.active) {
|
||||
case Encryption.SSL:
|
||||
|
|
@ -411,8 +449,8 @@ public class AddEditPage : Gtk.Box {
|
|||
Geary.String.is_empty_or_whitespace(imap_password) ||
|
||||
Geary.String.is_empty_or_whitespace(smtp_host) ||
|
||||
Geary.String.is_empty_or_whitespace(smtp_port.to_string()) ||
|
||||
Geary.String.is_empty_or_whitespace(smtp_username) ||
|
||||
Geary.String.is_empty_or_whitespace(smtp_password))
|
||||
Geary.String.is_empty_or_whitespace(smtp_username) && check_smtp_noauth.active == false ||
|
||||
Geary.String.is_empty_or_whitespace(smtp_password) && check_smtp_noauth.active == false)
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
|
@ -460,6 +498,10 @@ public class AddEditPage : Gtk.Box {
|
|||
account_information.default_smtp_server_port = smtp_port;
|
||||
account_information.default_smtp_server_ssl = smtp_ssl;
|
||||
account_information.default_smtp_server_starttls = smtp_starttls;
|
||||
account_information.default_smtp_server_noauth = smtp_noauth;
|
||||
|
||||
if (smtp_noauth)
|
||||
account_information.smtp_credentials = null;
|
||||
|
||||
on_changed();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ public class Geary.AccountInformation : Object {
|
|||
private const string SMTP_PORT = "smtp_port";
|
||||
private const string SMTP_SSL = "smtp_ssl";
|
||||
private const string SMTP_STARTTLS = "smtp_starttls";
|
||||
|
||||
private const string SMTP_NOAUTH = "smtp_noauth";
|
||||
|
||||
public const string SETTINGS_FILENAME = "geary.ini";
|
||||
public const string DEFAULT_NICKNAME = _("Default");
|
||||
|
||||
|
|
@ -44,10 +45,11 @@ public class Geary.AccountInformation : Object {
|
|||
public uint16 default_smtp_server_port { get; set; }
|
||||
public bool default_smtp_server_ssl { get; set; }
|
||||
public bool default_smtp_server_starttls { get; set; }
|
||||
public bool default_smtp_server_noauth { get; set; }
|
||||
|
||||
public Geary.Credentials imap_credentials { get; set; default = new Geary.Credentials(null, null); }
|
||||
public bool imap_remember_password { get; set; default = true; }
|
||||
public Geary.Credentials smtp_credentials { get; set; default = new Geary.Credentials(null, null); }
|
||||
public Geary.Credentials? smtp_credentials { get; set; default = new Geary.Credentials(null, null); }
|
||||
public bool smtp_remember_password { get; set; default = true; }
|
||||
|
||||
internal AccountInformation(File directory) {
|
||||
|
|
@ -86,6 +88,12 @@ public class Geary.AccountInformation : Object {
|
|||
Geary.Smtp.ClientConnection.DEFAULT_PORT_SSL);
|
||||
default_smtp_server_ssl = get_bool_value(key_file, GROUP, SMTP_SSL, true);
|
||||
default_smtp_server_starttls = get_bool_value(key_file, GROUP, SMTP_STARTTLS, false);
|
||||
default_smtp_server_noauth = get_bool_value(key_file, GROUP, SMTP_NOAUTH, false);
|
||||
|
||||
if (default_smtp_server_noauth) {
|
||||
// Make sure the SMTP credentials are unset.
|
||||
smtp_credentials = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -361,6 +369,7 @@ public class Geary.AccountInformation : Object {
|
|||
key_file.set_integer(GROUP, SMTP_PORT, default_smtp_server_port);
|
||||
key_file.set_boolean(GROUP, SMTP_SSL, default_smtp_server_ssl);
|
||||
key_file.set_boolean(GROUP, SMTP_STARTTLS, default_smtp_server_starttls);
|
||||
key_file.set_boolean(GROUP, SMTP_NOAUTH, default_smtp_server_noauth);
|
||||
}
|
||||
|
||||
string data = key_file.to_data();
|
||||
|
|
|
|||
|
|
@ -146,8 +146,14 @@ public class Geary.Smtp.ClientSession {
|
|||
foreach (RFC822.MailboxAddress mailbox in addrlist) {
|
||||
RcptRequest rcpt_request = new RcptRequest.plain(mailbox.address);
|
||||
Response response = yield cx.transaction_async(rcpt_request, cancellable);
|
||||
if (!response.code.is_success_completed())
|
||||
response.throw_error("\"%s\" failed".printf(rcpt_request.to_string()));
|
||||
|
||||
if (!response.code.is_success_completed()) {
|
||||
if (response.code.is_denied()) {
|
||||
response.throw_error("recipient \"%s\" denied by smtp server".printf(rcpt_request.to_string()));
|
||||
} else {
|
||||
response.throw_error("\"%s\" failed".printf(rcpt_request.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class Geary.Smtp.ResponseCode {
|
|||
|
||||
public const string START_DATA_CODE = "354";
|
||||
public const string STARTTLS_READY_CODE = "220";
|
||||
public const string DENIED_CODE = "550";
|
||||
|
||||
public enum Status {
|
||||
POSITIVE_PRELIMINARY = 1,
|
||||
|
|
@ -104,6 +105,10 @@ public class Geary.Smtp.ResponseCode {
|
|||
public bool is_starttls_ready() {
|
||||
return str == STARTTLS_READY_CODE;
|
||||
}
|
||||
|
||||
public bool is_denied() {
|
||||
return str == DENIED_CODE;
|
||||
}
|
||||
|
||||
public string serialize() {
|
||||
return str;
|
||||
|
|
|
|||
|
|
@ -644,6 +644,41 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="check: smtp no authentication">
|
||||
<property name="label" translatable="yes">No authentication re_quired</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">14</property>
|
||||
<property name="width">2</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue