Version Description
Download this release
Release Info
Developer | Mailgun |
Plugin | Mailgun for WordPress |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.5.0
- CHANGELOG.md +46 -0
- LICENSE +339 -0
- includes/admin.php +376 -315
- includes/lists-page.php +74 -55
- includes/options-page.php +158 -136
- includes/widget.php +82 -64
- includes/wp-mail.php +352 -253
- languages/mailgun-ca.mo +0 -0
- languages/mailgun-ca.po +209 -0
- languages/mailgun-de_DE.mo +0 -0
- languages/mailgun-de_DE.po +206 -0
- languages/mailgun-es_ES.mo +0 -0
- languages/mailgun-es_ES.po +207 -0
- mailgun.php +415 -387
- readme.txt +16 -47
CHANGELOG.md
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Changelog
|
2 |
+
=========
|
3 |
+
|
4 |
+
1.5 (2016-12-19):
|
5 |
+
* Added Catalan language support (@DavidGarciaCat)
|
6 |
+
* Added Spanish language support (@DavidGarciaCat)
|
7 |
+
* Added German language support (@lsinger)
|
8 |
+
* Fixed incorrect SMTP hostname
|
9 |
+
* Applied PSR standards across codebase
|
10 |
+
* Applied open tracking bugfix
|
11 |
+
* Applied tags bugfix
|
12 |
+
* Applied `Mailgun Lists` admin panel bugfix
|
13 |
+
* Fixed click tracking dropdown
|
14 |
+
* Fixed click tracking and open tracking
|
15 |
+
* Now try to process *all* sent mails as HTML, see L201 wp-mail.php for details
|
16 |
+
* Mailgun logo now loads on both admin pages ;)
|
17 |
+
* Now using the Mailgun API v3 endpoint!
|
18 |
+
* Configuration test will now present either an error from the API or the HTTP response code + message
|
19 |
+
|
20 |
+
1.4.1 (2015-12-01):
|
21 |
+
* Clarify compatibility with WordPress 4.3
|
22 |
+
|
23 |
+
1.4 (2015-11-15):
|
24 |
+
* Added shortcode and widget support for list subscription
|
25 |
+
|
26 |
+
1.3.1 (2014-11-19):
|
27 |
+
* Switched to Semantic Versioning
|
28 |
+
* Fixed issue with campaigns and tags
|
29 |
+
|
30 |
+
1.3 (2014-08-25):
|
31 |
+
* Added check to ignore empty attachments
|
32 |
+
|
33 |
+
1.2 (2014-08-19):
|
34 |
+
* Fixed errors related to undefined variable. https://github.com/mailgun/wordpress-plugin/pull/3
|
35 |
+
|
36 |
+
1.1 (2013-12-09):
|
37 |
+
* Attachments are now handled properly.
|
38 |
+
* Added ability to customize tags and campaigns.
|
39 |
+
* Added ability to toggle URL and open tracking.
|
40 |
+
|
41 |
+
1.0 (2012-11-27):
|
42 |
+
* Re-release to update versioning to start at 1.0 instead of 0.1
|
43 |
+
|
44 |
+
0.1 (2012-11-21):
|
45 |
+
* Initial Release
|
46 |
+
|
LICENSE
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
includes/admin.php
CHANGED
@@ -1,319 +1,380 @@
|
|
1 |
<?php
|
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 |
<?php
|
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 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
+
class MailgunAdmin extends Mailgun
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Setup backend functionality in WordPress.
|
26 |
+
*
|
27 |
+
* @return none
|
28 |
+
*
|
29 |
+
* @since 0.1
|
30 |
+
*/
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
Mailgun::__construct();
|
34 |
+
|
35 |
+
// Load localizations if available
|
36 |
+
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
37 |
+
|
38 |
+
// Activation hook
|
39 |
+
register_activation_hook($this->plugin_file, [&$this, 'init']);
|
40 |
+
|
41 |
+
if (!defined('MAILGUN_USEAPI') || !MAILGUN_USEAPI) {
|
42 |
+
// Hook into admin_init and register settings and potentially register an admin_notice
|
43 |
+
add_action('admin_init', [&$this, 'admin_init']);
|
44 |
+
|
45 |
+
// Activate the options page
|
46 |
+
add_action('admin_menu', [&$this, 'admin_menu']);
|
47 |
+
}
|
48 |
+
|
49 |
+
// Register an AJAX action for testing mail sending capabilities
|
50 |
+
add_action('wp_ajax_mailgun-test', [&$this, 'ajax_send_test']);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Initialize the default options during plugin activation.
|
55 |
+
*
|
56 |
+
* @return none
|
57 |
+
*
|
58 |
+
* @since 0.1
|
59 |
+
*/
|
60 |
+
public function init()
|
61 |
+
{
|
62 |
+
$sitename = strtolower($_SERVER['SERVER_NAME']);
|
63 |
+
if (substr($sitename, 0, 4) == 'www.') {
|
64 |
+
$sitename = substr($sitename, 4);
|
65 |
+
}
|
66 |
+
|
67 |
+
$defaults = [
|
68 |
+
'useAPI' => '1',
|
69 |
+
'apiKey' => '',
|
70 |
+
'domain' => '',
|
71 |
+
'username' => '',
|
72 |
+
'password' => '',
|
73 |
+
'secure' => '1',
|
74 |
+
'track-clicks' => '',
|
75 |
+
'track-opens' => '',
|
76 |
+
'campaign-id' => '',
|
77 |
+
'tag' => $sitename,
|
78 |
+
];
|
79 |
+
if (!$this->options) {
|
80 |
+
$this->options = $defaults;
|
81 |
+
add_option('mailgun', $this->options);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add the options page.
|
87 |
+
*
|
88 |
+
* @return none
|
89 |
+
*
|
90 |
+
* @since 0.1
|
91 |
+
*/
|
92 |
+
public function admin_menu()
|
93 |
+
{
|
94 |
+
if (current_user_can('manage_options')) {
|
95 |
+
$this->hook_suffix = add_options_page(__('Mailgun', 'mailgun'), __('Mailgun', 'mailgun'), 'manage_options', 'mailgun', [&$this, 'options_page']);
|
96 |
+
add_options_page(__('Mailgun Lists', 'mailgun'), __('Mailgun Lists', 'mailgun'), 'manage_options', 'mailgun-lists', [&$this, 'lists_page']);
|
97 |
+
add_action("admin_print_scripts-{$this->hook_suffix}", [&$this, 'admin_js']);
|
98 |
+
add_filter("plugin_action_links_{$this->plugin_basename}", [&$this, 'filter_plugin_actions']);
|
99 |
+
add_action("admin_footer-{$this->hook_suffix}", [&$this, 'admin_footer_js']);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Enqueue javascript required for the admin settings page.
|
105 |
+
*
|
106 |
+
* @return none
|
107 |
+
*
|
108 |
+
* @since 0.1
|
109 |
+
*/
|
110 |
+
public function admin_js()
|
111 |
+
{
|
112 |
+
wp_enqueue_script('jquery');
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Output JS to footer for enhanced admin page functionality.
|
117 |
+
*
|
118 |
+
* @since 0.1
|
119 |
+
*/
|
120 |
+
public function admin_footer_js()
|
121 |
+
{
|
122 |
+
?>
|
123 |
+
<script type="text/javascript">
|
124 |
+
/* <![CDATA[ */
|
125 |
+
var mailgunApiOrNot = function() {
|
126 |
+
if (jQuery("#mailgun-api").val() == 1) {
|
127 |
+
jQuery(".mailgun-smtp").hide();
|
128 |
+
jQuery(".mailgun-api").show();
|
129 |
+
} else {
|
130 |
+
jQuery(".mailgun-api").hide();
|
131 |
+
jQuery(".mailgun-smtp").show();
|
132 |
+
}
|
133 |
+
|
134 |
+
}
|
135 |
+
var formModified = false;
|
136 |
+
jQuery().ready(function() {
|
137 |
+
mailgunApiOrNot();
|
138 |
+
jQuery('#mailgun-api').change(function() {
|
139 |
+
mailgunApiOrNot();
|
140 |
+
});
|
141 |
+
jQuery('#mailgun-test').click(function(e) {
|
142 |
+
e.preventDefault();
|
143 |
+
if ( formModified ) {
|
144 |
+
var doTest = confirm('<?php _e('The Mailgun plugin configuration has changed since you last saved. Do you wish to test anyway?\n\nClick "Cancel" and then "Save Changes" if you wish to save your changes.', 'mailgun'); ?>');
|
145 |
+
if ( ! doTest ) {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
jQuery(this).val('<?php _e('Testing...', 'mailgun'); ?>');
|
150 |
+
jQuery("#mailgun-test-result").text('');
|
151 |
+
jQuery.get(
|
152 |
+
ajaxurl,
|
153 |
+
{
|
154 |
+
action: 'mailgun-test',
|
155 |
+
_wpnonce: '<?php echo wp_create_nonce(); ?>'
|
156 |
+
}
|
157 |
+
)
|
158 |
+
.complete(function() {
|
159 |
+
jQuery("#mailgun-test").val('<?php _e('Test Configuration', 'mailgun'); ?>');
|
160 |
+
})
|
161 |
+
.success(function(data) {
|
162 |
+
alert(
|
163 |
+
'Mailgun ' + data.method + ' Test ' + data.message
|
164 |
+
+ '; status "' + data.error + '"'
|
165 |
+
);
|
166 |
+
})
|
167 |
+
.error(function() {
|
168 |
+
alert('Mailgun Test <?php _e('Failure', 'mailgun'); ?>');
|
169 |
+
});
|
170 |
+
});
|
171 |
+
jQuery("#mailgun-form").change(function() {
|
172 |
+
formModified = true;
|
173 |
+
});
|
174 |
+
});
|
175 |
+
/* ]]> */
|
176 |
+
</script>
|
177 |
+
<?php
|
178 |
+
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Output the options page.
|
183 |
+
*
|
184 |
+
* @return none
|
185 |
+
*
|
186 |
+
* @since 0.1
|
187 |
+
*/
|
188 |
+
public function options_page()
|
189 |
+
{
|
190 |
+
if (!@include 'options-page.php') {
|
191 |
+
printf(__('<div id="message" class="updated fade"><p>The options page for the <strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</strong> is missing. Please reinstall the plugin.</p></div>', 'mailgun'), dirname(__FILE__).'/options-page.php');
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Output the lists page.
|
197 |
+
*
|
198 |
+
* @return none
|
199 |
+
*
|
200 |
+
* @since 0.1
|
201 |
+
*/
|
202 |
+
public function lists_page()
|
203 |
+
{
|
204 |
+
if (!@include 'lists-page.php') {
|
205 |
+
printf(__('<div id="message" class="updated fade"><p>The lists page for the <strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</strong> is missing. Please reinstall the plugin.</p></div>', 'mailgun'), dirname(__FILE__).'/lists-page.php');
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
// /options-general.php?page=mailgun-lists
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Wrapper function hooked into admin_init to register settings
|
213 |
+
* and potentially register an admin notice if the plugin hasn't
|
214 |
+
* been configured yet.
|
215 |
+
*
|
216 |
+
* @return none
|
217 |
+
*
|
218 |
+
* @since 0.1
|
219 |
+
*/
|
220 |
+
public function admin_init()
|
221 |
+
{
|
222 |
+
$this->register_settings();
|
223 |
+
$apiKey = $this->get_option('apiKey');
|
224 |
+
$useAPI = $this->get_option('useAPI');
|
225 |
+
$password = $this->get_option('password');
|
226 |
+
if ((empty($apiKey) && $useAPI == '1') || (empty($password) && $useAPI == '0')) {
|
227 |
+
add_action('admin_notices', [&$this, 'admin_notices']);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Whitelist the mailgun options.
|
233 |
+
*
|
234 |
+
* @since 0.1
|
235 |
+
*
|
236 |
+
* @return none
|
237 |
+
*/
|
238 |
+
public function register_settings()
|
239 |
+
{
|
240 |
+
register_setting('mailgun', 'mailgun', [&$this, 'validation']);
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* Data validation callback function for options.
|
245 |
+
*
|
246 |
+
* @param array $options An array of options posted from the options page
|
247 |
+
*
|
248 |
+
* @return array
|
249 |
+
*
|
250 |
+
* @since 0.1
|
251 |
+
*/
|
252 |
+
public function validation($options)
|
253 |
+
{
|
254 |
+
$apiKey = trim($options['apiKey']);
|
255 |
+
$username = trim($options['username']);
|
256 |
+
if (!empty($apiKey)) {
|
257 |
+
$pos = strpos($apiKey, 'key-');
|
258 |
+
if ($pos === false || $pos > 4) {
|
259 |
+
$apiKey = "key-{$apiKey}";
|
260 |
+
}
|
261 |
+
|
262 |
+
$pos = strpos($apiKey, 'api:');
|
263 |
+
if ($pos !== false && $pos == 0) {
|
264 |
+
$apiKey = substr($apiKey, 4);
|
265 |
+
}
|
266 |
+
$options['apiKey'] = $apiKey;
|
267 |
+
}
|
268 |
+
|
269 |
+
if (!empty($username)) {
|
270 |
+
$username = preg_replace('/@.+$/', '', $username);
|
271 |
+
$options['username'] = $username;
|
272 |
+
}
|
273 |
+
|
274 |
+
foreach ($options as $key => $value) {
|
275 |
+
$options[$key] = trim($value);
|
276 |
+
}
|
277 |
+
|
278 |
+
$this->options = $options;
|
279 |
+
|
280 |
+
return $options;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Function to output an admin notice when the plugin has not
|
285 |
+
* been configured yet.
|
286 |
+
*
|
287 |
+
* @return none
|
288 |
+
*
|
289 |
+
* @since 0.1
|
290 |
+
*/
|
291 |
+
public function admin_notices()
|
292 |
+
{
|
293 |
+
$screen = get_current_screen();
|
294 |
+
if ($screen->id == $this->hook_suffix) {
|
295 |
+
return;
|
296 |
+
} ?>
|
297 |
+
<div id='mailgun-warning' class='updated fade'><p><strong><?php _e('Mailgun is almost ready. ', 'mailgun'); ?></strong><?php printf(__('You must <a href="%1$s">configure Mailgun</a> for it to work.', 'mailgun'), menu_page_url('mailgun', false)); ?></p></div>
|
298 |
<?php
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Add a settings link to the plugin actions.
|
304 |
+
*
|
305 |
+
* @param array $links Array of the plugin action links
|
306 |
+
*
|
307 |
+
* @return array
|
308 |
+
*
|
309 |
+
* @since 0.1
|
310 |
+
*/
|
311 |
+
public function filter_plugin_actions($links)
|
312 |
+
{
|
313 |
+
$settings_link = '<a href="'.menu_page_url('mailgun', false).'">'.__('Settings', 'mailgun').'</a>';
|
314 |
+
array_unshift($links, $settings_link);
|
315 |
+
|
316 |
+
return $links;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* AJAX callback function to test mail sending functionality.
|
321 |
+
*
|
322 |
+
* @return string
|
323 |
+
*
|
324 |
+
* @since 0.1
|
325 |
+
*/
|
326 |
+
public function ajax_send_test()
|
327 |
+
{
|
328 |
+
nocache_headers();
|
329 |
+
header('Content-Type: application/json');
|
330 |
+
|
331 |
+
if (!current_user_can('manage_options') || !wp_verify_nonce($_GET['_wpnonce'])) {
|
332 |
+
die(
|
333 |
+
json_encode(
|
334 |
+
[
|
335 |
+
'message' => __('Unauthorized', 'mailgun'),
|
336 |
+
'method' => null,
|
337 |
+
]
|
338 |
+
)
|
339 |
+
);
|
340 |
+
}
|
341 |
+
|
342 |
+
$useAPI = (defined('MAILGUN_USEAPI') && MAILGUN_USEAPI) ? MAILGUN_USEAPI : $this->get_option('useAPI');
|
343 |
+
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
344 |
+
if ((bool) $useAPI) {
|
345 |
+
$method = __('HTTP API', 'mailgun');
|
346 |
+
} else {
|
347 |
+
$method = ((bool) $secure) ? __('Secure SMTP', 'mailgun') : __('SMTP', 'mailgun');
|
348 |
+
}
|
349 |
+
|
350 |
+
$admin_email = get_option('admin_email');
|
351 |
+
$result = wp_mail(
|
352 |
+
$admin_email,
|
353 |
+
__('Mailgun WordPress Plugin Test', 'mailgun'),
|
354 |
+
sprintf(__("This is a test email generated by the Mailgun WordPress plugin.\n\nIf you have received this message, the requested test has succeeded.\n\nThe method used to send this email was: %s.", 'mailgun'), $method),
|
355 |
+
['Content-Type: text/plain']
|
356 |
+
);
|
357 |
+
|
358 |
+
if ($result) {
|
359 |
+
die(
|
360 |
+
json_encode(
|
361 |
+
[
|
362 |
+
'message' => __('Success', 'mailgun'),
|
363 |
+
'method' => $method,
|
364 |
+
'error' => __('Success', 'mailgun'),
|
365 |
+
]
|
366 |
+
)
|
367 |
+
);
|
368 |
+
} else {
|
369 |
+
die(
|
370 |
+
json_encode(
|
371 |
+
[
|
372 |
+
'message' => __('Failure', 'mailgun'),
|
373 |
+
'method' => $method,
|
374 |
+
'error' => mg_api_last_error(),
|
375 |
+
]
|
376 |
+
)
|
377 |
+
);
|
378 |
+
}
|
379 |
+
}
|
380 |
}
|
includes/lists-page.php
CHANGED
@@ -1,76 +1,95 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
?>
|
21 |
|
22 |
<div class="wrap">
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
<a target="_blank" href="http://www.mailgun.com/">
|
28 |
-
<img src="https://2e6874288eee3bf7ca22-d122329f808928cff1e9967578106854.ssl.cf1.rackcdn.com/mailgun-logo.png" alt="Mailgun" />
|
29 |
-
</a>
|
30 |
-
</span>
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
<?php settings_fields( 'mailgun' ); ?>
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
<div id="mailgun-lists" style="margin-top:20px;">
|
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 |
</div>
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
+
global $mailgun;
|
23 |
+
|
24 |
+
// check mailgun domain & api key
|
25 |
+
$missing_error = '';
|
26 |
+
$api_key = $this->get_option('apiKey');
|
27 |
+
$mailgun_domain = $this->get_option('domain');
|
28 |
+
if ($api_key != '') {
|
29 |
+
if ($mailgun_domain == '') {
|
30 |
+
$missing_error = '<strong style="color:red;">Missing or invalid Mailgun Domain</strong>. ';
|
31 |
+
}
|
32 |
+
} else {
|
33 |
+
$missing_error = '<strong style="color:red;">Missing or invalid API Key</strong>. ';
|
34 |
+
}
|
35 |
+
|
36 |
+
// import available lists
|
37 |
+
$lists_arr = $mailgun->get_lists();
|
38 |
+
|
39 |
?>
|
40 |
|
41 |
<div class="wrap">
|
42 |
|
43 |
+
<div id="icon-options-general" class="icon32"><br /></div>
|
44 |
+
|
45 |
+
<span class="alignright">
|
46 |
+
<a target="_blank" href="http://www.mailgun.com/">
|
47 |
+
<img src="http://www.mailgun.com/static/img/mailgun.svg" alt="Mailgun" style="width: 10em;"/>
|
48 |
+
</a>
|
49 |
+
</span>
|
50 |
+
|
51 |
+
<h2><?php _e('Mailgun Lists', 'mailgun'); ?></h2>
|
52 |
|
53 |
+
<?php settings_fields('mailgun'); ?>
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
<h3><?php _e('Available Mailing Lists', 'mailgun'); ?> | <a href="/wp-admin/options-general.php?page=mailgun">Back to settings</a></h3>
|
|
|
|
|
56 |
|
57 |
+
<p><?php _e("{$missing_error}You must use a valid Mailgun domain name and API key to access lists", 'mailgun'); ?></p>
|
58 |
|
59 |
+
<div id="mailgun-lists" style="margin-top:20px;">
|
|
|
|
|
60 |
|
61 |
+
<?php if (!empty($lists_arr)) : ?>
|
62 |
|
63 |
+
<table class="wp-list-table widefat fixed striped pages">
|
64 |
|
65 |
+
<tr>
|
66 |
+
<th>List Address</th>
|
67 |
+
<th>Description</th>
|
68 |
+
<th>Shortcode</th>
|
69 |
+
</tr>
|
70 |
|
71 |
+
<?php foreach ($lists_arr as $list) : ?>
|
72 |
|
73 |
+
<tr>
|
74 |
+
<td><?php echo $list['address']; ?></td>
|
75 |
+
<td><?php echo $list['description']; ?></td>
|
76 |
+
<td>
|
77 |
+
[mailgun id="<?php echo $list['address']; ?>"]
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
|
81 |
+
<?php endforeach; ?>
|
82 |
|
83 |
+
</table>
|
84 |
|
85 |
+
<h3>Multi-list subscription</h3>
|
86 |
+
<p>
|
87 |
+
<?php _e('To allow users to subscribe to multiple lists on a single form, comma-separate the Mailgun list ids.', 'mailgun'); ?></p>
|
88 |
+
<p class="description">
|
89 |
+
<?php _e('<strong>Example:</strong> [mailgun id="list1@mydomain.com,list2@mydomain.com"]'); ?>
|
90 |
+
</p>
|
91 |
|
92 |
+
<?php endif; ?>
|
93 |
|
94 |
+
</div>
|
95 |
</div>
|
includes/options-page.php
CHANGED
@@ -1,137 +1,159 @@
|
|
1 |
-
|
2 |
-
<div id="icon-options-general" class="icon32"><br /></div>
|
3 |
-
<span class="alignright"><a target="_blank" href="http://www.mailgun.com/"><img src="https://2e6874288eee3bf7ca22-d122329f808928cff1e9967578106854.ssl.cf1.rackcdn.com/mailgun-logo.png" alt="Mailgun" /></a></span>
|
4 |
-
<h2><?php _e( 'Mailgun' , 'mailgun' ); ?></h2>
|
5 |
-
<p>A <a target="_blank" href="http://www.mailgun.com/">Mailgun</a> account is required to use this plugin and the Mailgun service.</p>
|
6 |
-
<p>If you need to register for an account, you can do so at <a target="_blank" href="http://www.mailgun.com/">http://www.mailgun.com/</a>.</p>
|
7 |
-
<form id="mailgun-form" action="options.php" method="post">
|
8 |
-
<?php settings_fields( 'mailgun' ); ?>
|
9 |
-
<h3><?php _e( 'Configuration' , 'mailgun' ); ?></h3>
|
10 |
-
<table class="form-table">
|
11 |
-
<tr valign="top">
|
12 |
-
<th scope="row">
|
13 |
-
<?php _e( 'Use HTTP API' , 'mailgun' ); ?>
|
14 |
-
</th>
|
15 |
-
<td>
|
16 |
-
<select id="mailgun-api" name="mailgun[useAPI]">
|
17 |
-
<option value="1"<?php selected( '1' , $this->get_option( 'useAPI' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
|
18 |
-
<option value="0"<?php selected( '0' , $this->get_option( 'useAPI' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
|
19 |
-
</select>
|
20 |
-
<p class="description"><?php _e( 'Set this to "No" if your server cannot make outbound HTTP connections or if emails are not being delivered. "No" will cause this plugin to use SMTP. Default "Yes".', 'mailgun' ); ?></p>
|
21 |
-
</td>
|
22 |
-
</tr>
|
23 |
-
<tr valign="top">
|
24 |
-
<th scope="row">
|
25 |
-
<?php _e( 'Mailgun Domain Name' , 'mailgun' ); ?>
|
26 |
-
</th>
|
27 |
-
<td>
|
28 |
-
<input type="text" class="regular-text" name="mailgun[domain]" value="<?php esc_attr_e( $this->get_option( 'domain' ) ); ?>" placeholder="samples.mailgun.org" />
|
29 |
-
<p class="description"><?php _e( 'Your Mailgun Domain Name.', 'mailgun' ); ?></p>
|
30 |
-
</td>
|
31 |
-
</tr>
|
32 |
-
<tr valign="top" class="mailgun-api">
|
33 |
-
<th scope="row">
|
34 |
-
<?php _e( 'API Key' , 'mailgun' ); ?>
|
35 |
-
</th>
|
36 |
-
<td>
|
37 |
-
<input type="text" class="regular-text" name="mailgun[apiKey]" value="<?php esc_attr_e( $this->get_option( 'apiKey' ) ); ?>" placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0" />
|
38 |
-
<p class="description"><?php _e( 'Your Mailgun API key, that starts with and includes "key-". Only valid for use with the API.', 'mailgun' ); ?></p>
|
39 |
-
</td>
|
40 |
-
</tr>
|
41 |
-
<tr valign="top" class="mailgun-smtp">
|
42 |
-
<th scope="row">
|
43 |
-
<?php _e( 'Username' , 'mailgun' ); ?>
|
44 |
-
</th>
|
45 |
-
<td>
|
46 |
-
<input type="text" class="regular-text" name="mailgun[username]" value="<?php esc_attr_e( $this->get_option( 'username' ) ); ?>" placeholder="postmaster" />
|
47 |
-
<p class="description"><?php _e( 'Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun' ); ?></p>
|
48 |
-
</td>
|
49 |
-
</tr>
|
50 |
-
<tr valign="top" class="mailgun-smtp">
|
51 |
-
<th scope="row">
|
52 |
-
<?php _e( 'Password' , 'mailgun' ); ?>
|
53 |
-
</th>
|
54 |
-
<td>
|
55 |
-
<input type="text" class="regular-text" name="mailgun[password]" value="<?php esc_attr_e( $this->get_option( 'password' ) ); ?>" placeholder="my-password" />
|
56 |
-
<p class="description"><?php _e( 'Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun' ); ?></p>
|
57 |
-
</td>
|
58 |
-
</tr>
|
59 |
-
<tr valign="top" class="mailgun-smtp">
|
60 |
-
<th scope="row">
|
61 |
-
<?php _e( 'Use Secure SMTP' , 'mailgun' ); ?>
|
62 |
-
</th>
|
63 |
-
<td>
|
64 |
-
<select name="mailgun[secure]">
|
65 |
-
<option value="1"<?php selected( '1' , $this->get_option( 'secure' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
|
66 |
-
<option value="0"<?php selected( '0' , $this->get_option( 'secure' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
|
67 |
-
</select>
|
68 |
-
<p class="description"><?php _e( 'Set this to "No" if your server cannot establish SSL SMTP connections or if emails are not being delivered. If you set this to "No" your password will be sent in plain text. Only valid for use with SMTP. Default "Yes".', 'mailgun' ); ?></p>
|
69 |
-
</td>
|
70 |
-
</tr>
|
71 |
-
<tr valign="top">
|
72 |
-
<th scope="row">
|
73 |
-
<?php _e( 'Click Tracking' , 'mailgun' ); ?>
|
74 |
-
</th>
|
75 |
-
<td>
|
76 |
-
<select name="mailgun[track-clicks]">
|
77 |
-
<option value="yes"<?php selected( 'yes' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
|
78 |
-
<option value="htmlonly"<?php selected( 'htmlonly' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'HTML Only' , 'mailgun' ); ?></option>
|
79 |
-
<option value="no"<?php selected( 'no' , $this->get_option( 'track-clicks' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
|
80 |
-
</select>
|
81 |
-
<p class="description"><?php _e( 'If enabled, Mailgun will and track links.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-clicks" target="_blank">Click Tracking Documentation</a></p>
|
82 |
-
</td>
|
83 |
-
</tr>
|
84 |
-
<tr valign="top">
|
85 |
-
<th scope="row">
|
86 |
-
<?php _e( 'Open Tracking' , 'mailgun' ); ?>
|
87 |
-
</th>
|
88 |
-
<td>
|
89 |
-
<select name="mailgun[track-opens]">
|
90 |
-
<option value="1"<?php selected( '1' , $this->get_option( 'track-opens' ) ); ?>><?php _e( 'Yes' , 'mailgun' ); ?></option>
|
91 |
-
<option value="0"<?php selected( '0' , $this->get_option( 'track-opens' ) ); ?>><?php _e( 'No' , 'mailgun' ); ?></option>
|
92 |
-
</select>
|
93 |
-
<p class="description"><?php _e( 'If enabled, HTML messages will include an open tracking beacon.', 'mailgun' ); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-opens" target="_blank">Open Tracking Documentation</a></p>
|
94 |
-
</td>
|
95 |
-
</tr>
|
96 |
-
<tr valign="top">
|
97 |
-
<th scope="row">
|
98 |
-
<?php _e( 'Tag' , 'mailgun' ); ?>
|
99 |
-
</th>
|
100 |
-
<td>
|
101 |
-
<input type="text" class="regular-text" name="mailgun[campaign-id]" value="<?php esc_attr_e( $this->get_option( 'campaign-id' ) ); ?>" placeholder="tag" />
|
102 |
-
<p class="description"><?php _e( 'If added, this tag will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple tags.', 'mailgun' ); ?> <?php _e('Learn more about','mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tracking-messages" target="_blank">Tracking</a> <?php _e('and','mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tagging" target="_blank">Tagging</a>.</p>
|
103 |
-
</td>
|
104 |
-
</tr>
|
105 |
-
</table>
|
106 |
-
<h3><?php _e( 'Lists' , 'mailgun' ); ?></h3>
|
107 |
-
<table class="form-table">
|
108 |
-
<tr valign="top">
|
109 |
-
<th scope="row">
|
110 |
-
<?php _e( 'Shortcode' , 'mailgun' ); ?>
|
111 |
-
</th>
|
112 |
-
<td>
|
113 |
-
<div>
|
114 |
-
<strong>[mailgun id="<em>{mailgun list id}</em>" collect_name="true"]</strong>
|
115 |
-
</div>
|
116 |
-
<div>
|
117 |
-
<p class="description"><?php _e( 'Use the shortcode above to associate a widget instance with a mailgun list', 'mailgun' ); ?></p>
|
118 |
-
</div>
|
119 |
-
</td>
|
120 |
-
</tr>
|
121 |
-
<tr valign="top">
|
122 |
-
<th scope="row">
|
123 |
-
<?php _e( 'Lists' , 'mailgun' ); ?>
|
124 |
-
</th>
|
125 |
-
<td>
|
126 |
-
<a href="?page=mailgun-lists">View available lists</a>
|
127 |
-
</td>
|
128 |
-
</tr>
|
129 |
-
</table>
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
+
?>
|
23 |
+
<div class="wrap">
|
24 |
+
<div id="icon-options-general" class="icon32"><br /></div>
|
25 |
+
<span class="alignright"><a target="_blank" href="http://www.mailgun.com/"><img src="http://www.mailgun.com/static/img/mailgun.svg" alt="Mailgun" style="width: 10em;"/></a></span>
|
26 |
+
<h2><?php _e('Mailgun', 'mailgun'); ?></h2>
|
27 |
+
<p>A <a target="_blank" href="http://www.mailgun.com/">Mailgun</a> account is required to use this plugin and the Mailgun service.</p>
|
28 |
+
<p>If you need to register for an account, you can do so at <a target="_blank" href="http://www.mailgun.com/">http://www.mailgun.com/</a>.</p>
|
29 |
+
<form id="mailgun-form" action="options.php" method="post">
|
30 |
+
<?php settings_fields('mailgun'); ?>
|
31 |
+
<h3><?php _e('Configuration', 'mailgun'); ?></h3>
|
32 |
+
<table class="form-table">
|
33 |
+
<tr valign="top">
|
34 |
+
<th scope="row">
|
35 |
+
<?php _e('Use HTTP API', 'mailgun'); ?>
|
36 |
+
</th>
|
37 |
+
<td>
|
38 |
+
<select id="mailgun-api" name="mailgun[useAPI]">
|
39 |
+
<option value="1"<?php selected('1', $this->get_option('useAPI')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
40 |
+
<option value="0"<?php selected('0', $this->get_option('useAPI')); ?>><?php _e('No', 'mailgun'); ?></option>
|
41 |
+
</select>
|
42 |
+
<p class="description"><?php _e('Set this to "No" if your server cannot make outbound HTTP connections or if emails are not being delivered. "No" will cause this plugin to use SMTP. Default "Yes".', 'mailgun'); ?></p>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
<tr valign="top">
|
46 |
+
<th scope="row">
|
47 |
+
<?php _e('Mailgun Domain Name', 'mailgun'); ?>
|
48 |
+
</th>
|
49 |
+
<td>
|
50 |
+
<input type="text" class="regular-text" name="mailgun[domain]" value="<?php esc_attr_e($this->get_option('domain')); ?>" placeholder="samples.mailgun.org" />
|
51 |
+
<p class="description"><?php _e('Your Mailgun Domain Name.', 'mailgun'); ?></p>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
<tr valign="top" class="mailgun-api">
|
55 |
+
<th scope="row">
|
56 |
+
<?php _e('API Key', 'mailgun'); ?>
|
57 |
+
</th>
|
58 |
+
<td>
|
59 |
+
<input type="text" class="regular-text" name="mailgun[apiKey]" value="<?php esc_attr_e($this->get_option('apiKey')); ?>" placeholder="key-3ax6xnjp29jd6fds4gc373sgvjxteol0" />
|
60 |
+
<p class="description"><?php _e('Your Mailgun API key, that starts with and includes "key-". Only valid for use with the API.', 'mailgun'); ?></p>
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
+
<tr valign="top" class="mailgun-smtp">
|
64 |
+
<th scope="row">
|
65 |
+
<?php _e('Username', 'mailgun'); ?>
|
66 |
+
</th>
|
67 |
+
<td>
|
68 |
+
<input type="text" class="regular-text" name="mailgun[username]" value="<?php esc_attr_e($this->get_option('username')); ?>" placeholder="postmaster" />
|
69 |
+
<p class="description"><?php _e('Your Mailgun SMTP username. Only valid for use with SMTP.', 'mailgun'); ?></p>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<tr valign="top" class="mailgun-smtp">
|
73 |
+
<th scope="row">
|
74 |
+
<?php _e('Password', 'mailgun'); ?>
|
75 |
+
</th>
|
76 |
+
<td>
|
77 |
+
<input type="text" class="regular-text" name="mailgun[password]" value="<?php esc_attr_e($this->get_option('password')); ?>" placeholder="my-password" />
|
78 |
+
<p class="description"><?php _e('Your Mailgun SMTP password that goes with the above username. Only valid for use with SMTP.', 'mailgun'); ?></p>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
<tr valign="top" class="mailgun-smtp">
|
82 |
+
<th scope="row">
|
83 |
+
<?php _e('Use Secure SMTP', 'mailgun'); ?>
|
84 |
+
</th>
|
85 |
+
<td>
|
86 |
+
<select name="mailgun[secure]">
|
87 |
+
<option value="1"<?php selected('1', $this->get_option('secure')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
88 |
+
<option value="0"<?php selected('0', $this->get_option('secure')); ?>><?php _e('No', 'mailgun'); ?></option>
|
89 |
+
</select>
|
90 |
+
<p class="description"><?php _e('Set this to "No" if your server cannot establish SSL SMTP connections or if emails are not being delivered. If you set this to "No" your password will be sent in plain text. Only valid for use with SMTP. Default "Yes".', 'mailgun'); ?></p>
|
91 |
+
</td>
|
92 |
+
</tr>
|
93 |
+
<tr valign="top">
|
94 |
+
<th scope="row">
|
95 |
+
<?php _e('Click Tracking', 'mailgun'); ?>
|
96 |
+
</th>
|
97 |
+
<td>
|
98 |
+
<select name="mailgun[track-clicks]">
|
99 |
+
<option value="yes"<?php selected('yes', $this->get_option('track-clicks')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
100 |
+
<option value="htmlonly"<?php selected('htmlonly', $this->get_option('track-clicks')); ?>><?php _e('HTML Only', 'mailgun'); ?></option>
|
101 |
+
<option value="no"<?php selected('no', $this->get_option('track-clicks')); ?>><?php _e('No', 'mailgun'); ?></option>
|
102 |
+
</select>
|
103 |
+
<p class="description"><?php _e('If enabled, Mailgun will and track links.', 'mailgun'); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-clicks" target="_blank">Click Tracking Documentation</a></p>
|
104 |
+
</td>
|
105 |
+
</tr>
|
106 |
+
<tr valign="top">
|
107 |
+
<th scope="row">
|
108 |
+
<?php _e('Open Tracking', 'mailgun'); ?>
|
109 |
+
</th>
|
110 |
+
<td>
|
111 |
+
<select name="mailgun[track-opens]">
|
112 |
+
<option value="1"<?php selected('1', $this->get_option('track-opens')); ?>><?php _e('Yes', 'mailgun'); ?></option>
|
113 |
+
<option value="0"<?php selected('0', $this->get_option('track-opens')); ?>><?php _e('No', 'mailgun'); ?></option>
|
114 |
+
</select>
|
115 |
+
<p class="description"><?php _e('If enabled, HTML messages will include an open tracking beacon.', 'mailgun'); ?> <a href="http://documentation.mailgun.com/user_manual.html#tracking-opens" target="_blank">Open Tracking Documentation</a></p>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<tr valign="top">
|
119 |
+
<th scope="row">
|
120 |
+
<?php _e('Tag', 'mailgun'); ?>
|
121 |
+
</th>
|
122 |
+
<td>
|
123 |
+
<input type="text" class="regular-text" name="mailgun[campaign-id]" value="<?php esc_attr_e($this->get_option('campaign-id')); ?>" placeholder="tag" />
|
124 |
+
<p class="description"><?php _e('If added, this tag will exist on every outbound message. Statistics will be populated in the Mailgun Control Panel. Use a comma to define multiple tags.', 'mailgun'); ?> <?php _e('Learn more about', 'mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tracking-messages" target="_blank">Tracking</a> <?php _e('and', 'mailgun'); ?> <a href="https://documentation.mailgun.com/user_manual.html#tagging" target="_blank">Tagging</a>.</p>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
</table>
|
128 |
+
<h3><?php _e('Lists', 'mailgun'); ?></h3>
|
129 |
+
<table class="form-table">
|
130 |
+
<tr valign="top">
|
131 |
+
<th scope="row">
|
132 |
+
<?php _e('Shortcode', 'mailgun'); ?>
|
133 |
+
</th>
|
134 |
+
<td>
|
135 |
+
<div>
|
136 |
+
<strong>[mailgun id="<em>{mailgun list id}</em>" collect_name="true"]</strong>
|
137 |
+
</div>
|
138 |
+
<div>
|
139 |
+
<p class="description"><?php _e('Use the shortcode above to associate a widget instance with a mailgun list', 'mailgun'); ?></p>
|
140 |
+
</div>
|
141 |
+
</td>
|
142 |
+
</tr>
|
143 |
+
<tr valign="top">
|
144 |
+
<th scope="row">
|
145 |
+
<?php _e('Lists', 'mailgun'); ?>
|
146 |
+
</th>
|
147 |
+
<td>
|
148 |
+
<a href="?page=mailgun-lists">View available lists</a>
|
149 |
+
</td>
|
150 |
+
</tr>
|
151 |
+
</table>
|
152 |
+
|
153 |
+
<p><?php _e('Before attempting to test the configuration, please click "Save Changes".', 'mailgun'); ?></p>
|
154 |
+
<p class="submit">
|
155 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes', 'mailgun'); ?>" />
|
156 |
+
<input type="button" id="mailgun-test" class="button-secondary" value="<?php _e('Test Configuration', 'mailgun'); ?>" />
|
157 |
+
</p>
|
158 |
+
</form>
|
159 |
+
</div>
|
includes/widget.php
CHANGED
@@ -1,93 +1,111 @@
|
|
1 |
<?php
|
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 |
-
// Widget Backend
|
42 |
-
public function form(
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
} else {
|
48 |
-
$list_address = __(
|
49 |
}
|
50 |
|
51 |
-
|
52 |
$collect_name = 'checked';
|
53 |
} else {
|
54 |
-
|
55 |
}
|
56 |
|
57 |
-
$list_title = isset(
|
58 |
-
$list_description = isset(
|
59 |
-
|
60 |
// Widget admin form
|
61 |
?>
|
62 |
<div class="mailgun-list-widget-back">
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
</div>
|
80 |
<?php
|
81 |
}
|
82 |
-
|
83 |
// Updating widget replacing old instances with new
|
84 |
-
public function update(
|
85 |
-
|
86 |
-
|
|
|
87 |
|
88 |
return $instance;
|
89 |
}
|
90 |
}
|
91 |
-
|
92 |
-
|
93 |
-
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
|
22 |
+
class list_widget extends WP_Widget
|
23 |
+
{
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
parent::__construct(
|
27 |
+
// Base ID of your widget
|
28 |
+
'list_widget',
|
29 |
+
// Widget name will appear in UI
|
30 |
+
__('Mailgun List Widget', 'wpb_widget_domain'),
|
31 |
+
// Widget description
|
32 |
+
['description' => __('Mailgun list widget', 'wpb_widget_domain')]
|
33 |
+
);
|
34 |
+
}
|
35 |
|
36 |
+
// Creating widget front-end
|
37 |
+
// This is where the action happens
|
38 |
+
public function widget($args, $instance)
|
39 |
+
{
|
40 |
+
global $mailgun;
|
41 |
|
42 |
+
// vars
|
43 |
+
$list_address = apply_filters('list_address', $instance['list_address']);
|
44 |
|
45 |
+
if (isset($instance['collect_name'])) {
|
46 |
+
$args['collect_name'] = true;
|
47 |
+
}
|
48 |
|
49 |
+
if (isset($instance['list_title'])) {
|
50 |
+
$args['list_title'] = $instance['list_title'];
|
51 |
+
}
|
52 |
|
53 |
+
if (isset($instance['list_description'])) {
|
54 |
+
$args['list_description'] = $instance['list_description'];
|
55 |
+
}
|
56 |
|
57 |
+
$mailgun->list_form($list_address, $args, $instance);
|
58 |
}
|
59 |
|
60 |
+
// Widget Backend
|
61 |
+
public function form($instance)
|
62 |
+
{
|
63 |
+
global $mailgun;
|
64 |
+
|
65 |
+
if (isset($instance['list_address'])) {
|
66 |
+
$list_address = $instance['list_address'];
|
67 |
} else {
|
68 |
+
$list_address = __('New list_address', 'wpb_widget_domain');
|
69 |
}
|
70 |
|
71 |
+
if (isset($instance['collect_name']) && $instance['collect_name'] === 'on') {
|
72 |
$collect_name = 'checked';
|
73 |
} else {
|
74 |
+
$collect_name = '';
|
75 |
}
|
76 |
|
77 |
+
$list_title = isset($instance['list_title']) ? $instance['list_title'] : null;
|
78 |
+
$list_description = isset($instance['list_description']) ? $instance['list_description'] : null;
|
79 |
+
|
80 |
// Widget admin form
|
81 |
?>
|
82 |
<div class="mailgun-list-widget-back">
|
83 |
+
<p>
|
84 |
+
<label for="<?php echo $this->get_field_id('list_title'); ?>"><?php _e('Title (optional):'); ?></label>
|
85 |
+
<input class="widefat" id="<?php echo $this->get_field_id('list_title'); ?>" name="<?php echo $this->get_field_name('list_title'); ?>" type="text" value="<?php echo esc_attr($list_title); ?>" />
|
86 |
+
</p>
|
87 |
+
<p>
|
88 |
+
<label for="<?php echo $this->get_field_id('list_description'); ?>"><?php _e('Description (optional):'); ?></label>
|
89 |
+
<input class="widefat" id="<?php echo $this->get_field_id('list_description'); ?>" name="<?php echo $this->get_field_name('list_description'); ?>" type="text" value="<?php echo esc_attr($list_description); ?>" />
|
90 |
+
</p>
|
91 |
+
<p>
|
92 |
+
<label for="<?php echo $this->get_field_id('list_address'); ?>"><?php _e('List addresses (required):'); ?></label>
|
93 |
+
<input class="widefat" id="<?php echo $this->get_field_id('list_address'); ?>" name="<?php echo $this->get_field_name('list_address'); ?>" type="text" value="<?php echo esc_attr($list_address); ?>" />
|
94 |
+
</p>
|
95 |
+
<p>
|
96 |
+
<label for="<?php echo $this->get_field_id('collect_name'); ?>"><?php _e('Collect name:'); ?></label>
|
97 |
+
<input class="widefat" id="<?php echo $this->get_field_id('collect_name'); ?>" name="<?php echo $this->get_field_name('collect_name'); ?>" type="checkbox" <?php echo esc_attr($collect_name); ?> />
|
98 |
+
</p>
|
99 |
</div>
|
100 |
<?php
|
101 |
}
|
102 |
+
|
103 |
// Updating widget replacing old instances with new
|
104 |
+
public function update($new_instance, $old_instance)
|
105 |
+
{
|
106 |
+
$instance = [];
|
107 |
+
$instance = $new_instance;
|
108 |
|
109 |
return $instance;
|
110 |
}
|
111 |
}
|
|
|
|
|
|
includes/wp-mail.php
CHANGED
@@ -1,273 +1,372 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* wp_mail function to be loaded in to override the core wp_mail function
|
4 |
-
* from wp-includes/pluggable.php
|
5 |
*
|
6 |
* Based off of the core wp_mail function, but with modifications required to
|
7 |
* send email using the Mailgun HTTP API
|
8 |
*
|
9 |
-
* @param string|array $to
|
10 |
-
* @param string
|
11 |
-
* @param string
|
12 |
-
* @param string|array $headers
|
13 |
* @param string|array $attachments Optional. Files to attach.
|
|
|
14 |
* @return bool Whether the email contents were sent successfully.
|
|
|
15 |
* @since 0.1
|
16 |
*/
|
17 |
-
function wp_mail(
|
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 |
// this is the wordpress site tag
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
// campaign-id now refers to a list of tags which will be appended to the site tag
|
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 |
// overriding this function, let's add looping here to handle that
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
if ( ! isset( $response_body->message ) || $response_body->message != 'Queued. Thank you.' )
|
270 |
-
return false;
|
271 |
|
272 |
-
|
273 |
}
|
1 |
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* mg_api_last_error is a compound getter/setter for the last error that was
|
24 |
+
* encountered during a Mailgun API call.
|
25 |
+
*
|
26 |
+
* @param string $error OPTIONAL
|
27 |
+
*
|
28 |
+
* @return string Last error that occurred.
|
29 |
+
*
|
30 |
+
* @since 1.5
|
31 |
+
*/
|
32 |
+
function mg_api_last_error($error = null)
|
33 |
+
{
|
34 |
+
static $last_error;
|
35 |
+
|
36 |
+
if (null === $error) {
|
37 |
+
return $last_error;
|
38 |
+
} else {
|
39 |
+
$tmp = $last_error;
|
40 |
+
$last_error = $error;
|
41 |
+
|
42 |
+
return $tmp;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
/**
|
47 |
* wp_mail function to be loaded in to override the core wp_mail function
|
48 |
+
* from wp-includes/pluggable.php.
|
49 |
*
|
50 |
* Based off of the core wp_mail function, but with modifications required to
|
51 |
* send email using the Mailgun HTTP API
|
52 |
*
|
53 |
+
* @param string|array $to Array or comma-separated list of email addresses to send message.
|
54 |
+
* @param string $subject Email subject
|
55 |
+
* @param string $message Message contents
|
56 |
+
* @param string|array $headers Optional. Additional headers.
|
57 |
* @param string|array $attachments Optional. Files to attach.
|
58 |
+
*
|
59 |
* @return bool Whether the email contents were sent successfully.
|
60 |
+
*
|
61 |
* @since 0.1
|
62 |
*/
|
63 |
+
function wp_mail($to, $subject, $message, $headers = '', $attachments = [])
|
64 |
+
{
|
65 |
+
// Compact the input, apply the filters, and extract them back out
|
66 |
+
extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments')));
|
67 |
+
|
68 |
+
$mailgun = get_option('mailgun');
|
69 |
+
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $mailgun['apiKey'];
|
70 |
+
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $mailgun['domain'];
|
71 |
+
|
72 |
+
if (empty($apiKey) || empty($domain)) {
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
if (!is_array($attachments)) {
|
77 |
+
$attachments = explode("\n", str_replace("\r\n", "\n", $attachments));
|
78 |
+
}
|
79 |
+
|
80 |
+
// Headers
|
81 |
+
if (empty($headers)) {
|
82 |
+
$headers = [];
|
83 |
+
} else {
|
84 |
+
if (!is_array($headers)) {
|
85 |
+
// Explode the headers out, so this function can take both
|
86 |
+
// string headers and an array of headers.
|
87 |
+
$tempheaders = explode("\n", str_replace("\r\n", "\n", $headers));
|
88 |
+
} else {
|
89 |
+
$tempheaders = $headers;
|
90 |
+
}
|
91 |
+
$headers = [];
|
92 |
+
$cc = [];
|
93 |
+
$bcc = [];
|
94 |
+
|
95 |
+
// If it's actually got contents
|
96 |
+
if (!empty($tempheaders)) {
|
97 |
+
// Iterate through the raw headers
|
98 |
+
foreach ((array) $tempheaders as $header) {
|
99 |
+
if (strpos($header, ':') === false) {
|
100 |
+
if (false !== stripos($header, 'boundary=')) {
|
101 |
+
$parts = preg_split('/boundary=/i', trim($header));
|
102 |
+
$boundary = trim(str_replace(["'", '"'], '', $parts[1]));
|
103 |
+
}
|
104 |
+
continue;
|
105 |
+
}
|
106 |
+
// Explode them out
|
107 |
+
list($name, $content) = explode(':', trim($header), 2);
|
108 |
+
|
109 |
+
// Cleanup crew
|
110 |
+
$name = trim($name);
|
111 |
+
$content = trim($content);
|
112 |
+
|
113 |
+
switch (strtolower($name)) {
|
114 |
+
// Mainly for legacy -- process a From: header if it's there
|
115 |
+
case 'from':
|
116 |
+
if (strpos($content, '<') !== false) {
|
117 |
+
// So... making my life hard again?
|
118 |
+
$from_name = substr($content, 0, strpos($content, '<') - 1);
|
119 |
+
$from_name = str_replace('"', '', $from_name);
|
120 |
+
$from_name = trim($from_name);
|
121 |
+
|
122 |
+
$from_email = substr($content, strpos($content, '<') + 1);
|
123 |
+
$from_email = str_replace('>', '', $from_email);
|
124 |
+
$from_email = trim($from_email);
|
125 |
+
} else {
|
126 |
+
$from_email = trim($content);
|
127 |
+
}
|
128 |
+
break;
|
129 |
+
case 'content-type':
|
130 |
+
if (strpos($content, ';') !== false) {
|
131 |
+
list($type, $charset) = explode(';', $content);
|
132 |
+
$content_type = trim($type);
|
133 |
+
if (false !== stripos($charset, 'charset=')) {
|
134 |
+
$charset = trim(str_replace(['charset=', '"'], '', $charset));
|
135 |
+
} elseif (false !== stripos($charset, 'boundary=')) {
|
136 |
+
$boundary = trim(str_replace(['BOUNDARY=', 'boundary=', '"'], '', $charset));
|
137 |
+
$charset = '';
|
138 |
+
}
|
139 |
+
} else {
|
140 |
+
$content_type = trim($content);
|
141 |
+
}
|
142 |
+
break;
|
143 |
+
case 'cc':
|
144 |
+
$cc = array_merge((array) $cc, explode(',', $content));
|
145 |
+
break;
|
146 |
+
case 'bcc':
|
147 |
+
$bcc = array_merge((array) $bcc, explode(',', $content));
|
148 |
+
break;
|
149 |
+
default:
|
150 |
+
// Add it to our grand headers array
|
151 |
+
$headers[trim($name)] = trim($content);
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
// From email and name
|
159 |
+
// If we don't have a name from the input headers
|
160 |
+
if (!isset($from_name)) {
|
161 |
+
$from_name = 'WordPress';
|
162 |
+
}
|
163 |
+
|
164 |
+
/* If we don't have an email from the input headers default to wordpress@$sitename
|
165 |
+
* Some hosts will block outgoing mail from this address if it doesn't exist but
|
166 |
+
* there's no easy alternative. Defaulting to admin_email might appear to be another
|
167 |
+
* option but some hosts may refuse to relay mail from an unknown domain. See
|
168 |
+
* http://trac.wordpress.org/ticket/5007.
|
169 |
+
*/
|
170 |
+
|
171 |
+
if (!isset($from_email)) {
|
172 |
+
// Get the site domain and get rid of www.
|
173 |
+
$sitename = strtolower($_SERVER['SERVER_NAME']);
|
174 |
+
if (substr($sitename, 0, 4) == 'www.') {
|
175 |
+
$sitename = substr($sitename, 4);
|
176 |
+
}
|
177 |
+
|
178 |
+
$from_email = 'wordpress@'.$sitename;
|
179 |
+
}
|
180 |
+
|
181 |
+
// Plugin authors can override the potentially troublesome default
|
182 |
+
$from_email = apply_filters('wp_mail_from', $from_email);
|
183 |
+
$from_name = apply_filters('wp_mail_from_name', $from_name);
|
184 |
+
|
185 |
+
$body = [
|
186 |
+
'from' => "{$from_name} <{$from_email}>",
|
187 |
+
'to' => $to,
|
188 |
+
'subject' => $subject,
|
189 |
+
'text' => $message,
|
190 |
+
];
|
191 |
+
|
192 |
+
$body['o:tag'] = '';
|
193 |
+
$body['o:tracking-clicks'] = !empty($mailgun['track-clicks']) ? $mailgun['track-clicks'] : 'no';
|
194 |
+
$body['o:tracking-opens'] = empty($mailgun['track-opens']) ? 'no' : 'yes';
|
195 |
|
196 |
// this is the wordpress site tag
|
197 |
+
if (isset($mailgun['tag'])) {
|
198 |
+
$tags = explode(',', str_replace(' ', '', $mailgun['tag']));
|
199 |
+
$body['o:tag'] = $tags;
|
200 |
+
}
|
201 |
|
202 |
// campaign-id now refers to a list of tags which will be appended to the site tag
|
203 |
+
if (isset($mailgun['campaign-id'])) {
|
204 |
+
$tags = explode(',', str_replace(' ', '', $mailgun['campaign-id']));
|
205 |
+
if (empty($body['o:tag'])) {
|
206 |
+
$body['o:tag'] = $tags;
|
207 |
+
} elseif (is_array($body['o:tag'])) {
|
208 |
+
$body['o:tag'] = array_merge($body['o:tag'], $tags);
|
209 |
+
} else {
|
210 |
+
$body['o:tag'] .= ','.$tags;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
if (!empty($cc) && is_array($cc)) {
|
215 |
+
$body['cc'] = implode(', ', $cc);
|
216 |
+
}
|
217 |
+
|
218 |
+
if (!empty($bcc) && is_array($bcc)) {
|
219 |
+
$body['bcc'] = implode(', ', $bcc);
|
220 |
+
}
|
221 |
+
|
222 |
+
// If we are not given a Content-Type from the supplied headers, use
|
223 |
+
// text/html and *attempt* to strip tags and provide a text/plain
|
224 |
+
// version.
|
225 |
+
if (!isset($content_type)) {
|
226 |
+
// If there is no pre-provided Content-Type, *assume* that it is
|
227 |
+
// plain text and treat it as such. Pros: WP password reset will
|
228 |
+
// not break. Cons: if it is HTML, the mail will be raw HTML.
|
229 |
+
$content_type = 'text/html';
|
230 |
+
$body['text'] = $message;
|
231 |
+
// <br /> tags need a space in front of them because otherwise,
|
232 |
+
// URLs with a EOL directly following get missed by Mailgun's
|
233 |
+
// URL eater.
|
234 |
+
$body['html'] = str_replace(["\r\n", "\r", "\n"], ' <br />', $message);
|
235 |
+
} else {
|
236 |
+
// Depending on the given input content type, create the
|
237 |
+
// corresponding body output. Mails sent here will ALWAYS
|
238 |
+
// have both a text/plain part and text/html part with a
|
239 |
+
// final Content-Type of multipart.
|
240 |
+
if ($content_type === 'text/html') {
|
241 |
+
$body['html'] = $message;
|
242 |
+
// It won't be pretty, but just use the HTML message as the text
|
243 |
+
// part. No escape, no strip tags. In the case of WP's password
|
244 |
+
// reset, both of those would blow up the URL since it is wrapped
|
245 |
+
// in < >.
|
246 |
+
$body['text'] = $message;
|
247 |
+
} elseif ($content_type === 'text/plain') {
|
248 |
+
$content_type = 'text/html';
|
249 |
+
$body['text'] = $message;
|
250 |
+
// Add HTML line breaks for each newline.
|
251 |
+
$body['html'] = nl2br($message);
|
252 |
+
} else {
|
253 |
+
// Unknown Content-Type??
|
254 |
+
$body['text'] = $message;
|
255 |
+
$body['html'] = $message;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
// If we don't have a charset from the input headers
|
260 |
+
if (!isset($charset)) {
|
261 |
+
$charset = get_bloginfo('charset');
|
262 |
+
}
|
263 |
+
|
264 |
+
// Set the content-type and charset
|
265 |
+
$charset = apply_filters('wp_mail_charset', $charset);
|
266 |
+
if (isset($headers['Content-Type'])) {
|
267 |
+
if (!strstr($headers['Content-Type'], 'charset')) {
|
268 |
+
$headers['Content-Type'] = rtrim($headers['Content-Type'], '; ')."; charset={$charset}";
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
// Set custom headers
|
273 |
+
if (!empty($headers)) {
|
274 |
+
foreach ((array) $headers as $name => $content) {
|
275 |
+
$body["h:{$name}"] = $content;
|
276 |
+
}
|
277 |
+
|
278 |
+
// TODO: Can we handle this?
|
279 |
+
//if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
|
280 |
+
// $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
|
281 |
+
}
|
282 |
+
|
283 |
+
/*
|
284 |
+
* Deconstruct post array and create POST payload.
|
285 |
+
* This entire routine is because wp_remote_post does
|
286 |
+
* not support files directly.
|
287 |
+
*/
|
288 |
+
|
289 |
+
// First, generate a boundary for the multipart message.
|
290 |
+
$boundary = base_convert(uniqid('boundary', true), 10, 36);
|
291 |
+
|
292 |
+
$payload = null;
|
293 |
+
|
294 |
+
// Iterate through pre-built params and build payload:
|
295 |
+
foreach ($body as $key => $value) {
|
296 |
+
if (is_array($value)) {
|
297 |
+
$parent_key = $key;
|
298 |
+
foreach ($value as $key => $value) {
|
299 |
+
$payload .= '--'.$boundary;
|
300 |
+
$payload .= "\r\n";
|
301 |
+
$payload .= 'Content-Disposition: form-data; name="'.$parent_key."\"\r\n\r\n";
|
302 |
+
$payload .= $value;
|
303 |
+
$payload .= "\r\n";
|
304 |
+
}
|
305 |
+
} else {
|
306 |
+
$payload .= '--'.$boundary;
|
307 |
+
$payload .= "\r\n";
|
308 |
+
$payload .= 'Content-Disposition: form-data; name="'.$key.'"'."\r\n\r\n";
|
309 |
+
$payload .= $value;
|
310 |
+
$payload .= "\r\n";
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
// If we have attachments, add them to the payload.
|
315 |
+
if (!empty($attachments)) {
|
316 |
+
$i = 0;
|
317 |
+
foreach ($attachments as $attachment) {
|
318 |
+
if (!empty($attachment)) {
|
319 |
+
$payload .= '--'.$boundary;
|
320 |
+
$payload .= "\r\n";
|
321 |
+
$payload .= 'Content-Disposition: form-data; name="attachment['.$i.']"; filename="'.basename($attachment).'"'."\r\n\r\n";
|
322 |
+
$payload .= file_get_contents($attachment);
|
323 |
+
$payload .= "\r\n";
|
324 |
+
$i++;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
$payload .= '--'.$boundary.'--';
|
330 |
+
|
331 |
+
$data = [
|
332 |
+
'body' => $payload,
|
333 |
+
'headers' => ['Authorization' => 'Basic '.base64_encode("api:{$apiKey}"),
|
334 |
+
'Content-Type' => 'multipart/form-data; boundary='.$boundary, ],
|
335 |
+
];
|
336 |
+
|
337 |
+
$url = "https://api.mailgun.net/v3/{$domain}/messages";
|
338 |
+
|
339 |
+
// TODO: Mailgun only supports 1000 recipients per request, since we are
|
340 |
// overriding this function, let's add looping here to handle that
|
341 |
+
$response = wp_remote_post($url, $data);
|
342 |
+
if (is_wp_error($response)) {
|
343 |
+
// Store WP error in last error.
|
344 |
+
mg_api_last_error($response->get_error_message());
|
345 |
+
|
346 |
+
return false;
|
347 |
+
}
|
348 |
+
|
349 |
+
$response_code = wp_remote_retrieve_response_code($response);
|
350 |
+
$response_body = json_decode(wp_remote_retrieve_body($response));
|
351 |
+
|
352 |
+
// Mailgun API should *always* return a `message` field, even when
|
353 |
+
// $response_code != 200, so a lack of `message` indicates something
|
354 |
+
// is broken.
|
355 |
+
if ((int) $response_code != 200 && !isset($response_body->message)) {
|
356 |
+
// Store response code and HTTP response message in last error.
|
357 |
+
$response_message = wp_remote_retrieve_response_message($response);
|
358 |
+
$errmsg = "$response_code - $response_message";
|
359 |
+
mg_api_last_error($errmsg);
|
360 |
+
|
361 |
+
return false;
|
362 |
+
}
|
363 |
|
364 |
+
// Not sure there is any additional checking that needs to be done here, but why not?
|
365 |
+
if ($response_body->message != 'Queued. Thank you.') {
|
366 |
+
mg_api_last_error($response_body->message);
|
367 |
|
368 |
+
return false;
|
369 |
+
}
|
|
|
|
|
370 |
|
371 |
+
return true;
|
372 |
}
|
languages/mailgun-ca.mo
ADDED
Binary file
|
languages/mailgun-ca.po
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Mailgun\n"
|
4 |
+
"POT-Creation-Date: 2012-11-20 13:54-0600\n"
|
5 |
+
"PO-Revision-Date: 2016-07-24 15:45+0100\n"
|
6 |
+
"Language-Team: Mailgun <matt@sivel.net>\n"
|
7 |
+
"MIME-Version: 1.0\n"
|
8 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
+
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"X-Generator: Poedit 1.8.8\n"
|
11 |
+
"Last-Translator: \n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
+
"Language: es_ES\n"
|
14 |
+
|
15 |
+
#: mailgun.php:89
|
16 |
+
#, php-format
|
17 |
+
msgid ""
|
18 |
+
"Mailgun has been automatically deactivated because the file <strong>%s</"
|
19 |
+
"strong> is missing. Please reinstall the plugin and reactivate."
|
20 |
+
msgstr ""
|
21 |
+
"Mailgun ha estat desactivat automàticament perquè el fitxer <strong>%s</"
|
22 |
+
"strong> no s'ha trobat. Si us plau, reinstal·la el plugin i torna a activar-"
|
23 |
+
"lo."
|
24 |
+
|
25 |
+
#: includes/admin.php:60 includes/options-page.php:4
|
26 |
+
msgid "Mailgun"
|
27 |
+
msgstr "Mailgun"
|
28 |
+
|
29 |
+
#: includes/admin.php:105
|
30 |
+
msgid ""
|
31 |
+
"The Mailgun plugin configuration has changed since you last saved. Do you "
|
32 |
+
"wish to test anyway?\\n\\nClick \"Cancel\" and then \"Save Changes\" if you "
|
33 |
+
"wish to save your changes."
|
34 |
+
msgstr ""
|
35 |
+
"La configuració del plugin de Mailgun ha canviat des del darrer cop que ho "
|
36 |
+
"has desat. Vols provar la configuració de totes maneres? Selecciona "
|
37 |
+
"\"Cancel·lar\" i després a \"Desar els canvis\" si vols desar els teus "
|
38 |
+
"canvis."
|
39 |
+
|
40 |
+
#: includes/admin.php:110
|
41 |
+
msgid "Testing..."
|
42 |
+
msgstr "Provant..."
|
43 |
+
|
44 |
+
#: includes/admin.php:120 includes/options-page.php:75
|
45 |
+
msgid "Test Configuration"
|
46 |
+
msgstr "Provar la configuració"
|
47 |
+
|
48 |
+
#: includes/admin.php:126 includes/admin.php:288
|
49 |
+
msgid "Failure"
|
50 |
+
msgstr "Error"
|
51 |
+
|
52 |
+
#: includes/admin.php:146
|
53 |
+
#, php-format
|
54 |
+
msgid ""
|
55 |
+
"<div id=\"message\" class=\"updated fade\"><p>The options page for the "
|
56 |
+
"<strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</"
|
57 |
+
"strong> is missing. Please reinstall the plugin.</p></div>"
|
58 |
+
msgstr ""
|
59 |
+
"<div id=\"message\" class=\"updated fade\"><p>La pàgina de configuració del "
|
60 |
+
"plugin de <strong>Mailgun</strong> no pot ser mostrada. El fitxer <strong>"
|
61 |
+
"%s</strong> no existeix. Si us plau, reinstal·la el plugin.</p></div>"
|
62 |
+
|
63 |
+
#: includes/admin.php:223
|
64 |
+
msgid "Mailgun is almost ready. "
|
65 |
+
msgstr "Mailgun està gairebé llest."
|
66 |
+
|
67 |
+
#: includes/admin.php:223
|
68 |
+
#, php-format
|
69 |
+
msgid "You must <a href=\"%1$s\">configure Mailgun</a> for it to work."
|
70 |
+
msgstr "Has de <a href=\"%1$s\">configurar Mailgun</a> per fer-lo funcionar."
|
71 |
+
|
72 |
+
#: includes/admin.php:235
|
73 |
+
msgid "Settings"
|
74 |
+
msgstr "Ajustaments"
|
75 |
+
|
76 |
+
#: includes/admin.php:254
|
77 |
+
msgid "Unauthorized"
|
78 |
+
msgstr "No autoritzat"
|
79 |
+
|
80 |
+
#: includes/admin.php:264
|
81 |
+
msgid "HTTP API"
|
82 |
+
msgstr "API HTTP"
|
83 |
+
|
84 |
+
#: includes/admin.php:266
|
85 |
+
msgid "Secure SMTP"
|
86 |
+
msgstr "SMTP Segur"
|
87 |
+
|
88 |
+
#: includes/admin.php:266
|
89 |
+
msgid "SMTP"
|
90 |
+
msgstr "SMTP"
|
91 |
+
|
92 |
+
#: includes/admin.php:271
|
93 |
+
msgid "Mailgun WordPress Plugin Test"
|
94 |
+
msgstr "Prova del plugin de Mailgun per al WordPress."
|
95 |
+
|
96 |
+
#: includes/admin.php:272
|
97 |
+
#, php-format
|
98 |
+
msgid ""
|
99 |
+
"This is a test email generated by the Mailgun WordPress plugin.\n"
|
100 |
+
"\n"
|
101 |
+
"If you have received this message, the requested test has succeeded.\n"
|
102 |
+
"\n"
|
103 |
+
"The method used to send this email was: %s."
|
104 |
+
msgstr ""
|
105 |
+
"Aquest és un correu electrònic de prova generat pel plugin de Mailgun per al "
|
106 |
+
"WordPress.\n"
|
107 |
+
"\n"
|
108 |
+
"Si has rebut aquest missatge, significa que el plugin està correctament "
|
109 |
+
"configurat, i que ha estat possible establir connexió amb els sistemes de "
|
110 |
+
"Mailgun.\n"
|
111 |
+
"\n"
|
112 |
+
"El mètode utilitzat per enviar aquest missatge ha estat: %s."
|
113 |
+
|
114 |
+
#: includes/admin.php:279
|
115 |
+
msgid "Success"
|
116 |
+
msgstr "Èxit"
|
117 |
+
|
118 |
+
#: includes/options-page.php:9
|
119 |
+
msgid "Configuration"
|
120 |
+
msgstr "Configuració"
|
121 |
+
|
122 |
+
#: includes/options-page.php:13
|
123 |
+
msgid "Use HTTP API"
|
124 |
+
msgstr "Fer servir API HTTP"
|
125 |
+
|
126 |
+
#: includes/options-page.php:17 includes/options-page.php:65
|
127 |
+
msgid "Yes"
|
128 |
+
msgstr "Si"
|
129 |
+
|
130 |
+
#: includes/options-page.php:18 includes/options-page.php:66
|
131 |
+
msgid "No"
|
132 |
+
msgstr "No"
|
133 |
+
|
134 |
+
#: includes/options-page.php:20
|
135 |
+
msgid ""
|
136 |
+
"Set this to \"No\" if your server cannot make outbound HTTP connections or "
|
137 |
+
"if emails are not being delivered. \"No\" will cause this plugin to use "
|
138 |
+
"SMTP. Default \"Yes\"."
|
139 |
+
msgstr ""
|
140 |
+
"Selecciona \"No\" si el teu servidor no pot establir comunicacions HTTP cap "
|
141 |
+
"a servidors externs, o si els correus electrònics no es poden enviar. "
|
142 |
+
"Seleccionar \"No\" significa que el Plugin utilitzarà el server SMTP. Per "
|
143 |
+
"defecte \"Si\"."
|
144 |
+
|
145 |
+
#: includes/options-page.php:25
|
146 |
+
msgid "Mailgun Domain Name"
|
147 |
+
msgstr "Nom de domini de Mailgun"
|
148 |
+
|
149 |
+
#: includes/options-page.php:29
|
150 |
+
msgid "Your Mailgun Domain Name."
|
151 |
+
msgstr "El teu nom de domini de Mailgun"
|
152 |
+
|
153 |
+
#: includes/options-page.php:34
|
154 |
+
msgid "API Key"
|
155 |
+
msgstr "Clau de la API"
|
156 |
+
|
157 |
+
#: includes/options-page.php:38
|
158 |
+
msgid ""
|
159 |
+
"Your Mailgun API key, that starts with and includes \"key-\". Only valid for "
|
160 |
+
"use with the API."
|
161 |
+
msgstr ""
|
162 |
+
"La teva clau de la API, que comença (i que conté) \"key-\". Aquesta clau és "
|
163 |
+
"valida només per a connexions amb la API."
|
164 |
+
|
165 |
+
#: includes/options-page.php:43
|
166 |
+
msgid "Username"
|
167 |
+
msgstr "Nom d'usuari"
|
168 |
+
|
169 |
+
#: includes/options-page.php:47
|
170 |
+
msgid "Your Mailgun SMTP username. Only valid for use with SMTP."
|
171 |
+
msgstr "El teu nom d'usuari de Mailgun. Únicament vàlid per a connexions SMTP."
|
172 |
+
|
173 |
+
#: includes/options-page.php:52
|
174 |
+
msgid "Password"
|
175 |
+
msgstr "Contrasenya"
|
176 |
+
|
177 |
+
#: includes/options-page.php:56
|
178 |
+
msgid ""
|
179 |
+
"Your Mailgun SMTP password that goes with the above username. Only valid for "
|
180 |
+
"use with SMTP."
|
181 |
+
msgstr ""
|
182 |
+
"La teva contrasenya de SMTP de Mailgun per al nom d'usuari de dalt. "
|
183 |
+
"Únicament vàlid per connexions SMTP."
|
184 |
+
|
185 |
+
#: includes/options-page.php:61
|
186 |
+
msgid "Use Secure SMTP"
|
187 |
+
msgstr "Utilitzar SMTP segur"
|
188 |
+
|
189 |
+
#: includes/options-page.php:68
|
190 |
+
msgid ""
|
191 |
+
"Set this to \"No\" if your server cannot establish SSL SMTP connections or "
|
192 |
+
"if emails are not being delivered. If you set this to \"No\" your password "
|
193 |
+
"will be sent in plain text. Only valid for use with SMTP. Default \"Yes\"."
|
194 |
+
msgstr ""
|
195 |
+
"Selecciona \"No\" si el teu servidor no pot establir connexions SMTP "
|
196 |
+
"segures, o si els correus electrònics no són enviats o lliurats. Si "
|
197 |
+
"estableixes \"No\" la teva contrasenya serà enviada en text pla. Aquesta "
|
198 |
+
"opció és vàlida només per a connexions SMTP. Per defecte \"Sí\"."
|
199 |
+
|
200 |
+
#: includes/options-page.php:72
|
201 |
+
msgid ""
|
202 |
+
"Before attempting to test the configuration, please click \"Save Changes\"."
|
203 |
+
msgstr ""
|
204 |
+
"Abans de provar la teva configuració, si us plau, desa els canvis prement "
|
205 |
+
"\"Desar els canvis\"."
|
206 |
+
|
207 |
+
#: includes/options-page.php:74
|
208 |
+
msgid "Save Changes"
|
209 |
+
msgstr "Desar els canvis"
|
languages/mailgun-de_DE.mo
ADDED
Binary file
|
languages/mailgun-de_DE.po
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Mailgun\n"
|
4 |
+
"POT-Creation-Date: 2012-11-20 13:54-0600\n"
|
5 |
+
"PO-Revision-Date: 2015-10-28 13:26+0100\n"
|
6 |
+
"Language-Team: Mailgun <matt@sivel.net>\n"
|
7 |
+
"MIME-Version: 1.0\n"
|
8 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
+
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"X-Generator: Poedit 1.8.6\n"
|
11 |
+
"Last-Translator: \n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
+
"Language: de_DE\n"
|
14 |
+
|
15 |
+
#: mailgun.php:89
|
16 |
+
#, php-format
|
17 |
+
msgid ""
|
18 |
+
"Mailgun has been automatically deactivated because the file <strong>%s</"
|
19 |
+
"strong> is missing. Please reinstall the plugin and reactivate."
|
20 |
+
msgstr ""
|
21 |
+
"Mailgun wurde automatisch deaktiviert, da die Datei <strong>%s</strong> "
|
22 |
+
"fehlt. Bitte installieren Sie das Plugin nochmals und aktivieren Sie es "
|
23 |
+
"wieder."
|
24 |
+
|
25 |
+
#: includes/admin.php:60 includes/options-page.php:4
|
26 |
+
msgid "Mailgun"
|
27 |
+
msgstr "Mailgun"
|
28 |
+
|
29 |
+
#: includes/admin.php:105
|
30 |
+
msgid ""
|
31 |
+
"The Mailgun plugin configuration has changed since you last saved. Do you "
|
32 |
+
"wish to test anyway?\\n\\nClick \"Cancel\" and then \"Save Changes\" if you "
|
33 |
+
"wish to save your changes."
|
34 |
+
msgstr ""
|
35 |
+
"Die Mailgun-Plugin-Konfiguration wurde seit dem letzten Speichern verändert. "
|
36 |
+
"Möchten Sie den Test dennoch starten?\\n\\nKlicken Sie \"Abbrechen\" und "
|
37 |
+
"dann \"Änderungen speichern\", falls Sie Ihre Änderungen speichern möchten."
|
38 |
+
|
39 |
+
#: includes/admin.php:110
|
40 |
+
msgid "Testing..."
|
41 |
+
msgstr "Teste..."
|
42 |
+
|
43 |
+
#: includes/admin.php:120 includes/options-page.php:75
|
44 |
+
msgid "Test Configuration"
|
45 |
+
msgstr "Konfiguration Testen"
|
46 |
+
|
47 |
+
#: includes/admin.php:126 includes/admin.php:288
|
48 |
+
msgid "Failure"
|
49 |
+
msgstr "Fehler"
|
50 |
+
|
51 |
+
#: includes/admin.php:146
|
52 |
+
#, php-format
|
53 |
+
msgid ""
|
54 |
+
"<div id=\"message\" class=\"updated fade\"><p>The options page for the "
|
55 |
+
"<strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</"
|
56 |
+
"strong> is missing. Please reinstall the plugin.</p></div>"
|
57 |
+
msgstr ""
|
58 |
+
"<div id=\"message\" class=\"updated fade\"><p>Die Options-Seite für das "
|
59 |
+
"<strong>Mailgun</strong>-Plugin kann nicht angezeigt werden. Die Datei "
|
60 |
+
"<strong>%s</strong> fehlt. Bitte installieren Sie das Plugin erneut.</p></"
|
61 |
+
"div>"
|
62 |
+
|
63 |
+
#: includes/admin.php:223
|
64 |
+
msgid "Mailgun is almost ready. "
|
65 |
+
msgstr "Mailgun ist fast bereit. "
|
66 |
+
|
67 |
+
#: includes/admin.php:223
|
68 |
+
#, php-format
|
69 |
+
msgid "You must <a href=\"%1$s\">configure Mailgun</a> for it to work."
|
70 |
+
msgstr ""
|
71 |
+
"Sie müssen <a href=\"%1$s\">Mailgun konfigurieren</a>, damit es funktioniert."
|
72 |
+
|
73 |
+
#: includes/admin.php:235
|
74 |
+
msgid "Settings"
|
75 |
+
msgstr "Einstellungen"
|
76 |
+
|
77 |
+
#: includes/admin.php:254
|
78 |
+
msgid "Unauthorized"
|
79 |
+
msgstr "Nicht autorisiert"
|
80 |
+
|
81 |
+
#: includes/admin.php:264
|
82 |
+
msgid "HTTP API"
|
83 |
+
msgstr "HTTP API"
|
84 |
+
|
85 |
+
#: includes/admin.php:266
|
86 |
+
msgid "Secure SMTP"
|
87 |
+
msgstr "Sicheres SMTP"
|
88 |
+
|
89 |
+
#: includes/admin.php:266
|
90 |
+
msgid "SMTP"
|
91 |
+
msgstr "SMTP"
|
92 |
+
|
93 |
+
#: includes/admin.php:271
|
94 |
+
msgid "Mailgun WordPress Plugin Test"
|
95 |
+
msgstr "Mailgun WordPress Plugin Test"
|
96 |
+
|
97 |
+
#: includes/admin.php:272
|
98 |
+
#, php-format
|
99 |
+
msgid ""
|
100 |
+
"This is a test email generated by the Mailgun WordPress plugin.\n"
|
101 |
+
"\n"
|
102 |
+
"If you have received this message, the requested test has succeeded.\n"
|
103 |
+
"\n"
|
104 |
+
"The method used to send this email was: %s."
|
105 |
+
msgstr ""
|
106 |
+
"Die ist eine Test-Email, die vom Mailgun WordPress Plugin erzeugt wurde.\n"
|
107 |
+
"\n"
|
108 |
+
"Sollten Sie diese Nachricht erhalten haben, war der angefragte Test "
|
109 |
+
"erfolgreich.\n"
|
110 |
+
"\n"
|
111 |
+
"Zum Senden dieser Email wurde folgende Methode verwendet: %s."
|
112 |
+
|
113 |
+
#: includes/admin.php:279
|
114 |
+
msgid "Success"
|
115 |
+
msgstr "Erfolg"
|
116 |
+
|
117 |
+
#: includes/options-page.php:9
|
118 |
+
msgid "Configuration"
|
119 |
+
msgstr "Konfiguration"
|
120 |
+
|
121 |
+
#: includes/options-page.php:13
|
122 |
+
msgid "Use HTTP API"
|
123 |
+
msgstr "HTTP API verwenden"
|
124 |
+
|
125 |
+
#: includes/options-page.php:17 includes/options-page.php:65
|
126 |
+
msgid "Yes"
|
127 |
+
msgstr "Ja"
|
128 |
+
|
129 |
+
#: includes/options-page.php:18 includes/options-page.php:66
|
130 |
+
msgid "No"
|
131 |
+
msgstr "Nein"
|
132 |
+
|
133 |
+
#: includes/options-page.php:20
|
134 |
+
msgid ""
|
135 |
+
"Set this to \"No\" if your server cannot make outbound HTTP connections or "
|
136 |
+
"if emails are not being delivered. \"No\" will cause this plugin to use "
|
137 |
+
"SMTP. Default \"Yes\"."
|
138 |
+
msgstr ""
|
139 |
+
"Stellen Sie dies auf \"Nein\", falls Ihr Server keine abgehenden HTTP-"
|
140 |
+
"Verbindungen aufbauen kann oder falls Emails nicht zugestellt werden. Das "
|
141 |
+
"Plugin verwendet dann SMTP. Voreinstellung \"Ja\"."
|
142 |
+
|
143 |
+
#: includes/options-page.php:25
|
144 |
+
msgid "Mailgun Domain Name"
|
145 |
+
msgstr "Mailgun Domänenname"
|
146 |
+
|
147 |
+
#: includes/options-page.php:29
|
148 |
+
msgid "Your Mailgun Domain Name."
|
149 |
+
msgstr "Ihr Mailgun Domänenname"
|
150 |
+
|
151 |
+
#: includes/options-page.php:34
|
152 |
+
msgid "API Key"
|
153 |
+
msgstr "API-Schlüssel"
|
154 |
+
|
155 |
+
#: includes/options-page.php:38
|
156 |
+
msgid ""
|
157 |
+
"Your Mailgun API key, that starts with and includes \"key-\". Only valid for "
|
158 |
+
"use with the API."
|
159 |
+
msgstr ""
|
160 |
+
"Ihr Mailgun API-Schlüssel, enthält und fängt mit \"key-\" an. Nur gültig zur "
|
161 |
+
"Verwendung mit der API."
|
162 |
+
|
163 |
+
#: includes/options-page.php:43
|
164 |
+
msgid "Username"
|
165 |
+
msgstr "Benutzername"
|
166 |
+
|
167 |
+
#: includes/options-page.php:47
|
168 |
+
msgid "Your Mailgun SMTP username. Only valid for use with SMTP."
|
169 |
+
msgstr "Ihr Mailgun SMTP Benutzername. Nur gültig zur Verwendung mit SMTP."
|
170 |
+
|
171 |
+
#: includes/options-page.php:52
|
172 |
+
msgid "Password"
|
173 |
+
msgstr "Passwort"
|
174 |
+
|
175 |
+
#: includes/options-page.php:56
|
176 |
+
msgid ""
|
177 |
+
"Your Mailgun SMTP password that goes with the above username. Only valid for "
|
178 |
+
"use with SMTP."
|
179 |
+
msgstr ""
|
180 |
+
"Ihr Mailgun SMTP Passwort, das zum o.g. Benutzernamen gehört. Nur gültig zur "
|
181 |
+
"Verwendung mit SMTP."
|
182 |
+
|
183 |
+
#: includes/options-page.php:61
|
184 |
+
msgid "Use Secure SMTP"
|
185 |
+
msgstr "Sicheres SMTP verwenden"
|
186 |
+
|
187 |
+
#: includes/options-page.php:68
|
188 |
+
msgid ""
|
189 |
+
"Set this to \"No\" if your server cannot establish SSL SMTP connections or "
|
190 |
+
"if emails are not being delivered. If you set this to \"No\" your password "
|
191 |
+
"will be sent in plain text. Only valid for use with SMTP. Default \"Yes\"."
|
192 |
+
msgstr ""
|
193 |
+
"Stellen Sie dies auf \"Nein\", falls Ihr Server keine SSL SMTP-Verbindungen "
|
194 |
+
"aufbauen kann oder falls Emails nicht zugestellt werden. Bei \"Nein\" werden "
|
195 |
+
"Passwörter im Klartext versendet. Nur gültig für SMTP. Voreinstellung \"Ja\"."
|
196 |
+
|
197 |
+
#: includes/options-page.php:72
|
198 |
+
msgid ""
|
199 |
+
"Before attempting to test the configuration, please click \"Save Changes\"."
|
200 |
+
msgstr ""
|
201 |
+
"Bevor Sie versuchen, die Konfiguration zu testen, klicken Sie bitte "
|
202 |
+
"\"Änderungen speichern\"."
|
203 |
+
|
204 |
+
#: includes/options-page.php:74
|
205 |
+
msgid "Save Changes"
|
206 |
+
msgstr "Änderungen speichern"
|
languages/mailgun-es_ES.mo
ADDED
Binary file
|
languages/mailgun-es_ES.po
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Mailgun\n"
|
4 |
+
"POT-Creation-Date: 2012-11-20 13:54-0600\n"
|
5 |
+
"PO-Revision-Date: 2016-07-24 15:26+0100\n"
|
6 |
+
"Language-Team: Mailgun <matt@sivel.net>\n"
|
7 |
+
"MIME-Version: 1.0\n"
|
8 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
+
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"X-Generator: Poedit 1.8.8\n"
|
11 |
+
"Last-Translator: \n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
13 |
+
"Language: es_ES\n"
|
14 |
+
|
15 |
+
#: mailgun.php:89
|
16 |
+
#, php-format
|
17 |
+
msgid ""
|
18 |
+
"Mailgun has been automatically deactivated because the file <strong>%s</"
|
19 |
+
"strong> is missing. Please reinstall the plugin and reactivate."
|
20 |
+
msgstr ""
|
21 |
+
"Mailgun ha sido desactivado automáticamente porque el archivo <strong>%s</"
|
22 |
+
"strong> no se ha encontrado. Por favor, reinstala el plugin y reactívalo de "
|
23 |
+
"nuevo."
|
24 |
+
|
25 |
+
#: includes/admin.php:60 includes/options-page.php:4
|
26 |
+
msgid "Mailgun"
|
27 |
+
msgstr "Mailgun"
|
28 |
+
|
29 |
+
#: includes/admin.php:105
|
30 |
+
msgid ""
|
31 |
+
"The Mailgun plugin configuration has changed since you last saved. Do you "
|
32 |
+
"wish to test anyway?\\n\\nClick \"Cancel\" and then \"Save Changes\" if you "
|
33 |
+
"wish to save your changes."
|
34 |
+
msgstr ""
|
35 |
+
"La configuración del plugin de Mailgun ha cambiado desde la última vez que "
|
36 |
+
"lo guardaste. Quieres probar la configuración de todos modos?\\n"
|
37 |
+
"\\nSeleccciona \"Cancelar\" y luego \"Guardar cambios\" si quieres guardar "
|
38 |
+
"tus cambios."
|
39 |
+
|
40 |
+
#: includes/admin.php:110
|
41 |
+
msgid "Testing..."
|
42 |
+
msgstr "Probando…"
|
43 |
+
|
44 |
+
#: includes/admin.php:120 includes/options-page.php:75
|
45 |
+
msgid "Test Configuration"
|
46 |
+
msgstr "Probar configuración"
|
47 |
+
|
48 |
+
#: includes/admin.php:126 includes/admin.php:288
|
49 |
+
msgid "Failure"
|
50 |
+
msgstr "Fallo"
|
51 |
+
|
52 |
+
#: includes/admin.php:146
|
53 |
+
#, php-format
|
54 |
+
msgid ""
|
55 |
+
"<div id=\"message\" class=\"updated fade\"><p>The options page for the "
|
56 |
+
"<strong>Mailgun</strong> plugin cannot be displayed. The file <strong>%s</"
|
57 |
+
"strong> is missing. Please reinstall the plugin.</p></div>"
|
58 |
+
msgstr ""
|
59 |
+
"<div id=\"message\" class=\"updated fade\"><p>La página de configuración del "
|
60 |
+
"plugin de <strong>Mailgun</strong> no puede ser mostrada. El archivo <strong>"
|
61 |
+
"%s</strong> no existe. Por favor, reinstala el plugin.</p></div>"
|
62 |
+
|
63 |
+
#: includes/admin.php:223
|
64 |
+
msgid "Mailgun is almost ready. "
|
65 |
+
msgstr "Mailgun está casi listo."
|
66 |
+
|
67 |
+
#: includes/admin.php:223
|
68 |
+
#, php-format
|
69 |
+
msgid "You must <a href=\"%1$s\">configure Mailgun</a> for it to work."
|
70 |
+
msgstr "Debes <a href=\"%1$s\">configurar Mailgun</a> para hacerlo funcionar."
|
71 |
+
|
72 |
+
#: includes/admin.php:235
|
73 |
+
msgid "Settings"
|
74 |
+
msgstr "Ajustes"
|
75 |
+
|
76 |
+
#: includes/admin.php:254
|
77 |
+
msgid "Unauthorized"
|
78 |
+
msgstr "No autorizado"
|
79 |
+
|
80 |
+
#: includes/admin.php:264
|
81 |
+
msgid "HTTP API"
|
82 |
+
msgstr "API HTTP"
|
83 |
+
|
84 |
+
#: includes/admin.php:266
|
85 |
+
msgid "Secure SMTP"
|
86 |
+
msgstr "SMTP Seguro"
|
87 |
+
|
88 |
+
#: includes/admin.php:266
|
89 |
+
msgid "SMTP"
|
90 |
+
msgstr "SMTP"
|
91 |
+
|
92 |
+
#: includes/admin.php:271
|
93 |
+
msgid "Mailgun WordPress Plugin Test"
|
94 |
+
msgstr "Prueba del plugin de Mailgun para WordPress"
|
95 |
+
|
96 |
+
#: includes/admin.php:272
|
97 |
+
#, php-format
|
98 |
+
msgid ""
|
99 |
+
"This is a test email generated by the Mailgun WordPress plugin.\n"
|
100 |
+
"\n"
|
101 |
+
"If you have received this message, the requested test has succeeded.\n"
|
102 |
+
"\n"
|
103 |
+
"The method used to send this email was: %s."
|
104 |
+
msgstr ""
|
105 |
+
"Este es un correo electrónido de prueba generado por el plugin de Mailgun "
|
106 |
+
"para WordPress.\n"
|
107 |
+
"\n"
|
108 |
+
"Si has recibido este mensaje significa que el plugin está correctamente "
|
109 |
+
"configurado, y que se ha establecido conexión con los sistemas de Mailgun.\n"
|
110 |
+
"\n"
|
111 |
+
"El método usado para enviar este email ha sido: %s."
|
112 |
+
|
113 |
+
#: includes/admin.php:279
|
114 |
+
msgid "Success"
|
115 |
+
msgstr "Éxito"
|
116 |
+
|
117 |
+
#: includes/options-page.php:9
|
118 |
+
msgid "Configuration"
|
119 |
+
msgstr "Configuración"
|
120 |
+
|
121 |
+
#: includes/options-page.php:13
|
122 |
+
msgid "Use HTTP API"
|
123 |
+
msgstr "Usar API HTTP"
|
124 |
+
|
125 |
+
#: includes/options-page.php:17 includes/options-page.php:65
|
126 |
+
msgid "Yes"
|
127 |
+
msgstr "Si"
|
128 |
+
|
129 |
+
#: includes/options-page.php:18 includes/options-page.php:66
|
130 |
+
msgid "No"
|
131 |
+
msgstr "No"
|
132 |
+
|
133 |
+
#: includes/options-page.php:20
|
134 |
+
msgid ""
|
135 |
+
"Set this to \"No\" if your server cannot make outbound HTTP connections or "
|
136 |
+
"if emails are not being delivered. \"No\" will cause this plugin to use "
|
137 |
+
"SMTP. Default \"Yes\"."
|
138 |
+
msgstr ""
|
139 |
+
"Selecciona \"No\" si tu servidor no puede establecer conexiones HTTP hacia "
|
140 |
+
"servicios externos, o si los emails no son enviados. Seleccionar \"No\" "
|
141 |
+
"implica que el Plugin usará el servicio SMTP. Por defecto \"Si\"."
|
142 |
+
|
143 |
+
#: includes/options-page.php:25
|
144 |
+
msgid "Mailgun Domain Name"
|
145 |
+
msgstr "Nombre de dominio de Mailgun"
|
146 |
+
|
147 |
+
#: includes/options-page.php:29
|
148 |
+
msgid "Your Mailgun Domain Name."
|
149 |
+
msgstr "Tu nombre de dominio de Mailgun"
|
150 |
+
|
151 |
+
#: includes/options-page.php:34
|
152 |
+
msgid "API Key"
|
153 |
+
msgstr "Clave de la API"
|
154 |
+
|
155 |
+
#: includes/options-page.php:38
|
156 |
+
msgid ""
|
157 |
+
"Your Mailgun API key, that starts with and includes \"key-\". Only valid for "
|
158 |
+
"use with the API."
|
159 |
+
msgstr ""
|
160 |
+
"Tu clave de la API, que empieza con (e incluye) \"key-\". Válida solamente "
|
161 |
+
"para ser usada con la API."
|
162 |
+
|
163 |
+
#: includes/options-page.php:43
|
164 |
+
msgid "Username"
|
165 |
+
msgstr "Nombre de usuario"
|
166 |
+
|
167 |
+
#: includes/options-page.php:47
|
168 |
+
msgid "Your Mailgun SMTP username. Only valid for use with SMTP."
|
169 |
+
msgstr ""
|
170 |
+
"Tu nombre de usuario de Mailgun. Solamente válido para conexiones SMTP."
|
171 |
+
|
172 |
+
#: includes/options-page.php:52
|
173 |
+
msgid "Password"
|
174 |
+
msgstr "Contraseña"
|
175 |
+
|
176 |
+
#: includes/options-page.php:56
|
177 |
+
msgid ""
|
178 |
+
"Your Mailgun SMTP password that goes with the above username. Only valid for "
|
179 |
+
"use with SMTP."
|
180 |
+
msgstr ""
|
181 |
+
"Tu contraseña de SMTP de Mailgun para el nombre de usuario de arriba. "
|
182 |
+
"Solamente válido para conexiones SMTP."
|
183 |
+
|
184 |
+
#: includes/options-page.php:61
|
185 |
+
msgid "Use Secure SMTP"
|
186 |
+
msgstr "Usar SMTP seguro"
|
187 |
+
|
188 |
+
#: includes/options-page.php:68
|
189 |
+
msgid ""
|
190 |
+
"Set this to \"No\" if your server cannot establish SSL SMTP connections or "
|
191 |
+
"if emails are not being delivered. If you set this to \"No\" your password "
|
192 |
+
"will be sent in plain text. Only valid for use with SMTP. Default \"Yes\"."
|
193 |
+
msgstr ""
|
194 |
+
"Establece \"No\" si tu servidor no puede establecer conexiones SMTP Seguras, "
|
195 |
+
"o si los emails no son enviados/entregados. Si estableces \"No\" tu "
|
196 |
+
"contraseña será enviada en texto plano. Esta opción es válida solamente para "
|
197 |
+
"conexiones SMTP. Por defecto \"Si\"."
|
198 |
+
|
199 |
+
#: includes/options-page.php:72
|
200 |
+
msgid ""
|
201 |
+
"Before attempting to test the configuration, please click \"Save Changes\"."
|
202 |
+
msgstr ""
|
203 |
+
"Antes de probar la configuración, por favor, presiona en \"Guardar cambios\"."
|
204 |
+
|
205 |
+
#: includes/options-page.php:74
|
206 |
+
msgid "Save Changes"
|
207 |
+
msgstr "Guardar cambios"
|
mailgun.php
CHANGED
@@ -1,404 +1,432 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Plugin Name: Mailgun
|
4 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
5 |
* Description: Mailgun integration for WordPress
|
6 |
-
* Version: 1.
|
7 |
* Author: Mailgun
|
8 |
* Author URI: http://www.mailgun.com/
|
9 |
* License: GPLv2 or later
|
10 |
* Text Domain: mailgun
|
11 |
-
* Domain Path: /languages
|
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 |
$mailgun = new Mailgun();
|
387 |
|
388 |
-
if (
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
}
|
393 |
|
394 |
-
if (
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
}
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
1 |
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* mailgun-wordpress-plugin - Sending mail from Wordpress using Mailgun
|
5 |
+
* Copyright (C) 2016 Mailgun, et al.
|
6 |
+
*
|
7 |
+
* This program is free software; you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License along
|
18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
20 |
+
*/
|
21 |
+
|
22 |
/**
|
23 |
* Plugin Name: Mailgun
|
24 |
* Plugin URI: http://wordpress.org/extend/plugins/mailgun/
|
25 |
* Description: Mailgun integration for WordPress
|
26 |
+
* Version: 1.5.0
|
27 |
* Author: Mailgun
|
28 |
* Author URI: http://www.mailgun.com/
|
29 |
* License: GPLv2 or later
|
30 |
* Text Domain: mailgun
|
31 |
+
* Domain Path: /languages/.
|
32 |
*/
|
33 |
+
class Mailgun
|
34 |
+
{
|
35 |
+
/**
|
36 |
+
* Setup shared functionality for Admin and Front End.
|
37 |
+
*
|
38 |
+
* @return none
|
39 |
+
*
|
40 |
+
* @since 0.1
|
41 |
+
*/
|
42 |
+
public function __construct()
|
43 |
+
{
|
44 |
+
$this->options = get_option('mailgun');
|
45 |
+
$this->plugin_file = __FILE__;
|
46 |
+
$this->plugin_basename = plugin_basename($this->plugin_file);
|
47 |
+
$this->api_endpoint = 'https://api.mailgun.net/v3/';
|
48 |
+
|
49 |
+
// Either override the wp_mail function or configure PHPMailer to use the
|
50 |
+
// Mailgun SMTP servers
|
51 |
+
if ($this->get_option('useAPI') || (defined('MAILGUN_USEAPI') && MAILGUN_USEAPI)) {
|
52 |
+
if (!function_exists('wp_mail')) {
|
53 |
+
if (!@include dirname(__FILE__).'/includes/wp-mail.php') {
|
54 |
+
self::deactivate_and_die(dirname(__FILE__).'/includes/wp-mail.php');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
} else {
|
58 |
+
add_action('phpmailer_init', [&$this, 'phpmailer_init']);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get specific option from the options table.
|
64 |
+
*
|
65 |
+
* @param string $option Name of option to be used as array key for retrieving the specific value
|
66 |
+
*
|
67 |
+
* @return mixed
|
68 |
+
*
|
69 |
+
* @since 0.1
|
70 |
+
*/
|
71 |
+
public function get_option($option, $options = null)
|
72 |
+
{
|
73 |
+
if (is_null($options)) {
|
74 |
+
$options = &$this->options;
|
75 |
+
}
|
76 |
+
if (isset($options[$option])) {
|
77 |
+
return $options[$option];
|
78 |
+
} else {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Hook into phpmailer to override SMTP based configurations
|
85 |
+
* to use the Mailgun SMTP server.
|
86 |
+
*
|
87 |
+
* @param object $phpmailer The PHPMailer object to modify by reference
|
88 |
+
*
|
89 |
+
* @return none
|
90 |
+
*
|
91 |
+
* @since 0.1
|
92 |
+
*/
|
93 |
+
public function phpmailer_init(&$phpmailer)
|
94 |
+
{
|
95 |
+
$username = (defined('MAILGUN_USERNAME') && MAILGUN_USERNAME) ? MAILGUN_USERNAME : $this->get_option('username');
|
96 |
+
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $this->get_option('domain');
|
97 |
+
$username = preg_replace('/@.+$/', '', $username)."@{$domain}";
|
98 |
+
$secure = (defined('MAILGUN_SECURE') && MAILGUN_SECURE) ? MAILGUN_SECURE : $this->get_option('secure');
|
99 |
+
$password = (defined('MAILGUN_PASSWORD') && MAILGUN_PASSWORD) ? MAILGUN_PASSWORD : $this->get_option('password');
|
100 |
+
|
101 |
+
$phpmailer->Mailer = 'smtp';
|
102 |
+
$phpmailer->SMTPSecure = (bool) $secure ? 'ssl' : 'none';
|
103 |
+
$phpmailer->Host = 'smtp.mailgun.org';
|
104 |
+
$phpmailer->Port = (bool) $secure ? 465 : 587;
|
105 |
+
$phpmailer->SMTPAuth = true;
|
106 |
+
$phpmailer->Username = $username;
|
107 |
+
$phpmailer->Password = $password;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Deactivate this plugin and die.
|
112 |
+
*
|
113 |
+
* Used to deactivate the plugin when files critical to it's operation can not be loaded
|
114 |
+
*
|
115 |
+
* @since 0.1
|
116 |
+
*
|
117 |
+
* @return none
|
118 |
+
*/
|
119 |
+
public function deactivate_and_die($file)
|
120 |
+
{
|
121 |
+
load_plugin_textdomain('mailgun', false, 'mailgun/languages');
|
122 |
+
$message = sprintf(__('Mailgun has been automatically deactivated because the file <strong>%s</strong> is missing. Please reinstall the plugin and reactivate.'), $file);
|
123 |
+
if (!function_exists('deactivate_plugins')) {
|
124 |
+
include ABSPATH.'wp-admin/includes/plugin.php';
|
125 |
+
}
|
126 |
+
deactivate_plugins(__FILE__);
|
127 |
+
wp_die($message);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Make a Mailgun api call.
|
132 |
+
*
|
133 |
+
* @param string $endpoint The Mailgun endpoint uri
|
134 |
+
*
|
135 |
+
* @return array
|
136 |
+
*
|
137 |
+
* @since 0.1
|
138 |
+
*/
|
139 |
+
public function api_call($uri, $params = [], $method = 'POST')
|
140 |
+
{
|
141 |
+
$options = get_option('mailgun');
|
142 |
+
$apiKey = (defined('MAILGUN_APIKEY') && MAILGUN_APIKEY) ? MAILGUN_APIKEY : $options['apiKey'];
|
143 |
+
$domain = (defined('MAILGUN_DOMAIN') && MAILGUN_DOMAIN) ? MAILGUN_DOMAIN : $options['domain'];
|
144 |
+
|
145 |
+
$time = time();
|
146 |
+
$url = $this->api_endpoint.$uri;
|
147 |
+
$headers = ['Authorization' => 'Basic '.base64_encode("api:{$apiKey}")];
|
148 |
+
|
149 |
+
switch ($method) {
|
150 |
+
case 'GET':
|
151 |
+
$params['sess'] = '';
|
152 |
+
$querystring = http_build_query($params);
|
153 |
+
$url = $url.'?'.$querystring;
|
154 |
+
$params = '';
|
155 |
+
break;
|
156 |
+
case 'POST':
|
157 |
+
case 'PUT':
|
158 |
+
case 'DELETE':
|
159 |
+
$params['sess'] = '';
|
160 |
+
$params['time'] = $time;
|
161 |
+
$params['hash'] = sha1(date('U'));
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
|
165 |
+
// make the request
|
166 |
+
$args = [
|
167 |
+
'method' => $method,
|
168 |
+
'body' => $params,
|
169 |
+
'headers' => $headers,
|
170 |
+
'sslverify' => true,
|
171 |
+
];
|
172 |
+
|
173 |
+
// make the remote request
|
174 |
+
$result = wp_remote_request($url, $args);
|
175 |
+
if (!is_wp_error($result)) {
|
176 |
+
return $result['body'];
|
177 |
+
} else {
|
178 |
+
return $result->get_error_message();
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Get account associated lists.
|
184 |
+
*
|
185 |
+
* @return array
|
186 |
+
*
|
187 |
+
* @since 0.1
|
188 |
+
*/
|
189 |
+
public function get_lists()
|
190 |
+
{
|
191 |
+
$results = [];
|
192 |
+
|
193 |
+
$lists_json = $this->api_call('lists', [], 'GET');
|
194 |
+
$lists_arr = json_decode($lists_json, true);
|
195 |
+
if (isset($lists_arr['items']) && !empty($lists_arr['items'])) {
|
196 |
+
$results = $lists_arr['items'];
|
197 |
+
}
|
198 |
+
|
199 |
+
return $results;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Handle add list ajax post.
|
204 |
+
*
|
205 |
+
* @return string json
|
206 |
+
*
|
207 |
+
* @since 0.1
|
208 |
+
*/
|
209 |
+
public function add_list()
|
210 |
+
{
|
211 |
+
$response = [];
|
212 |
+
|
213 |
+
$name = isset($_POST['name']) ? $_POST['name'] : null;
|
214 |
+
$email = isset($_POST['email']) ? $_POST['email'] : null;
|
215 |
+
|
216 |
+
$list_addresses = $_POST['addresses'];
|
217 |
+
|
218 |
+
if (!empty($list_addresses)) {
|
219 |
+
foreach ($list_addresses as $address => $val) {
|
220 |
+
$response[] = $this->api_call(
|
221 |
+
"lists/{$address}/members",
|
222 |
+
[
|
223 |
+
'address' => $email,
|
224 |
+
'name' => $name,
|
225 |
+
]
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
echo json_encode(['status' => 200, 'message' => 'Thank you!']);
|
230 |
+
} else {
|
231 |
+
echo json_encode(['status' => 500, 'message' => 'Uh oh. We weren\'t able to add you to the list'.count($list_addresses) ? 's.' : '. Please try again.']);
|
232 |
+
}
|
233 |
+
|
234 |
+
wp_die();
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Frontend List Form.
|
239 |
+
*
|
240 |
+
* @param string $list_address Mailgun address list id
|
241 |
+
* @param array $args widget arguments
|
242 |
+
* @param string $instance widget instance params
|
243 |
+
*
|
244 |
+
* @since 0.1
|
245 |
+
*/
|
246 |
+
public function list_form($list_address, $args = [], $instance = [])
|
247 |
+
{
|
248 |
+
$widget_class_id = "mailgun-list-widget-{$args['widget_id']}";
|
249 |
+
$form_class_id = "list-form-{$args['widget_id']}";
|
250 |
+
|
251 |
+
// List addresses from the plugin config
|
252 |
+
$list_addresses = array_map('trim', explode(',', $list_address));
|
253 |
+
|
254 |
+
// All list info from the API; used for list info when more than one list is available to subscribe to
|
255 |
+
$all_list_addresses = $this->get_lists(); ?>
|
256 |
+
<div class="mailgun-list-widget-front <?php echo $widget_class_id; ?> widget">
|
257 |
+
<form class="list-form <?php echo $form_class_id; ?>">
|
258 |
+
<div class="mailgun-list-widget-inputs">
|
259 |
+
<?php if (isset($args['list_title'])) : ?>
|
260 |
+
<div class="mailgun-list-title">
|
261 |
+
<h4 class="widget-title">
|
262 |
+
<span><?php echo $args['list_title']; ?></span>
|
263 |
+
</h4>
|
264 |
+
</div>
|
265 |
+
<?php endif; ?>
|
266 |
+
<?php if (isset($args['list_description'])) : ?>
|
267 |
+
<div class="mailgun-list-description">
|
268 |
+
<p class="widget-description">
|
269 |
+
<span><?php echo $args['list_description']; ?></span>
|
270 |
+
</p>
|
271 |
+
</div>
|
272 |
+
<?php endif; ?>
|
273 |
+
<?php if (isset($args['collect_name']) && intval($args['collect_name']) === 1) : ?>
|
274 |
+
<p class="mailgun-list-widget-name">
|
275 |
+
<strong>Name:</strong>
|
276 |
+
<input type="text" name="name" />
|
277 |
+
</p>
|
278 |
+
<?php endif; ?>
|
279 |
+
<p class="mailgun-list-widget-email">
|
280 |
+
<strong>Email:</strong>
|
281 |
+
<input type="text" name="email" />
|
282 |
+
</p>
|
283 |
+
</div>
|
284 |
+
|
285 |
+
<?php if (count($list_addresses) > 1) : ?>
|
286 |
+
<ul class="mailgun-lists" style="list-style: none;">
|
287 |
+
<?php foreach ($all_list_addresses as $la) : ?>
|
288 |
+
<?php if (!in_array($la['address'], $list_addresses)) {
|
289 |
+
continue;
|
290 |
+
} ?>
|
291 |
+
<li>
|
292 |
+
<input type="checkbox" class="mailgun-list-name" name="addresses[<?php echo $la['address']; ?>]" /> <?php echo $la['name']; ?>
|
293 |
+
</li>
|
294 |
+
<?php endforeach; ?>
|
295 |
+
</ul>
|
296 |
+
<?php else : ?>
|
297 |
+
<input type="hidden" name="addresses[<?php echo $list_addresses[0]; ?>]" value="on" />
|
298 |
+
<?php endif; ?>
|
299 |
+
|
300 |
+
<input class="mailgun-list-submit-button" data-form-id="<?php echo $form_class_id; ?>" type="button" value="Subscribe" />
|
301 |
+
<input type="hidden" name="mailgun-submission" value="1" />
|
302 |
+
|
303 |
+
</form>
|
304 |
+
<div class="widget-list-panel result-panel" style="display:none;">
|
305 |
+
<span>Thank you for subscribing!</span>
|
306 |
+
</div>
|
307 |
+
</div>
|
308 |
+
|
309 |
+
<script>
|
310 |
+
|
311 |
+
jQuery(document).ready(function(){
|
312 |
+
|
313 |
+
jQuery('.mailgun-list-submit-button').on('click', function() {
|
314 |
+
|
315 |
+
var form_id = jQuery(this).data('form-id');
|
316 |
+
|
317 |
+
if(jQuery('.mailgun-list-name').length > 0 && jQuery('.'+form_id+' .mailgun-list-name:checked').length < 1) {
|
318 |
+
alert('Please select a list to subscribe to.');
|
319 |
+
return;
|
320 |
+
}
|
321 |
+
|
322 |
+
if(jQuery('.'+form_id+' .mailgun-list-widget-name input') && jQuery('.'+form_id+' .mailgun-list-widget-name input').val() === '') {
|
323 |
+
alert('Please enter your subscription name.');
|
324 |
+
return;
|
325 |
+
}
|
326 |
+
|
327 |
+
if(jQuery('.'+form_id+' .mailgun-list-widget-email input').val() === '') {
|
328 |
+
alert('Please enter your subscription email.');
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
|
332 |
+
jQuery.ajax({
|
333 |
+
url: '<?php echo admin_url('admin-ajax.php?action=add_list'); ?>',
|
334 |
+
action:'add_list',
|
335 |
+
type: 'post',
|
336 |
+
dataType: 'json',
|
337 |
+
data: jQuery('.'+form_id+'').serialize(),
|
338 |
+
success: function(data) {
|
339 |
+
|
340 |
+
data_msg = data.message;
|
341 |
+
already_exists = false;
|
342 |
+
if(data_msg !== undefined){
|
343 |
+
already_exists = data_msg.indexOf('Address already exists') > -1;
|
344 |
+
}
|
345 |
+
|
346 |
+
// success
|
347 |
+
if((data.status === 200)) {
|
348 |
+
jQuery('.<?php echo $widget_class_id; ?> .widget-list-panel').css('display', 'none');
|
349 |
+
jQuery('.<?php echo $widget_class_id; ?> .list-form').css('display', 'none');
|
350 |
+
jQuery('.<?php echo $widget_class_id; ?> .result-panel').css('display', 'block');
|
351 |
+
// error
|
352 |
+
} else {
|
353 |
+
alert(data_msg);
|
354 |
+
}
|
355 |
+
}
|
356 |
+
});
|
357 |
+
});
|
358 |
+
});
|
359 |
+
|
360 |
+
</script>
|
361 |
+
|
362 |
+
<?php
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Initialize List Form.
|
368 |
+
*
|
369 |
+
* @param array $atts Form attributes
|
370 |
+
*
|
371 |
+
* @since 0.1
|
372 |
+
*/
|
373 |
+
public function build_list_form($atts)
|
374 |
+
{
|
375 |
+
if (isset($atts['id']) && $atts['id'] != '') {
|
376 |
+
$args['widget_id'] = md5(rand(10000, 99999) + $atts['id']);
|
377 |
+
|
378 |
+
if (isset($atts['collect_name'])) {
|
379 |
+
$args['collect_name'] = true;
|
380 |
+
}
|
381 |
+
|
382 |
+
if (isset($atts['title'])) {
|
383 |
+
$args['list_title'] = $atts['title'];
|
384 |
+
}
|
385 |
+
|
386 |
+
if (isset($atts['description'])) {
|
387 |
+
$args['list_description'] = $atts['description'];
|
388 |
+
}
|
389 |
+
|
390 |
+
ob_start();
|
391 |
+
$this->list_form($atts['id'], $args);
|
392 |
+
$output_string = ob_get_contents();
|
393 |
+
ob_end_clean();
|
394 |
+
|
395 |
+
return $output_string;
|
396 |
+
} else {
|
397 |
+
?>
|
398 |
+
<span>Mailgun list ID needed to render form!</span>
|
399 |
+
<br />
|
400 |
+
<strong>Example :</strong> [mailgun id="[your list id]"]
|
401 |
+
<?php
|
402 |
+
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Initialize List Widget.
|
408 |
+
*
|
409 |
+
* @since 0.1
|
410 |
+
*/
|
411 |
+
public function load_list_widget()
|
412 |
+
{
|
413 |
+
register_widget('list_widget');
|
414 |
+
add_shortcode('mailgun', [&$this, 'build_list_form']);
|
415 |
+
}
|
416 |
}
|
417 |
|
418 |
$mailgun = new Mailgun();
|
419 |
|
420 |
+
if (@include dirname(__FILE__).'/includes/widget.php') {
|
421 |
+
add_action('widgets_init', [&$mailgun, 'load_list_widget']);
|
422 |
+
add_action('wp_ajax_nopriv_add_list', [&$mailgun, 'add_list']);
|
423 |
+
add_action('wp_ajax_add_list', [&$mailgun, 'add_list']);
|
424 |
}
|
425 |
|
426 |
+
if (is_admin()) {
|
427 |
+
if (@include dirname(__FILE__).'/includes/admin.php') {
|
428 |
+
$mailgunAdmin = new MailgunAdmin();
|
429 |
+
} else {
|
430 |
+
Mailgun::deactivate_and_die(dirname(__FILE__).'/includes/admin.php');
|
431 |
+
}
|
432 |
}
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
-
|
|
|
|
|
2 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
3 |
Tags: mailgun, smtp, http, api, mail, email
|
4 |
Requires at least: 3.3
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
-
|
|
|
|
|
10 |
|
11 |
== Description ==
|
12 |
|
@@ -18,6 +22,7 @@ The latest version of this plugin adds support for Mailgun list subscription. Us
|
|
18 |
|
19 |
The current version of this plugin only handles sending emails, tracking and tagging and list subscription.
|
20 |
|
|
|
21 |
== Installation ==
|
22 |
|
23 |
1. Upload the `mailgun` folder to the `/wp-content/plugins/` directory or install directly through the plugin installer
|
@@ -26,28 +31,30 @@ The current version of this plugin only handles sending emails, tracking and tag
|
|
26 |
4. Click the Test Configuration button to verify that your settings are correct.
|
27 |
5. Click View Available Lists to review shortcode settings for lists in your Mailgun account that you may wish to help users subscribe to
|
28 |
|
|
|
29 |
== Frequently Asked Questions ==
|
30 |
|
31 |
-
|
32 |
|
33 |
Your web server may not allow outbound HTTP connections. Set `Use HTTP API` to "No", and fill out the configuration options to SMTP and test again.
|
34 |
|
35 |
-
|
36 |
|
37 |
Your web server may not allow outbound SMTP connections on port 465 for secure connections or 587 for unsecured connections. Try changing `Use Secure SMTP` to "No" or "Yes" depending on your current configuration and testing again. If both fail, try setting `Use HTTP API` to "Yes" and testing again.
|
38 |
|
39 |
-
|
40 |
|
41 |
Yes, using the following constants that can be placed in wp-config.php:
|
42 |
|
43 |
-
|
44 |
MAILGUN_USEAPI Type: boolean
|
45 |
MAILGUN_APIKEY Type: string
|
46 |
MAILGUN_DOMAIN Type: string
|
47 |
MAILGUN_USERNAME Type: string
|
48 |
MAILGUN_PASSWORD Type: string
|
49 |
MAILGUN_SECURE Type: boolean
|
50 |
-
|
|
|
51 |
|
52 |
== Screenshots ==
|
53 |
|
@@ -58,41 +65,3 @@ MAILGUN_SECURE Type: boolean
|
|
58 |
5. Using a Subscription Code
|
59 |
6. Subscription Form Seen By Site Visitors
|
60 |
|
61 |
-
== Upgrade Notice ==
|
62 |
-
|
63 |
-
= 1.0 =
|
64 |
-
|
65 |
-
Re-release to update versioning to start at 1.0 instead of 0.1
|
66 |
-
|
67 |
-
= 0.1 =
|
68 |
-
|
69 |
-
Initial Release
|
70 |
-
|
71 |
-
== ChangeLog ==
|
72 |
-
|
73 |
-
= 1.4.1 (2015-12-01): =
|
74 |
-
* Clarify compatibility with WordPress 4.3
|
75 |
-
|
76 |
-
= 1.4 (2015-11-15): =
|
77 |
-
* Added shortcode and widget support for list subscription
|
78 |
-
|
79 |
-
= 1.3.1 (2014-11-19): =
|
80 |
-
* Switched to Semantic Versioning
|
81 |
-
* Fixed issue with campaigns and tags
|
82 |
-
|
83 |
-
= 1.3 (2014-08-25): =
|
84 |
-
* Added check to ignore empty attachments
|
85 |
-
|
86 |
-
= 1.2 (2014-08-19): =
|
87 |
-
* Fixed errors related to undefined variable. https://github.com/mailgun/wordpress-plugin/pull/3
|
88 |
-
|
89 |
-
= 1.1 (2013-12-09): =
|
90 |
-
* Attachments are now handled properly.
|
91 |
-
* Added ability to customize tags and campaigns.
|
92 |
-
* Added ability to toggle URL and open tracking.
|
93 |
-
|
94 |
-
= 1.0 (2012-11-27): =
|
95 |
-
* Re-release to update versioning to start at 1.0 instead of 0.1
|
96 |
-
|
97 |
-
= 0.1 (2012-11-21): =
|
98 |
-
* Initial Release
|
1 |
+
Mailgun for WordPress
|
2 |
+
=====================
|
3 |
+
|
4 |
Contributors: Mailgun, sivel, lookahead.io, m35dev
|
5 |
Tags: mailgun, smtp, http, api, mail, email
|
6 |
Requires at least: 3.3
|
7 |
+
Tested up to: 4.7
|
8 |
+
Stable tag: 1.5.0
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
+
|
12 |
+
Easily send email from your WordPress site through Mailgun using the HTTP API or SMTP.
|
13 |
+
|
14 |
|
15 |
== Description ==
|
16 |
|
22 |
|
23 |
The current version of this plugin only handles sending emails, tracking and tagging and list subscription.
|
24 |
|
25 |
+
|
26 |
== Installation ==
|
27 |
|
28 |
1. Upload the `mailgun` folder to the `/wp-content/plugins/` directory or install directly through the plugin installer
|
31 |
4. Click the Test Configuration button to verify that your settings are correct.
|
32 |
5. Click View Available Lists to review shortcode settings for lists in your Mailgun account that you may wish to help users subscribe to
|
33 |
|
34 |
+
|
35 |
== Frequently Asked Questions ==
|
36 |
|
37 |
+
- Testing the configuration fails when using the HTTP API =
|
38 |
|
39 |
Your web server may not allow outbound HTTP connections. Set `Use HTTP API` to "No", and fill out the configuration options to SMTP and test again.
|
40 |
|
41 |
+
- Testing the configuration fails when using SMTP =
|
42 |
|
43 |
Your web server may not allow outbound SMTP connections on port 465 for secure connections or 587 for unsecured connections. Try changing `Use Secure SMTP` to "No" or "Yes" depending on your current configuration and testing again. If both fail, try setting `Use HTTP API` to "Yes" and testing again.
|
44 |
|
45 |
+
- Can this be configured globally for WordPress Multisite? =
|
46 |
|
47 |
Yes, using the following constants that can be placed in wp-config.php:
|
48 |
|
49 |
+
```
|
50 |
MAILGUN_USEAPI Type: boolean
|
51 |
MAILGUN_APIKEY Type: string
|
52 |
MAILGUN_DOMAIN Type: string
|
53 |
MAILGUN_USERNAME Type: string
|
54 |
MAILGUN_PASSWORD Type: string
|
55 |
MAILGUN_SECURE Type: boolean
|
56 |
+
```
|
57 |
+
|
58 |
|
59 |
== Screenshots ==
|
60 |
|
65 |
5. Using a Subscription Code
|
66 |
6. Subscription Form Seen By Site Visitors
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|