50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
use Socketlabs\SocketLabsClient;
|
|
use Socketlabs\Message\BasicMessage;
|
|
use Socketlabs\Message\EmailAddress;
|
|
|
|
include "socketlabs-php-main/socketlabs-php-main/InjectionApi/src/includes.php";
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["variableName"])) {
|
|
$receivedVariable = $_POST["variableName"];
|
|
// Process the received variable here
|
|
// echo "Received variable: " . $receivedVariable;
|
|
|
|
//echo "Received variable: " . $receivedVariable;
|
|
|
|
$serverId = 42329;
|
|
$apiKey = "RB1ix50wg5NW19mvUHvx.DImVryVSWvWwgjr61XNGhYAVtlr5yNEmmZmsj3ev";
|
|
|
|
$client = new SocketLabsClient($serverId, $apiKey);
|
|
|
|
$message = new BasicMessage();
|
|
$message->subject = "Test Message";
|
|
$message->htmlBody = "<html><body><p>".$receivedVariable."</p></body></html>";
|
|
$message->plainTextBody = "Test email body";
|
|
|
|
// Ensure this From address uses your verified domain in SocketLabs!
|
|
$message->from = new EmailAddress("[email protected]");
|
|
$message->addToAddress("[email protected]");
|
|
|
|
try {
|
|
$response = $client->send($message);
|
|
if($response->result == "Success"){
|
|
echo("Tilaus lähetetty");
|
|
echo "Received variable: " . $receivedVariable;
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo "Caught exception: " . $e->getMessage();
|
|
}
|
|
|
|
|
|
} else {
|
|
echo "No data received";
|
|
}
|
|
|
|
|
|
/*ini_set('display_errors', 1);
|
|
error_reporting(E_ALL);
|
|
*/
|