SmtpcomApi
¶ ↑
SmtpcomApi
is a ruby wrapper for the smtp.com API (api.smtp.com)
Installation¶ ↑
[sudo] gem install smtpcom_api
Usage¶ ↑
Authentication¶ ↑
You need api key and api url for authentication in SmtpcomApi
client = SmtpcomApi::Client.new('your_api_key', 'api_url')
Account settings¶ ↑
Getting account
account = client.account
Getting account attributes as hash
account.attributes # or account.to_hash
Updating account attributes:
account.company_name = 'My Company' account.save
Senders¶ ↑
Getting senders list
senders = client.senders # or senders = account.senders
Finding one sender by his label or id
sender = client.sender('sender_label_or_id') # or sender = account.sender('sender_label_or_id')
Getting sender attributes as hash
sener.attributes # or sender.to_hash
Updating sender attributes
sender.login = 'new_login' sender.password = 'new_password1' sender.save
Adding new sender
attributes = { :label => 'my_label', :login => 'my_login', :password => 'my_password1', :max_quota => 10000 } new_sender = client.add_sender attributes
Some senders could be authenticated by IP address instead of login/pass To allow sender login that way you should set :is_ip_based attribute to true and add allowed IPs
# setting is_ip_based = true new_sender.is_ip_based = true new_sender.save # adding allowed IPs new_sender.add_allowed_ip('222.178.23.97') # or removing some new_sender.remove_allowed_ip('222.178.23.97')
Statistics¶ ↑
Examples how to get sender statistics data (summary/detailed delivery/campaigns/complaints/queue):
now = Time.now.to_i month_ago = now - 30*24*60*60 sender.summary :time_start => month_ago, :time_end => now sender.delivery :time_start => month_ago, :time_end => now, :limit => 10, :offset => 0 sender.campaigns :time_start => month_ago, :time_end => now sender.complaints :time_start => month_ago, :time_end => now, :limit => 10, :offset => 0 sender.queue :time_start => month_ago, :time_end => now, :limit => 10, :offset => 0
Contributing to smtpcom_api¶ ↑
-
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
-
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
-
Fork the project.
-
Start a feature/bugfix branch.
-
Commit and push until you are happy with your contribution.
-
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2012 Vasiliy Sablin. See LICENSE.txt for further details.