Skip to content

API Reference

Daniel Berger edited this page Nov 20, 2026 · 1 revision

API reference

require 'mail/sympa'
sympa = Mail::Sympa.new('https://lists.example.org/sympasoap')
sympa.login('owner@example.org', 'your-password')

Connection and authentication

Mail::Sympa.new(endpoint, namespace = 'urn:sympasoap') creates a client. The endpoint may be a string or URI object. The endpoint, namespace, and cookie attributes are read-only; url is an alias for endpoint.

login(email, password) returns a session-cookie string. Login trims and lowercases the email address. Reauthentication clears the previous cookie before making the request, so failed login leaves the client unauthenticated.

Call login before the list, subscriber, permission, and which methods below. They raise Mail::Sympa::Error with must login first when no cookie is present.

Lists and permissions

Method Result and behavior
lists(topic = '', sub_topic = '') Array of strings containing list metadata. Omit topics to request all visible lists.
complex_lists(topic = '', sub_topic = '') Array of hashes containing structured list metadata. Alias: complexLists.
info(list_name) Hash describing one list.
review(list_name) Array of subscriber email strings. The tested server returns ['no_subscribers'] for an empty list.
am_i?(user, list_name, function = 'editor') Boolean indicating whether the user has the requested role. The wrapper accepts editor and owner. Alias: amI.

lists returns the server's metadata strings, not just bare list names. Use complex_lists when you want named fields:

sympa.complex_lists.each do |list|
  puts list[:list_address]
  puts list[:subject]
  puts list[:homepage]
end

info = sympa.info('announcements')
puts info[:subject]
puts info[:is_owner]

Fields depend on the operation and server response. SOAP camelCase field names are decoded to symbol keys such as :list_address, :is_owner, and :is_editor.

Subscriber changes

Method Behavior
add(email, list_name, name, quiet = true) Add a subscriber. The default suppresses the subscription notification.
del(email, list_name, quiet = true) Remove a subscriber. Alias: delete.
subscribe(list_name, name = @email) Subscribe the logged-in user. The default name is the canonical login email.
signoff(list_name) Unsubscribe the logged-in user. Alias: unsubscribe.

The tested Sympa server returns true for successful changes. Server scenarios, list ownership, and other permissions determine whether a request is allowed.

sympa.add('reader@example.org', 'announcements', 'Example Reader', true)
p sympa.review('announcements')
sympa.del('reader@example.org', 'announcements', true)

List administration

sympa.create_list(
  'new-list',
  'New list',
  'discussion_list',
  'A description of the new list',
  'computing'
)

sympa.close_list('new-list')

create_list(list_name, subject, template = 'discussion_list', description = ' ', topics = ' ') creates a list. Supply a template available on the server and a valid topic from its topics.conf. Sympa 6.2.70 rejects a blank topic, so passing only the list name and subject is insufficient in the tested environment. Alias: createList.

close_list(list_name) closes a list. Alias: closeList.

Both methods return true on success in the integration environment. These are server-state changes and require the appropriate server permissions.

Trusted applications

Configure the application in Sympa's trusted_applications.conf, including its password and permission to proxy USER_EMAIL.

variables = 'USER_EMAIL=reader@example.org'
lists = sympa.which(variables, 'portal', 'application-password')
structured_lists = sympa.complex_which(variables, 'portal', 'application-password')

which(user, app_name, app_passwd) returns an array of metadata strings. complex_which(user, app_name, app_passwd) returns structured hashes in an array; its alias is complexWhich. The user argument is the proxy-variable string, not a bare email address. The wrapper requires login before these convenience methods.

authenticate_remote_app_and_run(app_name, app_password, variables, service, parameters) exposes the five-argument trusted call directly. parameters is an array. This direct method uses the application's credentials and does not impose the convenience methods' cookie check. Alias: authenticateRemoteAppAndRun.

Errors and migration from 1.2.0

SOAP faults and transport failures surface as Mail::Sympa::Error; server fault details are included when available. Incorrect Ruby argument counts still raise ArgumentError.

begin
  sympa.review('missing-list')
rescue Mail::Sympa::Error => error
  warn error.message
end

Version 1.3.0 replaces soap4r-ruby1.9 with Savon and Nokogiri. Public method names and aliases remain, but structured return values have changed from SOAP::Mapping objects to hashes:

# 1.2.0: info.subject, info.isOwner
# 1.3.0:
info[:subject]
info[:is_owner]

Arrays, empty results, singleton results, and SOAP booleans are decoded from the native SOAP response. Authenticated calls use authenticateAndRun; trusted calls use authenticateRemoteAppAndRun, with SOAP-encoded parameter arrays.

For server-side semantics, see the Sympa SOAP/HTTP API.