# Replace email-to-text alerts in your scripts

Still emailing a carrier gateway to text yourself? Send the same alert to your own phone with one HTTP request. Includes Python and curl examples, with 10 free texts a month.

## 1. Keep the alert, replace the email call

AT&T shut down email-to-text on June 17, 2025. Verizon says its Vtext and VZWPix shutdown is underway and expected to finish by March 31, 2027; some senders may lose access sooner. The carrier notices are linked below.

If you control the script, replace the SMTP call to your carrier's email address with a SelfPing API request. Your scheduler and the condition that triggers the alert can stay as they are.

SelfPing sends only to the verified phone that created the key. It does not provide an email inbox or forward incoming email. An email-only device needs a separate bridge, and this guide does not cover texting customers or other recipients.

## 2. Get your free key

Sign in with your phone number and copy your API key from the dashboard. Save it as SELFPING_API_KEY in the environment where your script runs. Keep it out of source control and logs.

The free plan includes 10 texts a month. Hobby is $5/month for 100. Each send uses one credit. Choose a short alert that tells you what happened and where to investigate.

## 3. Replace the send in Python

Save this helper as selfping_alert.py. It uses Python's standard library and sends only when called. In the branch that used to email your phone, call text_myself with a short summary.

The helper returns False if the request fails and does not retry automatically. A timeout can leave delivery uncertain. Keep your job's existing success or failure status independent of the notification result.

selfping_alert.py:

```python
import json
import os
import sys
from urllib.error import HTTPError
from urllib.request import Request, urlopen


def text_myself(message):
    key = os.environ.get("SELFPING_API_KEY")
    if not key:
        print("SMS skipped: set SELFPING_API_KEY first.", file=sys.stderr)
        return False
    request = Request(
        "https://www.selfping.com/api/sms",
        data=json.dumps({"message": message[:160]}).encode("utf-8"),
        headers={
            "Authorization": f"Bearer {key}",
            "Content-Type": "application/json",
        },
        method="POST",
    )
    try:
        with urlopen(request, timeout=10) as response:
            accepted = response.status == 200
        if accepted:
            print("SMS accepted. Check final delivery in the SelfPing dashboard.")
        return accepted
    except HTTPError as error:
        print(f"SMS rejected: HTTP {error.code}.", file=sys.stderr)
    except Exception:
        print("SMS unconfirmed. Check the dashboard before retrying.", file=sys.stderr)
    return False
```

Inside your existing alert condition:

```python
from selfping_alert import text_myself

text_myself("Backup failed. Check the backup log before the next run.")
```

## 4. Or send from a shell script

With SELFPING_API_KEY set, this command sends one text and uses one credit. Run it only when you are ready to test delivery. For messages assembled from variables, use a JSON encoder as in the Python example.

Send one alert:

```bash
curl --fail-with-body --connect-timeout 5 --max-time 15 \
  https://www.selfping.com/api/sms \
  -H "Authorization: Bearer $SELFPING_API_KEY" \
  --json '{"message":"Backup failed. Check the backup log before the next run."}'
```

## 5. Check the first delivery before switching over

Test one alert, check that it reaches your phone, and confirm the final delivery status in the dashboard. An accepted API request is not proof that the text arrived. After verification, remove the old carrier-email send so each event triggers only one notification.

If you do not receive the text, check the API key, remaining credits, and delivery status. Keep passwords, private records, and full log output out of the message. For a complete command wrapper with cron setup, follow the Python and cron recipe linked below.

## References

- [AT&T shutdown notice](https://www.att.com/support/article/wireless/KM1061254/)

- [Verizon shutdown notice](https://www.verizon.com/support/vtext-vzwpix-shutdown/)

- [Python urllib.request](https://docs.python.org/3/library/urllib.request.html)

- [Python and cron alerts](/recipes/python-cron-alert)

- [Runnable examples](https://github.com/br-schneider/selfping-examples)

- [Pricing](https://www.selfping.com/pricing)