Last active
May 30, 2025 17:19
-
-
Save mahircoding/580e39ca4c16cc78091bc797c0ab95d9 to your computer and use it in GitHub Desktop.
send mail with api mailtrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function kirim($v, $x, $y, $z) { | |
| $curl = curl_init(); | |
| curl_setopt_array($curl, [ | |
| CURLOPT_URL => "https://send.api.mailtrap.io/api/send", | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_ENCODING => "", | |
| CURLOPT_MAXREDIRS => 10, | |
| CURLOPT_TIMEOUT => 30, | |
| CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
| CURLOPT_CUSTOMREQUEST => "POST", | |
| CURLOPT_POSTFIELDS => json_encode([ | |
| 'to' => [ | |
| [ | |
| 'email' => $v, | |
| 'name' => $x | |
| ] | |
| ], | |
| 'from' => [ | |
| 'email' => 'no_reply@brizpress.com', // Replace with your actual email | |
| 'name' => 'Jasa Trade' | |
| ], | |
| 'reply_to' => [ | |
| 'email' => 'reply@brizpress.com', // Replace with your actual email | |
| 'name' => 'Reply' | |
| ], | |
| 'headers' => [ | |
| 'X-Message-Source' => 'dev.mydomain.com' // Replace with your actual domain web | |
| ], | |
| 'subject' => $y, | |
| 'text' => $z, | |
| 'html' => $z, | |
| ]), | |
| CURLOPT_HTTPHEADER => [ | |
| "Accept: application/json", | |
| "Authorization: Bearer c271242f455e87fxxxxxxxxx", // Replace with your actual API token | |
| "Content-Type: application/json" | |
| ], | |
| ]); | |
| $response = curl_exec($curl); | |
| $err = curl_error($curl); | |
| curl_close($curl); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.