PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/dynamics/mailgun/plugin.php +50 -29 10.1.4 → 11.1.0 View file →
@@ -34,19 +34,23 @@
34 34 ];
35 35 $config = empty($data['tab']) ? $this->config : $data['tab']->config;
36 36 $defaultDomain = $config->get(self::SENDING_METHOD_ID.'_api_domain');
37 37 $defaultApiKey = $config->get(self::SENDING_METHOD_ID.'_api_key');
38 - ob_start();
39 38 ?>
40 - <div class="send_settings cell grid-x acym_vcenter" id="<?php echo self::SENDING_METHOD_ID; ?>_settings">
39 + <div class="send_settings cell grid-x acym_vcenter" id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings">
41 40 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
42 41 <label class="cell large-3 medium-4 margin-right-1">
43 42 <?php
44 - echo acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION', self::SENDING_METHOD_NAME);
45 - echo acym_info(acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION_DESC', self::SENDING_METHOD_NAME)); ?>
43 + echo esc_html(acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION', self::SENDING_METHOD_NAME));
44 + acym_info(
45 + [
46 + 'textShownInTooltip' => acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION_DESC', self::SENDING_METHOD_NAME),
47 + ]
48 + );
49 + ?>
46 50 </label>
47 51 <?php
48 - echo acym_radio(
52 + acym_radio(
49 53 $regions,
50 54 'config['.self::SENDING_METHOD_ID.'_api_region]',
51 55 $this->config->get(self::SENDING_METHOD_ID.'_api_region', 'us')
52 56 );
@@ -52,39 +56,42 @@
52 56 );
53 57 ?>
54 58 </div>
55 59 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
56 - <label class="cell" for="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-domain">
57 - <?php echo acym_translationSprintf(
58 - 'ACYM_SENDING_METHOD_API_DOMAIN',
59 - self::SENDING_METHOD_NAME
60 + <label class="cell" for="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-domain">
61 + <?php echo esc_html(
62 + acym_translationSprintf(
63 + 'ACYM_SENDING_METHOD_API_DOMAIN',
64 + self::SENDING_METHOD_NAME
65 + )
60 66 ); ?>
61 67 </label>
62 68 <input type="text"
63 - id="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-domain"
64 - value="<?php echo empty($defaultDomain) ? $this->config->get(self::SENDING_METHOD_ID.'_api_domain') : $defaultDomain; ?>"
65 - name="config[<?php echo self::SENDING_METHOD_ID; ?>_api_domain]"
66 - class="cell acym__configuration__mail__settings__text">
69 + id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-domain"
70 + value="<?php echo esc_attr(empty($defaultDomain) ? $this->config->get(self::SENDING_METHOD_ID.'_api_domain') : $defaultDomain); ?>"
71 + name="config[<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_api_domain]"
72 + class="cell acym__configuration__mail__settings__text">
67 73 </div>
68 74 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
69 - <label class="cell shrink margin-right-1" for="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-key">
70 - <?php echo acym_translationSprintf(
71 - 'ACYM_SENDING_METHOD_API_KEY',
72 - self::SENDING_METHOD_NAME
75 + <label class="cell shrink margin-right-1" for="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-key">
76 + <?php echo esc_html(
77 + acym_translationSprintf(
78 + 'ACYM_SENDING_METHOD_API_KEY',
79 + self::SENDING_METHOD_NAME
80 + )
73 81 ); ?>
74 82 </label>
75 - <?php echo $this->getLinks('https://signup.mailgun.com/new/signup', 'https://www.mailgun.com/pricing/'); ?>
83 + <?php $this->getLinks('https://signup.mailgun.com/new/signup', 'https://www.mailgun.com/pricing/'); ?>
76 84 <input type="text"
77 - id="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-key"
78 - value="<?php echo empty($defaultApiKey) ? $this->config->get(self::SENDING_METHOD_ID.'_api_key') : $defaultApiKey; ?>"
79 - name="config[<?php echo self::SENDING_METHOD_ID; ?>_api_key]"
80 - class="cell acym__configuration__mail__settings__text">
81 - <?php echo $this->getTestCredentialsSendingMethodButton(self::SENDING_METHOD_ID); ?>
82 - <?php echo $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
85 + id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-key"
86 + value="<?php echo esc_attr(empty($defaultApiKey) ? $this->config->get(self::SENDING_METHOD_ID.'_api_key') : $defaultApiKey); ?>"
87 + name="config[<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_api_key]"
88 + class="cell acym__configuration__mail__settings__text">
89 + <?php $this->getTestCredentialsSendingMethodButton(self::SENDING_METHOD_ID); ?>
90 + <?php $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
83 91 </div>
84 92 </div>
85 93 <?php
86 - $data['sendingMethodsHtmlSettings'][self::SENDING_METHOD_ID] = ob_get_clean();
87 94 }
88 95
89 96 public function onAcymTestCredentialSendingMethod($sendingMethod, $credentials)
90 97 {
@@ -102,8 +109,9 @@
102 109 ];
103 110
104 111 $response = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true);
105 112
113 + // If call didn't work, the response is always null
106 114 if (empty($response)) {
107 115 acym_sendAjaxResponse(acym_translation('ACYM_AUTHENTICATION_FAILS_WITH_API_KEY'), [], false);
108 116 } else {
109 117 acym_sendAjaxResponse(acym_translation('ACYM_API_KEY_CORRECT'));
@@ -111,8 +119,9 @@
111 119 }
112 120
113 121 public function onAcymSendEmail(&$response, $mailerHelper, $to, $from, $replyTo, $bcc = [], $attachments = [], $sendingMethodListParams = [])
114 122 {
123 + //https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api
115 124 if ($mailerHelper->externalMailer !== self::SENDING_METHOD_ID) return;
116 125
117 126 $this->setSendingMethodApiUrl();
118 127 $headers = $this->getHeadersSendingMethod(self::SENDING_METHOD_ID);
@@ -141,19 +150,24 @@
141 150 $data['bcc['.$key.']'] = $bccEmail[0];
142 151 }
143 152 }
144 153
154 + $files = [];
145 155 if (!empty($attachments)) {
146 156 foreach ($attachments as $key => $attachment) {
147 - $data['attachment['.$key.']'] = curl_file_create($attachment[0]);
157 + $files[] = [
158 + 'name' => 'attachment['.$key.']',
159 + 'path' => $attachment[0],
160 + 'filename' => basename($attachment[0]),
161 + ];
148 162 }
149 163 }
150 164
151 - $responseMailer = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true);
165 + $responseMailer = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true, $files);
152 166
153 - if (empty($responseMailer['message']) || empty($responseMailer['id']) || $responseMailer['message'] != 'Queued. Thank you.') {
167 + if (empty($responseMailer['message']) || empty($responseMailer['id']) || $responseMailer['message'] !== 'Queued. Thank you.') {
154 168 $response['error'] = true;
155 - $response['message'] = $responseMailer['message'];
169 + $response['message'] = $responseMailer['message'] ?? ($responseMailer['error_curl'] ?? acym_translation('ACYM_ERROR'));
156 170 } else {
157 171 $response['error'] = false;
158 172 }
159 173 }
@@ -173,8 +187,15 @@
173 187 $this->sendingMethodApiUrl .= $credentials[self::SENDING_METHOD_ID.'_api_domain'].'/';
174 188 }
175 189 }
176 190
191 + /**
192 + * @param array $credentials
193 + * @param string $sendingMethod
194 + * @param array $sendingMethodListParams this parameter is only used for the plugin sending method list
195 + *
196 + * @return void
197 + */
177 198 public function onAcymGetCredentialsSendingMethod(array &$credentials, string $sendingMethod, array $sendingMethodListParams = [])
178 199 {
179 200 if ($sendingMethod != self::SENDING_METHOD_ID) return;
180 201