-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElasticEmailClient.pl
6772 lines (5821 loc) · 194 KB
/
ElasticEmailClient.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
#The MIT License (MIT)
#
#Copyright (c) 2016-2017 Elastic Email, Inc.
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
use strict;
use warnings;
###########################
package Api;
use LWP::UserAgent;
use File::Basename;
our $mainApi= new Api("00000000-0000-0000-0000-000000000000", 'example@email.com', 'https://api.elasticemail.com/v2/');
sub new
{
my $class = shift;
my $self = {
apikey => shift,
username => shift,
url => shift,
};
bless $self, $class;
return $self;
}
sub Request
{
my ($self, $urlLocal, $requestType, $one_ref, $two_ref) = @_;
my @allTheData = $one_ref ? @{$one_ref} : ();
my @postFilesPaths = $two_ref ? @{$two_ref} : ();
my $ua = LWP::UserAgent->new;
my $response;
if ($requestType eq "GET"){
my $fullURL = $self->{url}.$urlLocal."?";
for(my $i = 0; $i < scalar @allTheData - 1; $i += 2){
if(!defined $allTheData[$i+1]) { next; }
$fullURL = $fullURL.$allTheData[$i]." = ".$allTheData[$i+1]." & ";
}
chop($fullURL);
$response = $ua->get($fullURL);
}
elsif($requestType eq "POST"){
my $fullURL = $self->{url}.$urlLocal;
my $num = 0;
my $file;
foreach $file(@postFilesPaths){
my $localFileName = fileparse($file);
my $fieldName = 'file'.$num;
push($allTheData[0], ($fieldName, [$file, $localFileName]));
$num++;
}
$response = $ua->post($fullURL, Content_Type => 'multipart/form-data', Content => @allTheData);
}
my $content = $response->decoded_content();
return $content;
}
#
# Methods for managing your account and subaccounts.
#
package Api::Account;
# Create new subaccount and provide most important data about it.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string email - Proper email address.
# string password - Current password.
# string confirmPassword - Repeat new password.
# bool requiresEmailCredits - True, if account needs credits to send emails. Otherwise, false (default False)
# bool enableLitmusTest - True, if account is able to send template tests to Litmus. Otherwise, false (default False)
# bool requiresLitmusCredits - True, if account needs credits to send emails. Otherwise, false (default False)
# int maxContacts - Maximum number of contacts the account can have (default 0)
# bool enablePrivateIPRequest - True, if account can request for private IP on its own. Otherwise, false (default True)
# bool sendActivation - True, if you want to send activation email to this account. Otherwise, false (default False)
# string returnUrl - URL to navigate to after account creation (default None)
# ApiTypes::SendingPermission? sendingPermission - Sending permission setting for account (default None)
# bool? enableContactFeatures - True, if you want to use Contact Delivery Tools. Otherwise, false (default None)
# string poolName - Private IP required. Name of the custom IP Pool which Sub Account should use to send its emails. Leave empty for the default one or if no Private IPs have been bought (default None)
# int emailSizeLimit - Maximum size of email including attachments in MB's (default 10)
# int? dailySendLimit - Amount of emails account can send daily (default None)
# Returns string
sub AddSubAccount
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
email => shift,
password => shift,
confirmPassword => shift,
requiresEmailCredits => shift,
enableLitmusTest => shift,
requiresLitmusCredits => shift,
maxContacts => shift,
enablePrivateIPRequest => shift,
sendActivation => shift,
returnUrl => shift,
sendingPermission => shift,
enableContactFeatures => shift,
poolName => shift,
emailSizeLimit => shift,
dailySendLimit => shift];
return $Api::mainApi->Request('account/addsubaccount', "GET", @params);
}
# Add email, template or litmus credits to a sub-account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int credits - Amount of credits to add
# string notes - Specific notes about the transaction
# ApiTypes::CreditType creditType - Type of credits to add (Email or Litmus) (default ApiTypes.CreditType.Email)
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to add credits to. Use subAccountEmail or publicAccountID not both. (default None)
sub AddSubAccountCredits
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
credits => shift,
notes => shift,
creditType => shift,
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/addsubaccountcredits', "GET", @params);
}
# Change your email address. Remember, that your email address is used as login!
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string newEmail - New email address.
# string confirmEmail - New email address.
# string sourceUrl - URL from which request was sent. (default "https://elasticemail.com/account/")
# Returns string
sub ChangeEmail
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
newEmail => shift,
confirmEmail => shift,
sourceUrl => shift];
return $Api::mainApi->Request('account/changeemail', "GET", @params);
}
# Create new password for your account. Password needs to be at least 6 characters long.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string currentPassword - Current password.
# string newPassword - New password for account.
# string confirmPassword - Repeat new password.
sub ChangePassword
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
currentPassword => shift,
newPassword => shift,
confirmPassword => shift];
return $Api::mainApi->Request('account/changepassword', "GET", @params);
}
# Deletes specified Subaccount
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# bool notify - True, if you want to send an email notification. Otherwise, false (default True)
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to delete. Use subAccountEmail or publicAccountID not both. (default None)
sub DeleteSubAccount
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
notify => shift,
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/deletesubaccount', "GET", @params);
}
# Returns API Key for the given Sub Account.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to retrieve sub-account API Key. Use subAccountEmail or publicAccountID not both. (default None)
# Returns string
sub GetSubAccountApiKey
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/getsubaccountapikey', "GET", @params);
}
# Lists all of your subaccounts
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::SubAccount>
sub GetSubAccountList
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/getsubaccountlist', "GET", @params);
}
# Loads your account. Returns detailed information about your account.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::Account
sub Load
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/load', "GET", @params);
}
# Load advanced options of your account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::AdvancedOptions
sub LoadAdvancedOptions
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadadvancedoptions', "GET", @params);
}
# Lists email credits history
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::EmailCredits>
sub LoadEmailCreditsHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loademailcreditshistory', "GET", @params);
}
# Lists litmus credits history
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::LitmusCredits>
sub LoadLitmusCreditsHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadlitmuscreditshistory', "GET", @params);
}
# Shows queue of newest notifications - very useful when you want to check what happened with mails that were not received.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::NotificationQueue>
sub LoadNotificationQueue
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadnotificationqueue', "GET", @params);
}
# Lists all payments
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int limit - Maximum of loaded items.
# int offset - How many items should be loaded ahead.
# DateTime fromDate - Starting date for search in YYYY-MM-DDThh:mm:ss format.
# DateTime toDate - Ending date for search in YYYY-MM-DDThh:mm:ss format.
# Returns List<ApiTypes::Payment>
sub LoadPaymentHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
limit => shift,
offset => shift,
fromDate => shift,
toDate => shift];
return $Api::mainApi->Request('account/loadpaymenthistory', "GET", @params);
}
# Lists all referral payout history
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::Payment>
sub LoadPayoutHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadpayouthistory', "GET", @params);
}
# Shows information about your referral details
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::Referral
sub LoadReferralDetails
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadreferraldetails', "GET", @params);
}
# Shows latest changes in your sending reputation
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int limit - Maximum of loaded items. (default 20)
# int offset - How many items should be loaded ahead. (default 0)
# Returns List<ApiTypes::ReputationHistory>
sub LoadReputationHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
limit => shift,
offset => shift];
return $Api::mainApi->Request('account/loadreputationhistory', "GET", @params);
}
# Shows detailed information about your actual reputation score
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::ReputationDetail
sub LoadReputationImpact
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/loadreputationimpact', "GET", @params);
}
# Returns detailed spam check.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int limit - Maximum of loaded items. (default 20)
# int offset - How many items should be loaded ahead. (default 0)
# Returns List<ApiTypes::SpamCheck>
sub LoadSpamCheck
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
limit => shift,
offset => shift];
return $Api::mainApi->Request('account/loadspamcheck', "GET", @params);
}
# Lists email credits history for sub-account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to list history for. Use subAccountEmail or publicAccountID not both. (default None)
# Returns List<ApiTypes::EmailCredits>
sub LoadSubAccountsEmailCreditsHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/loadsubaccountsemailcreditshistory', "GET", @params);
}
# Loads settings of subaccount
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to load settings for. Use subAccountEmail or publicAccountID not both. (default None)
# Returns ApiTypes::SubAccountSettings
sub LoadSubAccountSettings
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/loadsubaccountsettings', "GET", @params);
}
# Lists litmus credits history for sub-account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to list history for. Use subAccountEmail or publicAccountID not both. (default None)
# Returns List<ApiTypes::LitmusCredits>
sub LoadSubAccountsLitmusCreditsHistory
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
subAccountEmail => shift,
publicAccountID => shift];
return $Api::mainApi->Request('account/loadsubaccountslitmuscreditshistory', "GET", @params);
}
# Shows usage of your account in given time.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# DateTime from - Starting date for search in YYYY-MM-DDThh:mm:ss format.
# DateTime to - Ending date for search in YYYY-MM-DDThh:mm:ss format.
# Returns List<ApiTypes::Usage>
sub LoadUsage
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
from => shift,
to => shift];
return $Api::mainApi->Request('account/loadusage', "GET", @params);
}
# Manages your apikeys.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string apiKey - APIKey you would like to manage.
# ApiTypes::APIKeyAction action - Specific action you would like to perform on the APIKey
# Returns List<string>
sub ManageApiKeys
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
apiKey => shift,
action => shift];
return $Api::mainApi->Request('account/manageapikeys', "GET", @params);
}
# Shows summary for your account.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::AccountOverview
sub Overview
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/overview', "GET", @params);
}
# Shows you account's profile basic overview
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns ApiTypes::Profile
sub ProfileOverview
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/profileoverview', "GET", @params);
}
# Remove email, template or litmus credits from a sub-account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# ApiTypes::CreditType creditType - Type of credits to add (Email or Litmus)
# string notes - Specific notes about the transaction
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to remove credits from. Use subAccountEmail or publicAccountID not both. (default None)
# int? credits - Amount of credits to remove (default None)
# bool removeAll - Remove all credits of this type from sub-account (overrides credits if provided) (default False)
sub RemoveSubAccountCredits
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
creditType => shift,
notes => shift,
subAccountEmail => shift,
publicAccountID => shift,
credits => shift,
removeAll => shift];
return $Api::mainApi->Request('account/removesubaccountcredits', "GET", @params);
}
# Request premium support for your account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
sub RequestPremiumSupport
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('account/requestpremiumsupport', "GET", @params);
}
# Request a private IP for your Account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int count - Number of items.
# string notes - Free form field of notes
sub RequestPrivateIP
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
count => shift,
notes => shift];
return $Api::mainApi->Request('account/requestprivateip', "GET", @params);
}
# Update sending and tracking options of your account.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# bool? enableClickTracking - True, if you want to track clicks. Otherwise, false (default None)
# bool? enableLinkClickTracking - True, if you want to track by link tracking. Otherwise, false (default None)
# bool? manageSubscriptions - True, if you want to display your labels on your unsubscribe form. Otherwise, false (default None)
# bool? manageSubscribedOnly - True, if you want to only display labels that the contact is subscribed to on your unsubscribe form. Otherwise, false (default None)
# bool? transactionalOnUnsubscribe - True, if you want to display an option for the contact to opt into transactional email only on your unsubscribe form. Otherwise, false (default None)
# bool? skipListUnsubscribe - True, if you do not want to use list-unsubscribe headers. Otherwise, false (default None)
# bool? autoTextFromHtml - True, if text BODY of message should be created automatically. Otherwise, false (default None)
# bool? allowCustomHeaders - True, if you want to apply custom headers to your emails. Otherwise, false (default None)
# string bccEmail - Email address to send a copy of all email to. (default None)
# string contentTransferEncoding - Type of content encoding (default None)
# bool? emailNotificationForError - True, if you want bounce notifications returned. Otherwise, false (default None)
# string emailNotificationEmail - Specific email address to send bounce email notifications to. (default None)
# string webNotificationUrl - URL address to receive web notifications to parse and process. (default None)
# bool? webNotificationNotifyOncePerEmail - True, if you want to receive notifications for each type only once per email. Otherwise, false (default None)
# bool? webNotificationForSent - True, if you want to send web notifications for sent email. Otherwise, false (default None)
# bool? webNotificationForOpened - True, if you want to send web notifications for opened email. Otherwise, false (default None)
# bool? webNotificationForClicked - True, if you want to send web notifications for clicked email. Otherwise, false (default None)
# bool? webNotificationForUnsubscribed - True, if you want to send web notifications for unsubscribed email. Otherwise, false (default None)
# bool? webNotificationForAbuseReport - True, if you want to send web notifications for complaint email. Otherwise, false (default None)
# bool? webNotificationForError - True, if you want to send web notifications for bounced email. Otherwise, false (default None)
# string hubCallBackUrl - URL used for tracking action of inbound emails (default "")
# string inboundDomain - Domain you use as your inbound domain (default None)
# bool? inboundContactsOnly - True, if you want inbound email to only process contacts from your account. Otherwise, false (default None)
# bool? lowCreditNotification - True, if you want to receive low credit email notifications. Otherwise, false (default None)
# bool? enableUITooltips - True, if account has tooltips active. Otherwise, false (default None)
# bool? enableContactFeatures - True, if you want to use Contact Delivery Tools. Otherwise, false (default None)
# string notificationsEmails - Email addresses to send a copy of all notifications from our system. Separated by semicolon (default None)
# string unsubscribeNotificationsEmails - Emails, separated by semicolon, to which the notification about contact unsubscribing should be sent to (default None)
# string logoUrl - URL to your logo image. (default None)
# bool? enableTemplateScripting - True, if you want to use template scripting in your emails {{}}. Otherwise, false (default True)
# int? staleContactScore - (0 means this functionality is NOT enabled) Score, depending on the number of times you have sent to a recipient, at which the given recipient should be moved to the Stale status (default None)
# int? staleContactInactiveDays - (0 means this functionality is NOT enabled) Number of days of inactivity for a contact after which the given recipient should be moved to the Stale status (default None)
# string deliveryReason - Why your clients are receiving your emails. (default None)
# bool? tutorialsEnabled - (default None)
# Returns ApiTypes::AdvancedOptions
sub UpdateAdvancedOptions
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
enableClickTracking => shift,
enableLinkClickTracking => shift,
manageSubscriptions => shift,
manageSubscribedOnly => shift,
transactionalOnUnsubscribe => shift,
skipListUnsubscribe => shift,
autoTextFromHtml => shift,
allowCustomHeaders => shift,
bccEmail => shift,
contentTransferEncoding => shift,
emailNotificationForError => shift,
emailNotificationEmail => shift,
webNotificationUrl => shift,
webNotificationNotifyOncePerEmail => shift,
webNotificationForSent => shift,
webNotificationForOpened => shift,
webNotificationForClicked => shift,
webNotificationForUnsubscribed => shift,
webNotificationForAbuseReport => shift,
webNotificationForError => shift,
hubCallBackUrl => shift,
inboundDomain => shift,
inboundContactsOnly => shift,
lowCreditNotification => shift,
enableUITooltips => shift,
enableContactFeatures => shift,
notificationsEmails => shift,
unsubscribeNotificationsEmails => shift,
logoUrl => shift,
enableTemplateScripting => shift,
staleContactScore => shift,
staleContactInactiveDays => shift,
deliveryReason => shift,
tutorialsEnabled => shift];
return $Api::mainApi->Request('account/updateadvancedoptions', "GET", @params);
}
# Update settings of your private branding. These settings are needed, if you want to use Elastic Email under your brand.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# bool enablePrivateBranding - True: Turn on or off ability to send mails under your brand. Otherwise, false (default False)
# string logoUrl - URL to your logo image. (default None)
# string supportLink - Address to your support. (default None)
# string privateBrandingUrl - Subdomain for your rebranded service (default None)
# string smtpAddress - Address of SMTP server. (default None)
# string smtpAlternative - Address of alternative SMTP server. (default None)
# string paymentUrl - URL for making payments. (default None)
sub UpdateCustomBranding
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
enablePrivateBranding => shift,
logoUrl => shift,
supportLink => shift,
privateBrandingUrl => shift,
smtpAddress => shift,
smtpAlternative => shift,
paymentUrl => shift];
return $Api::mainApi->Request('account/updatecustombranding', "GET", @params);
}
# Update http notification URL.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string url - URL of notification.
# bool notifyOncePerEmail - True, if you want to receive notifications for each type only once per email. Otherwise, false (default False)
# string settings - Http notification settings serialized to JSON (default None)
sub UpdateHttpNotification
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
url => shift,
notifyOncePerEmail => shift,
settings => shift];
return $Api::mainApi->Request('account/updatehttpnotification', "GET", @params);
}
# Update your profile.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string firstName - First name.
# string lastName - Last name.
# string address1 - First line of address.
# string city - City.
# string state - State or province.
# string zip - Zip/postal code.
# int countryID - Numeric ID of country. A file with the list of countries is available <a href="http://api.elasticemail.com/public/countries"><b>here</b></a>
# bool? marketingConsent - True if you want to receive newsletters from Elastic Email. Otherwise, false. Empty to leave the current value. (default None)
# string address2 - Second line of address. (default None)
# string company - Company name. (default None)
# string website - HTTP address of your website. (default None)
# string logoUrl - URL to your logo image. (default None)
# string taxCode - Code used for tax purposes. (default None)
# string phone - Phone number (default None)
sub UpdateProfile
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
firstName => shift,
lastName => shift,
address1 => shift,
city => shift,
state => shift,
zip => shift,
countryID => shift,
marketingConsent => shift,
address2 => shift,
company => shift,
website => shift,
logoUrl => shift,
taxCode => shift,
phone => shift];
return $Api::mainApi->Request('account/updateprofile', "GET", @params);
}
# Updates settings of specified subaccount
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# bool requiresEmailCredits - True, if account needs credits to send emails. Otherwise, false (default False)
# int monthlyRefillCredits - Amount of credits added to account automatically (default 0)
# bool requiresLitmusCredits - True, if account needs credits to send emails. Otherwise, false (default False)
# bool enableLitmusTest - True, if account is able to send template tests to Litmus. Otherwise, false (default False)
# int? dailySendLimit - Amount of emails account can send daily (default None)
# int emailSizeLimit - Maximum size of email including attachments in MB's (default 10)
# bool enablePrivateIPRequest - True, if account can request for private IP on its own. Otherwise, false (default False)
# int maxContacts - Maximum number of contacts the account can have (default 0)
# string subAccountEmail - Email address of sub-account (default None)
# string publicAccountID - Public key of sub-account to update. Use subAccountEmail or publicAccountID not both. (default None)
# ApiTypes::SendingPermission? sendingPermission - Sending permission setting for account (default None)
# bool? enableContactFeatures - True, if you want to use Contact Delivery Tools. Otherwise, false (default None)
# string poolName - Name of your custom IP Pool to be used in the sending process (default None)
sub UpdateSubAccountSettings
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
requiresEmailCredits => shift,
monthlyRefillCredits => shift,
requiresLitmusCredits => shift,
enableLitmusTest => shift,
dailySendLimit => shift,
emailSizeLimit => shift,
enablePrivateIPRequest => shift,
maxContacts => shift,
subAccountEmail => shift,
publicAccountID => shift,
sendingPermission => shift,
enableContactFeatures => shift,
poolName => shift];
return $Api::mainApi->Request('account/updatesubaccountsettings', "GET", @params);
}
#
# Managing attachments uploaded to your account.
#
package Api::Attachment;
# Permanently deletes attachment file from your account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# long attachmentID - ID number of your attachment.
sub Delete
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
attachmentID => shift];
return $Api::mainApi->Request('attachment/delete', "GET", @params);
}
# Gets address of chosen Attachment
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# long attachmentID - ID number of your attachment.
# Returns File
sub Get
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
attachmentID => shift];
return $Api::mainApi->Request('attachment/get', "GET", @params);
}
# Lists your available Attachments in the given email
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string msgID - ID number of selected message.
# Returns List<ApiTypes::Attachment>
sub List
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
msgID => shift];
return $Api::mainApi->Request('attachment/list', "GET", @params);
}
# Lists all your available attachments
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::Attachment>
sub ListAll
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('attachment/listall', "GET", @params);
}
# Permanently removes attachment file from your account
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string fileName - Name of your file.
sub Remove
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
fileName => shift];
return $Api::mainApi->Request('attachment/remove', "GET", @params);
}
# Uploads selected file to the server using http form upload format (MIME multipart/form-data) or PUT method. The attachments expire after 30 days.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# File attachmentFile - Content of your attachment.
# Returns ApiTypes::Attachment
sub Upload
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('attachment/upload', "POST", \@params, \@_);
}
#
# Sending and monitoring progress of your Campaigns
#
package Api::Campaign;
# Adds a campaign to the queue for processing based on the configuration
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# ApiTypes::Campaign campaign - Json representation of a campaign
# Returns int
sub Add
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
campaign => shift];
return $Api::mainApi->Request('campaign/add', "GET", @params);
}
# Copy selected campaign
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int channelID - ID number of selected Channel.
# Returns int
sub Copy
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelID => shift];
return $Api::mainApi->Request('campaign/copy', "GET", @params);
}
# Delete selected campaign
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# int channelID - ID number of selected Channel.
sub Delete
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelID => shift];
return $Api::mainApi->Request('campaign/delete', "GET", @params);
}
# Export selected campaigns to chosen file format.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# IEnumerable<int> channelIDs - List of campaign IDs used for processing (default None)
# ApiTypes::ExportFileFormats fileFormat - Format of the exported file (default ApiTypes.ExportFileFormats.Csv)
# ApiTypes::CompressionFormat compressionFormat - FileResponse compression format. None or Zip. (default ApiTypes.CompressionFormat.EENone)
# string fileName - Name of your file. (default None)
# Returns ApiTypes::ExportLink
sub Export
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelIDs => shift,
fileFormat => shift,
compressionFormat => shift,
fileName => shift];
return $Api::mainApi->Request('campaign/export', "GET", @params);
}
# List all of your campaigns
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string search - Text fragment used for searching. (default None)
# int offset - How many items should be loaded ahead. (default 0)
# int limit - Maximum of loaded items. (default 0)
# Returns List<ApiTypes::CampaignChannel>
sub List
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
search => shift,
offset => shift,
limit => shift];
return $Api::mainApi->Request('campaign/list', "GET", @params);
}
# Updates a previously added campaign. Only Active and Paused campaigns can be updated.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# ApiTypes::Campaign campaign - Json representation of a campaign
# Returns int
sub Update
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
campaign => shift];
return $Api::mainApi->Request('campaign/update', "GET", @params);
}
#
# SMTP and HTTP API channels for grouping email delivery.
#
package Api::Channel;
# Manually add a channel to your account to group email
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string name - Descriptive name of the channel
# Returns string
sub Add
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
name => shift];
return $Api::mainApi->Request('channel/add', "GET", @params);
}
# Delete the channel.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string name - The name of the channel to delete.
sub Delete
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
name => shift];
return $Api::mainApi->Request('channel/delete', "GET", @params);
}
# Export channels in CSV file format.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# IEnumerable<string> channelNames - List of channel names used for processing
# ApiTypes::CompressionFormat compressionFormat - FileResponse compression format. None or Zip. (default ApiTypes.CompressionFormat.EENone)
# string fileName - Name of your file. (default None)
# Returns File
sub ExportCsv
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelNames => shift,
compressionFormat => shift,
fileName => shift];
return $Api::mainApi->Request('channel/exportcsv', "GET", @params);
}
# Export channels in JSON file format.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# IEnumerable<string> channelNames - List of channel names used for processing
# ApiTypes::CompressionFormat compressionFormat - FileResponse compression format. None or Zip. (default ApiTypes.CompressionFormat.EENone)
# string fileName - Name of your file. (default None)
# Returns File
sub ExportJson
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelNames => shift,
compressionFormat => shift,
fileName => shift];
return $Api::mainApi->Request('channel/exportjson', "GET", @params);
}
# Export channels in XML file format.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# IEnumerable<string> channelNames - List of channel names used for processing
# ApiTypes::CompressionFormat compressionFormat - FileResponse compression format. None or Zip. (default ApiTypes.CompressionFormat.EENone)
# string fileName - Name of your file. (default None)
# Returns File
sub ExportXml
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
channelNames => shift,
compressionFormat => shift,
fileName => shift];
return $Api::mainApi->Request('channel/exportxml', "GET", @params);
}
# List all of your channels
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# Returns List<ApiTypes::Channel>
sub List
{
shift;
my @params = [apikey => $Api::mainApi->{apikey}];
return $Api::mainApi->Request('channel/list', "GET", @params);
}
# Rename an existing channel.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string name - The name of the channel to update.
# string newName - The new name for the channel.
# Returns string
sub Update
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
name => shift,
newName => shift];
return $Api::mainApi->Request('channel/update', "GET", @params);
}
#
# Methods used to manage your Contacts.
#
package Api::Contact;
# Add a new contact and optionally to one of your lists. Note that your API KEY is not required for this call.
# string publicAccountID - Public key for limited access to your account such as contact/add so you can use it safely on public websites.
# string email - Proper email address.
# IEnumerable<string> publicListID - ID code of list (default None)
# string[] listName - Name of your list. (default None)
# string firstName - First name. (default None)
# string lastName - Last name. (default None)
# ApiTypes::ContactSource source - Specifies the way of uploading the contact (default ApiTypes.ContactSource.ContactApi)
# string returnUrl - URL to navigate to after account creation (default None)
# string sourceUrl - URL from which request was sent. (default None)
# string activationReturnUrl - The url to return the contact to after activation. (default None)
# string activationTemplate - (default None)
# bool sendActivation - True, if you want to send activation email to this account. Otherwise, false (default True)
# DateTime? consentDate - Date of consent to send this contact(s) your email. If not provided current date is used for consent. (default None)
# string consentIP - IP address of consent to send this contact(s) your email. If not provided your current public IP address is used for consent. (default None)
# Dictionary<string, string> field - Custom contact field like firstname, lastname, city etc. Request parameters prefixed by field_ like field_firstname, field_lastname (default None)
# string notifyEmail - Emails, separated by semicolon, to which the notification about contact subscribing should be sent to (default None)
# Returns string
sub Add
{
shift;
my @params = [publicAccountID => shift,
email => shift,
publicListID => shift,
listName => shift,
firstName => shift,
lastName => shift,
source => shift,
returnUrl => shift,
sourceUrl => shift,
activationReturnUrl => shift,
activationTemplate => shift,
sendActivation => shift,
consentDate => shift,
consentIP => shift,
field => shift,
notifyEmail => shift];
return $Api::mainApi->Request('contact/add', "GET", @params);
}
# Manually add or update a contacts status to Abuse or Unsubscribed status (blocked).
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string email - Proper email address.
# ApiTypes::ContactStatus status - Name of status: Active, Engaged, Inactive, Abuse, Bounced, Unsubscribed.
sub AddBlocked
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
email => shift,
status => shift];
return $Api::mainApi->Request('contact/addblocked', "GET", @params);
}
# Change any property on the contact record.
# string apikey - ApiKey that gives you access to our SMTP and HTTP API's.
# string email - Proper email address.
# string name - Name of the contact property you want to change.
# string value - Value you would like to change the contact property to.
sub ChangeProperty
{
shift;
my @params = [apikey => $Api::mainApi->{apikey},
email => shift,
name => shift,
value => shift];
return $Api::mainApi->Request('contact/changeproperty', "GET", @params);
}