Send SMS via Email

SMS Details:



 

CODE FOLLOWS

<?php
    session_name
('eckfordd');
    
session_start();

    
error_reporting(E_ALL);

    
$step $_SESSION['step'] ?? 0;
    
$step $_POST['step'] ?? $step;

    
$options = ['Verizon''tMobile''Sprint''Att''Virgin''Cricket''Mint'];

    
$from $_POST['from'] ?? '';
    
$to $_POST['to'] ?? '';
    
$carrier $_POST['carrier'] ?? '';
    
$subject $_POST['subject'] ?? '';
    
$message stripslashes($_POST['message'] ?? '');

    include(
'includes/header.php');

    if (
$step == 0) {
        
?>

        <h1>Send SMS via Email</h1>
        <form action="my_sms.php" method="post">
            <fieldset>
                <legend>SMS Details:</legend>
                <label for="from">From (Email):</label>
                <input type="email" id="from" name="from" value="<?= htmlspecialchars($from?>" required>
                <br>
                <label for="to">To (Phone Number):</label>
                <input type="text" id="to" name="to" value="<?= htmlspecialchars($to?>" pattern="\d{10}" required>
                <br>
                <label for="subject">Subject:</label>
                <input type="text" id="subject" name="subject" value="<?= htmlspecialchars($subject?>" required>
                <br>
                <label for="message">Message:</label>
                <textarea id="message" name="message" rows="4" required><?= htmlspecialchars($message?></textarea>
                <br>
                <label for="carrier">Carrier:</label>
                <select id="carrier" name="carrier" required>
                    <?php foreach ($options as $opt): ?>
                        <option value="<?= $opt ?><?= $carrier === $opt "SELECTED" "" ?>><?= $opt ?></option>
                    <?php endforeach; ?>
                </select>
            </fieldset>
            <input type="hidden" name="step" value="1">
            <input type="submit" value="Send SMS">
        </form>

        <?php
    
} elseif ($step == 1) {
        if (!
filter_var($fromFILTER_VALIDATE_EMAIL) || !preg_match('/^\d{10}$/'$to)) {
            echo 
"Invalid input. Please try again.";
            
$_SESSION['step'] = 0;
            exit;
        }

        switch (
$carrier) {
            case 
'Verizon'$gateway '@vtext.com'; break;
            case 
'tMobile'$gateway '@tmomail.net'; break;
            case 
'Sprint'$gateway '@page.nextel.com'; break;
            case 
'Att':
            case 
'Cricket'$gateway '@cingularme.com'; break;
            case 
'Virgin'$gateway '@vmobl.com'; break;
            case 
'Mint'$gateway '@mailmymobile.net'; break;
            default: 
$gateway ''; break;
        }

        if (
$gateway) {
            
$formatted_number $to $gateway;
            
$mail_sent mail($formatted_number$subject$message"From: $from");

            if (
$mail_sent) {
                echo 
"Message sent successfully to $to via $carrier.";
            } else {
                echo 
"Failed to send message. Please try again.";
            }
        } else {
            echo 
"Invalid carrier selected.";
        }
        
?>

        <form action="my_sms.php" method="post">
            <input type="hidden" name="step" value="0">
            <input type="submit" value="Send Another SMS">
        </form>

        <?php
    
}

    include(
"includes/footer.php");
?>