diff --git a/README.md b/README.md
index ff57498..fd7e720 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,7 @@ be available in the PATH:
* [bash](https://www.gnu.org/software/bash/bash.html)
* [curl-impersonate](https://github.com/lwthiker/curl-impersonate), **or**
* [Docker](https://www.docker.com/)
+ * [gawk](https://www.gnu.org/software/gawk/gawk.html) (gawk)
* [HTML Tidy](https://www.html-tidy.org/) (tidy)
* [XMLStarlet](https://xmlstar.sourceforge.net/) (xmlstarlet)
* a sendmail-compatible MTA (sendmail)
@@ -48,8 +49,12 @@ Set `warnlimit` to the dollar amount below which an warning e-mail will be
sent when the script is run. `lowmail` must be set to `yes` for an e-mail to
actually be sent.
+Set `expirydays` to the number of days before expiry of the balance after which a
+warning e-mail will be sent. This defaults to 7. `lowmail` must be set to `yes`
+for an e-mail to actually be sent.
+
Set `lowmail` to `yes` to have the script send an e-mail whenever the balance
-goes below `warnlimit`.
+goes below `warnlimit` or the expiry date is within `expirydays`.
Set `alwaysmail` to `yes` to have the script send an e-mail every time it is
run, regardless of the limit. Leave it blank to only mail below the warning
diff --git a/speakout-account-info b/speakout-account-info
index f6c7f92..d52176e 100755
--- a/speakout-account-info
+++ b/speakout-account-info
@@ -35,6 +35,7 @@ account=
password=
recipient=
warnlimit=0
+expirydays=7
alwaysmail=
lowmail=
quiet=
@@ -147,9 +148,23 @@ As of $(date), the balance remaining on the cellular number $NICEPHONENUM is
\$$BALANCE which expires $EXPIRY.
EOF
+if awk -F/ -v EXPIRYDAYS="$expirydays" '{exit mktime($3 " " $1 " " $2 " 00 00 00") - systime() >= EXPIRYDAYS * 24*3600}' <<< "$EXPIRY"; then
+ readonly TIMEEXCEEDED=yes
+ cat >>"$CONTENTFILE" <This is expiring within $expirydays days!
+EOF
+else
+ readonly TIMEEXCEEDED=
+fi
+
if [[ -n "$LIMITEXCEEDED" ]]; then
cat >>"$CONTENTFILE" <This is below the warning threshold of \$$warnlimit!
+EOF
+fi
+
+if [[ -n "$LIMITEXCEEDED" || -n "$TIMEEXCEEDED" ]]; then
+ cat >>"$CONTENTFILE" <
Add more money to your account now by
choosing an amount here.
@@ -162,7 +177,7 @@ cat >>"$CONTENTFILE" <