{"id":23258,"date":"2026-09-16T02:51:49","date_gmt":"2026-09-16T02:51:49","guid":{"rendered":"https:\/\/www.mailgun.com\/blog\/the-php-sdk-the-first-of-many-official-mailgun-sdks-2\/"},"modified":"2026-09-16T02:51:49","modified_gmt":"2026-09-16T02:51:49","slug":"the-php-sdk-the-first-of-many-official-mailgun-sdks","status":"publish","type":"blog","link":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/","title":{"rendered":"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Wir freuen uns, heute bekannt geben zu k\u00f6nnen, dass der Nachrichtenversand mit Mailgun f\u00fcr PHP-Entwicklungsteams jetzt noch einfacher ist. In den letzten Wochen haben wir intensiv an SDKs f\u00fcr die Mailgun-API gearbeitet. Das SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Heute ver\u00f6ffentlichen wir die PHP-Version des SDKs. Weitere Sprachen folgen in K\u00fcrze.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Falls Sie noch nicht mit einem SDK vertraut sind, sehen wir uns zun\u00e4chst an, was erforderlich ist, um eine Nachricht mit der Standard-HTTP-CURL-Bibliothek f\u00fcr PHP zu versenden.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nachricht mit CURL versenden:<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                Shell                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-shell\">\r\n                                <code id=\"code_0_content\" class=\"language-shell\">\r\n\r\n                                        function send_simple_message() {  \r\n      $ch = curl_init();\r\n      curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);\r\n      curl_setopt($ch, CURLOPT_USERPWD, &#039;api:key-example&#039;);\r\n      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\r\n      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, &#039;POST&#039;);\r\n      curl_setopt($ch, CURLOPT_URL, \r\n          &#039;https:\/\/api.mailgun.net\/v2\/samples.mailgun.org\/messages&#039;);\r\n      curl_setopt($ch, CURLOPT_POSTFIELDS, \r\n            array(&#039;from&#039; =&gt; &#039;Dwight Schrute &#039;,\r\n                  &#039;to&#039; =&gt; &#039;Michael Scott &#039;,\r\n                  &#039;subject&#039; =&gt; &#039;The Printer Caught Fire&#039;,\r\n                  &#039;text&#039; =&gt; &#039;We have a problem.&#039;));\r\n      $result = curl_exec($ch);\r\n      curl_close($ch);\r\n      return $result;\r\n    }\r\n    echo send_simple_message();\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Der obige Code versendet eine Nachricht \u00fcber die Mailgun-API. Dabei handelt es sich jedoch um viel Code, der zwar wichtig, aber auch komplex ist und ohne umfassende CURL-Expertise recht verwirrend sein kann.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mit unserem neuen SDK konnten wir die erforderliche Code-Menge auf wenige Zeilen reduzieren.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nachricht mit dem Mailgun-PHP-SDK versenden:<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        # First, instantiate the SDK with your API credentials and define your domain.  \r\n    $mgClient = new Mailgun(&quot;key-example&quot;); \r\n    $domain = &quot;example.com&quot;; \r\n\r\n    # Now, compose and send your message. \r\n    $mgClient-&gt;sendMessage($domain, \r\n                   array(&#039;from&#039; =&gt; &#039;Dwight Schrute &#039;, \r\n                         &#039;to&#039; =&gt; &#039;Michael Scott &#039;, \r\n                         &#039;subject&#039; =&gt; &#039;The Printer Caught Fire&#039;, \r\n                         &#039;text&#039; =&gt; &#039;We have a problem.&#039;));\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Logs mit dem Mailgun-PHP-SDK abrufen:<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        # First, instantiate the SDK with your API credentials and  \r\n    define your domain.  \r\n    $mgClient = new Mailgun(&#039;key-3ax6xnjp29jd6fds4gc373sgvjxteol0&#039;);\r\n    $domain = &#039;samples.mailgun.org&#039;;\r\n\r\n    # Now, issue a get against the &quot;log&quot; resource URL. \r\n    $result = $mgClient-&gt;get(&quot;$domain\/log&quot;, array(&#039;limit&#039; =&gt; 5, &#039;skip&#039; =&gt; 0));\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Alle HTTP-Aktionen geben ein Antwortobjekt zur\u00fcck, das eine problemlose Interaktion erm\u00f6glicht.<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        # Obtain the HTTP response code. (e.g. 200)  \r\n    $responseCode = $result-&gt;http_response_code;\r\n\r\n    # Obtain the total count of results provided by the query. \r\n    $responseBody = $result-&gt;http_response_body-&gt;total_count;\r\n\r\n    # Iterate through the results and echo the message IDs.\r\n    $logItems = $result-&gt;http_response_body-&gt;items;\r\n    for($logItems as $logItem){  \r\necho $logItem-&gt;message_id . &quot;n&quot;;\r\n    }\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Falls Sie das SDK gleich heute nutzen m\u00f6chten, finden Sie den Code als \u00f6ffentliches Repository auf GitHub (<a href=\"https:\/\/github.com\/mailgun\/mailgun-php\" target=\"_tabs\" rel=\"noopener noreferrer\">mailgun-php<\/a>). Dort finden Sie M\u00f6glichkeiten, alles umzusetzen, was auch mit der Mailgun-API m\u00f6glich ist. Weitere Anwendungsbeispiele finden Sie in der README-Datei im Repository. Aber das ist noch nicht alles \u2026 Wir haben einige Dienstprogramme in das SDK integriert.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Message Builder<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Das Erstellen eines Arrays von Parametern kann f\u00fcr einige Code-Implementierungen schwierig sein. Daher haben wir eine Klasse integriert, mit der Sie Methodenaufrufe durchf\u00fchren k\u00f6nnen, die automatisch ein ordnungsgem\u00e4\u00df formatiertes Array von Nachrichtenparametern aufbauen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nachricht mit dem Mailgun-PHP-SDK und Message Builder versenden:<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        # First, instantiate the SDK with your API credentials and define  \r\n    your domain.  \r\n    $mgClient = new Mailgun(&quot;key-example&quot;);\r\n    $domain = &quot;example.com&quot;;\r\n\r\n    # Next, instantiate a Message Builder object from the SDK.\r\n    $msgBldr = $mgClient-&gt;MessageBuilder();\r\n\r\n    # Define the from address.\r\n    $msgBldr-&gt;setFromAddress(&quot;dwight@example.com&quot;, \r\n                     array(&quot;first&quot;=&gt;&quot;Dwight&quot;, &quot;last&quot; =&gt; &quot;Schrute&quot;)); \r\n    # Define a to recipient. \r\n    $msgBldr-&gt;addToRecipient(&quot;michael@example.com&quot;, \r\n                     array(&quot;first&quot; =&gt; &quot;Michael&quot;, &quot;last&quot; =&gt; &quot;Scott&quot;)); \r\n    # Define a cc recipient. \r\n    $msgBldr-&gt;addCcRecipient(&quot;pam@example.com&quot;, \r\n                     array(&quot;first&quot; =&gt; &quot;Pam&quot;, &quot;last&quot; =&gt; &quot;Beesly&quot;)); \r\n    # Define the subject. \r\n    $msgBldr-&gt;setSubject(&quot;Help!&quot;); \r\n    # Define the body of the message. \r\n    $msgBldr-&gt;setTextBody(&quot;The printer is on fire.&quot;); \r\n\r\n    # Other Optional Parameters. \r\n    $msgBldr-&gt;addCampaignId(&quot;Sabre-Printer-Fire&quot;); \r\n    $msgBldr-&gt;addCustomHeader(&quot;Customer-Id&quot;, &quot;12345&quot;); \r\n    $msgBldr-&gt;addAttachment(&quot;@\/sabre.jpg&quot;); \r\n    $msgBldr-&gt;setDeliveryTime(&quot;tomorrow 8:00AM&quot;, &quot;PST&quot;); \r\n\r\n    # Finally, send the message. \r\n    $mgClient-&gt;post(&#039;{$domain}\/messages&#039;, $msgBldr-&gt;getMessage());\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Eine Liste aller verf\u00fcgbaren Funktionen finden Sie in der\u00a0<a href=\"https:\/\/github.com\/mailgun\/mailgun-php\/tree\/master\/src\/Message\" target=\"_tabs\" rel=\"noopener noreferrer\">Liste auf GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Batch Message<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Zus\u00e4tzlich zum Message Builder bieten wir Batch Message an. Mit dieser Klasse k\u00f6nnen Sie eine Nachricht erstellen und eine Vorlagennachricht in Batches an bis zu 1.000 Empfangsadressen pro Post senden. Der Vorteil dieser Klasse ist, dass die Anzahl der Empfangsadressen \u00fcberwacht wird und die Nachricht automatisch an den Endpunkt gesendet wird, sobald Sie die 1.000. Adresse hinzugef\u00fcgt haben. Das bedeutet, dass Sie Ihre Nachricht erstellen und mit der Iteration durch Ihre Datenbank beginnen k\u00f6nnen. K\u00fcmmern Sie sich nicht um den eigentlichen Versand der Nachricht\u00a0\u2013 das SDK \u00fcbernimmt bei Bedarf die \u00dcbermittlung an die API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nachricht mit dem Mailgun-PHP-SDK und Batch Message versenden:<\/p>\n\n\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"In die Zwischenablage kopieren\" data-clipboard-success-label=\"Kopiert\" data-clipboard-error-label=\"Kopieren nicht m\u00f6glich\" data-tooltip=\"In die Zwischenablage kopieren\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"In die Zwischenablage kopieren\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        # First, instantiate the SDK with your API credentials and define  \r\n    your domain.  \r\n    $mgClient = new Mailgun(&quot;key-example&quot;);\r\n    $domain = &quot;example.com&quot;;\r\n\r\n    # Next, instantiate a Message Builder object from the SDK, pass in your \r\n    sending domain.  \r\n    $batchMsg = $mgClient-&gt;BatchMessage($domain);\r\n\r\n    # Define the from address.\r\n    $batchMsg-&gt;setFromAddress(&quot;dwight@example.com&quot;, \r\n                      array(&quot;first&quot;=&gt;&quot;Dwight&quot;, &quot;last&quot; =&gt; &quot;Schrute&quot;));\r\n    # Define the subject. \r\n    $batchMsg-&gt;setSubject(&quot;Help!&quot;);\r\n    # Define the body of the message.\r\n    $batchMsg-&gt;setTextBody(&quot;The printer is on fire!&quot;);\r\n\r\n    # Next, let&#039;s add a few recipients to the batch job.\r\n    $batchMsg-&gt;addToRecipient(&quot;pam@example.com&quot;, \r\n                      array(&quot;first&quot; =&gt; &quot;pam&quot;, &quot;last&quot; =&gt; &quot;Beesly&quot;));\r\n    $batchMsg-&gt;addToRecipient(&quot;jim@example.com&quot;, \r\n                      array(&quot;first&quot; =&gt; &quot;Jim&quot;, &quot;last&quot; =&gt; &quot;Halpert&quot;));\r\n    $batchMsg-&gt;addToRecipient(&quot;andy@example.com&quot;, \r\n                      array(&quot;first&quot; =&gt; &quot;Andy&quot;, &quot;last&quot; =&gt; &quot;Bernard&quot;));\r\n    ...etc...etc...\r\n    \/\/ After 1,000 recipeints, Batch Message will automatically post your message \r\n    to the messages endpoint. \r\n\r\n    \/\/ Call finalize() to send any remaining recipients still in the buffer.\r\n    $batchMsg-&gt;finalize();\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n\n\n<p class=\"wp-block-paragraph\">Wie Sie sehen, erweitert Batch Message den Message Builder. Alle im Message Builder verf\u00fcgbaren Funktionen stehen auch in Batch Message zur Verf\u00fcgung. Werfen Sie einen Blick in die\u00a0<a href=\"https:\/\/github.com\/mailgun\/mailgun-php\/blob\/master\/doc\/index.md\" target=\"_tabs\" rel=\"noopener noreferrer\">vollst\u00e4ndigen Dokumentation auf GitHub<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Opt-in-Handler<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Zu guter Letzt haben wir einen einfachen Double-Opt-in-Handler entwickelt, mit dem Sie eindeutige Opt-in-Links generieren k\u00f6nnen. Der Opt-in-Handler nutzt auch unseren\u00a0<a href=\"https:\/\/www.mailgun.com\/de\/?post_type=products&#038;p=3103\" target=\"_tabs\" rel=\"noopener noreferrer\">kostenlosen Dienst zur E-Mail-Adressvalidierung<\/a>\u00a0um die Genauigkeit der E-Mail-Adressen zu \u00fcberpr\u00fcfen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Der typische Ablauf f\u00fcr die Verwendung dieser Klasse sieht wie folgt aus:<br>\n<b>Abonnement wird angefragt<\/b>\u00a0-&gt; [Empfangsadresse validieren] -&gt; [Opt-in-Link generieren] -&gt; [Opt-in-Link per E-Mail senden]<br>\n<b>Opt-in-Link wird geklickt<\/b>\u00a0-&gt; [Opt-in-Link validieren] -&gt; [Abonnement best\u00e4tigen] -&gt; [Abschlie\u00dfende Best\u00e4tigung senden]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Verwenden Sie diese Klasse am besten f\u00fcr die Anmeldeformulare auf Ihrer Website. Daf\u00fcr ben\u00f6tigen Sie einen \u00fcber das Internet zug\u00e4nglichen Webserver, der den Klick auf den Validierungslink verarbeitet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lassen Sie uns wissen, was Sie denken. Gibt es noch etwas, das Sie sich im SDK w\u00fcnschen w\u00fcrden? Oder etwas, das Ihnen besonders gef\u00e4llt? Wir freuen uns \u00fcber Ihr Feedback.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Viel Spa\u00df beim Versenden,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ihr Mailgun-Team<\/p>\n\n\n\r\n    <aside data-content-type=\"longform\"  class=\"banner-block longform-spacings rounded-lg shadow-lg px-5 py-6 px-md-6 py-md-7 p-lg-7 bg-light\" data-theme=\"dark\" aria-labelledby=\"banner-block-block_f975b6426eacb7d76b8216ddedf5b7c6\">\r\n                    <p class=\"text-uppercase section-caption text-body-color\">\r\n                Registrieren            <\/p>\r\n                            <p class=\"h4 text-accent fw-bold\" id=\"banner-block-block_f975b6426eacb7d76b8216ddedf5b7c6\">\r\n                Loslegen ist ganz einfach. Und es ist kostenlos.            <\/p>\r\n                            <div class=\"mb-0 text-body-color\">\r\n                                    <div class=\"content-body mb-0 text-body-color\">Erfahren Sie, was Sie mit der weltbesten Plattform f\u00fcr E-Mail-Zustellung alles erreichen k\u00f6nnen.<\/div>\r\n                            <\/div>\r\n        \r\n        <div class=\"text-start mt-5\"><a href=\"https:\/\/signup.mailgun.com\/new\/signup\"  class=\"btn btn-secondary\" >Get started<\/a><\/div>\r\n    <\/aside>\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013<\/p>\n","protected":false},"author":13,"featured_media":4555,"menu_order":0,"template":"","meta":{"_acf_changed":true,"footnotes":""},"blog_category":[22],"class_list":["post-23258","blog","type-blog","status-publish","has-post-thumbnail","hentry","blog_category-product"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun<\/title>\n<meta name=\"description\" content=\"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun\" \/>\n<meta property=\"og:description\" content=\"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/\" \/>\n<meta property=\"og:site_name\" content=\"Transactional Email API Service For Developers | Mailgun\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Product.png\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"448\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/\",\"name\":\"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Product.png\",\"datePublished\":\"2026-09-16T02:51:49+00:00\",\"description\":\"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Product.png\",\"contentUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Product.png\",\"width\":720,\"height\":448},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/product\\\/the-php-sdk-the-first-of-many-official-mailgun-sdks\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#website\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/\",\"name\":\"Transactional Email API Service For Developers | Mailgun\",\"description\":\"Leistungsstarke Transaktions-E-Mail-APIs, mit denen Sie E-Mails senden, empfangen und nachverfolgen k\u00f6nnen, speziell f\u00fcr Entwickler konzipiert. Erfahren Sie noch heute mehr!\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#organization\",\"name\":\"Transactional Email API Service For Developers | Mailgun\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-android-chrome-512x512-1.png\",\"contentUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-android-chrome-512x512-1.png\",\"width\":512,\"height\":512,\"caption\":\"Transactional Email API Service For Developers | Mailgun\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun","description":"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/","og_locale":"de_DE","og_type":"article","og_title":"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun","og_description":"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013","og_url":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/","og_site_name":"Transactional Email API Service For Developers | Mailgun","og_image":[{"width":720,"height":448,"url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Product.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/","url":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/","name":"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs - Transactional Email API Service For Developers | Mailgun","isPartOf":{"@id":"https:\/\/www.mailgun.com\/de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/#primaryimage"},"image":{"@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Product.png","datePublished":"2026-09-16T02:51:49+00:00","description":"Das PHP-SDK erleichtert die Interaktion mit unserer API, da der \u00fcblicherweise f\u00fcr die Kommunikation mit einem HTTP-Webdienst erforderliche Boilerplate-Code entf\u00e4llt. Weiterlesen \u2013","breadcrumb":{"@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/#primaryimage","url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Product.png","contentUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Product.png","width":720,"height":448},{"@type":"BreadcrumbList","@id":"https:\/\/www.mailgun.com\/de\/blog\/product\/the-php-sdk-the-first-of-many-official-mailgun-sdks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mailgun.com\/de\/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https:\/\/www.mailgun.com\/de\/blog\/"},{"@type":"ListItem","position":3,"name":"Das PHP-SDK: Das erste von vielen offiziellen Mailgun-SDKs"}]},{"@type":"WebSite","@id":"https:\/\/www.mailgun.com\/de\/#website","url":"https:\/\/www.mailgun.com\/de\/","name":"Transactional Email API Service For Developers | Mailgun","description":"Leistungsstarke Transaktions-E-Mail-APIs, mit denen Sie E-Mails senden, empfangen und nachverfolgen k\u00f6nnen, speziell f\u00fcr Entwickler konzipiert. Erfahren Sie noch heute mehr!","publisher":{"@id":"https:\/\/www.mailgun.com\/de\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mailgun.com\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/www.mailgun.com\/de\/#organization","name":"Transactional Email API Service For Developers | Mailgun","url":"https:\/\/www.mailgun.com\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/www.mailgun.com\/de\/#\/schema\/logo\/image\/","url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/06\/cropped-android-chrome-512x512-1.png","contentUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/06\/cropped-android-chrome-512x512-1.png","width":512,"height":512,"caption":"Transactional Email API Service For Developers | Mailgun"},"image":{"@id":"https:\/\/www.mailgun.com\/de\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/blog\/23258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/users\/13"}],"version-history":[{"count":0,"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/blog\/23258\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/media\/4555"}],"wp:attachment":[{"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/media?parent=23258"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.mailgun.com\/de\/wp-json\/wp\/v2\/blog_category?post=23258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}