# How to check email addresses in Unix

**URL:** https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982
**Category:** Factual Questions
**Created:** [March 29, 2001, 3:55pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982 "2001-03-29T15:55:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kaotic\_Newtral](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@Kaotic\_Newtral](https://boards.straightdope.com/u/Kaotic_Newtral)
#### Post date: [March 29, 2001, 3:55pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982/1 "2001-03-29T15:55:44Z")

</div>

All,

I’m trying to write a shell-script that’ll check all the email addresses in our databases to make sure that they’re deliverable. I’ve tried ‘sendmail -bv [user@host.com](mailto:user@host.com)’ but no matter what, it says the address is deliverable. The other options, mail and mailx don’t seem to have an option at all.  
Any help? Thanks. This is on Solaris 2.7.

---

<div class="post-metadata">

### Author: ![Kaotic\_Newtral](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@Kaotic\_Newtral](https://boards.straightdope.com/u/Kaotic_Newtral)
#### Post date: [March 30, 2001, 1:30pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982/2 "2001-03-30T13:30:27Z")

</div>

I’ve checked other boards,books and called a few friends no answer seems in sight. Are there any guru’s out there?

---

<div class="post-metadata">

### Author: ![Zyada](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zyada/32/3028_2.png) [@Zyada](https://boards.straightdope.com/u/Zyada)
#### Post date: [March 30, 2001, 4:49pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982/3 "2001-03-30T16:49:16Z")

</div>

I don’t think the task can be done the way you want it to be done.

Since you are testing for email addresses that are external to your system, unix has to send the email out for delivery. What you will get back immediately is that unix was able to hand the mail over to the internet. If the mail is undeliverable, the sender will eventually get an email to that effect.

What you probably need to do is get a process to trap/parse those emails and communicate back to the database which email addresses are bad. That I don’t know how to do.

[sup]I sincerely hope you aren’t doing this to spam people[/sup]

---

<div class="post-metadata">

### Author: ![Bobort](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@Bobort](https://boards.straightdope.com/u/Bobort)
#### Post date: [March 30, 2001, 5:21pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982/4 "2001-03-30T17:21:06Z")

</div>

Theoretically, the way to do this is to connect to the remote mail server and use the VRFY SMTP command to check the address. Unfortunately, most mail servers don’t respond in any useful way to VRFY. Some will respond in the affirmative to pretty much any syntactically valid address at their domain. Some just don’t allow you to VRFY anything.

The only way to really know whether an address is valid is to send mail to it and see what happens.

---

<div class="post-metadata">

### Author: ![Kaotic\_Newtral](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@Kaotic\_Newtral](https://boards.straightdope.com/u/Kaotic_Newtral)
#### Post date: [March 30, 2001, 6:38pm UTC](https://boards.straightdope.com/t/how-to-check-email-addresses-in-unix/59982/5 "2001-03-30T18:38:51Z")

</div>

> [@](#):
>
> \*Originally posted by Zyada \*  
> \*\*  
> [sup]I sincerely hope you aren’t doing this to spam people[/sup] \*\*

I’m not doing this for spam. My databases have become filled with invalid email addresses. I’m just trying to find a way to clean these out without going through a costly manual routine.

Thanks for the responses. I didn’t think it would be easy to do.
