Knowledgebase › Voicemail-to-email when it never arrives — DKIM/SPF, msmtp, sendmail tracing

Voicemail-to-email when it never arrives — DKIM/SPF, msmtp, sendmail tracing

Voicemail-to-email is one of those features that "just works" until your VPS IP changes, or your mail relay swaps, or a major email provider tightens its filters. Then the voicemail records fine, the file is in the spool, but the recipient never gets the email. This article walks the diagnosis.

Step 1 — Confirm voicemail itself works

Before chasing mail, verify the voicemail recorded:

ls -la /var/spool/asterisk/voicemail/default/<extension>/INBOX/

If there's a recent .wav and .txt, voicemail is fine and the problem is purely mail delivery. If there's nothing, the voicemail itself isn't recording — different problem (extension config, mailbox setup, MoH issues).

Step 2 — Check what Asterisk tried to send

tail -200 /var/log/asterisk/full | grep -i email
tail -200 /var/log/asterisk/messages

You're looking for lines like:

VERBOSE[12345] app_voicemail.c: Sending email for mailbox 1001
VERBOSE[12345] app_voicemail.c: Message length 12 seconds, attached

If Asterisk didn't try to send, the mailbox is missing an email address. Check /etc/asterisk/voicemail.conf:

[default]
1001 => 1234,Front Desk,frontdesk@example.com

That third field is the email. If missing, no email gets sent.

Step 3 — Check the local mail queue

Asterisk pipes the email to whatever mailcmd is configured (default /usr/sbin/sendmail -t). The receiving MTA queues it.

If you're running sendmail or postfix locally:

# Postfix
mailq
postqueue -p

# Sendmail
mailq

# Look at the most recent mail log entries
tail -200 /var/log/mail.log

You're looking for:

  • "sent" or "queued" — mail accepted by the MTA. Move to step 4.
  • "bounced" or "deferred" — the MTA tried to deliver and failed. Note the reason.
  • Nothing — Asterisk's mail wasn't received by the MTA. sendmail binary missing or wrong path.

Step 4 — If the MTA bounced

Common bounce reasons:

  • "Sender address rejected: Domain not found." Your "From:" address uses a domain that doesn't exist (or your DNS resolver can't see). Fix the From address in Voicemail settings.
  • "550 5.7.1 SPF check failed." Your VPS IP isn't in the SPF record of the From domain. Either fix SPF (see Mail prerequisites) or use a From address you control.
  • "550 5.7.0 DKIM-Signature signature verification failed." The receiving server requires DKIM and yours is broken or missing.
  • "Connection timed out." Outbound port 25 is blocked. Switch to relaying through a smart host (see step 5).
  • "550 5.7.1 ... blacklisted." Your IP is on a public RBL. See Your IP got blacklisted.

Step 5 — Relay through a smart host

Direct outbound mail from a generic VPS IP is brittle. Relaying through a mail service (Mailgun, Postmark, Amazon SES, or even Gmail/G-Suite) almost always solves "voicemail email isn't arriving" permanently:

Use msmtp as the smart-host relay:

apt install msmtp msmtp-mta
# Or: dnf install msmtp

/etc/msmtprc:

defaults
auth on
tls on
tls_starttls on
logfile /var/log/msmtp.log

account default
host smtp.mailgun.org
port 587
user postmaster@<your-domain>
password <your-mailgun-smtp-password>
from voicemail@<your-domain>

Set permissions:

chmod 600 /etc/msmtprc
chown asterisk:asterisk /etc/msmtprc

Then point Asterisk's mailcmd at msmtp. In FreePBX®:

  • Settings → Voicemail Admin → Settings → Email Config → mailcmd = /usr/bin/msmtp -t

Or directly in voicemail.conf:

[general]
mailcmd=/usr/bin/msmtp -t

Reload Asterisk. Test by leaving a voicemail.

Step 6 — Verify delivery

tail -f /var/log/msmtp.log

Look for a successful SMTP exchange. The msmtp log is more helpful than the Asterisk log for this layer.

Then check the recipient inbox. Check spam, too — first emails from a new sender often spam-folder.

Common gotchas

  • Asterisk runs as the asterisk user. Make sure that user can read /etc/msmtprc and write to msmtp's log.
  • FreePBX overrides voicemail.conf. Edit through the GUI for persistent changes, or use voicemail.conf.custom for additions FreePBX won't overwrite.
  • From: address must be deliverable. Some receivers reject mail with From: addresses that don't have a valid MX. Use an address at a domain you actually own.
  • Attachment size limits. Long voicemails can exceed receiver size limits. Compress with format=wav49 (G.726 in WAV container, smaller files at acceptable quality).

Also Read

« « Back

Powered by WHMCompleteSolution