open
https://gitlab.synchro.net/main/sbbs/-/work_items/1385
## Summary
`send_netmail()` in `exec/load/shell_lib.js` throws a `TypeError` when it is called with an address, so the address is never added to the user's netmail address history. The SDOS shell's `NETMAIL [address]` command is the one caller that passes an address.
## Cause
`addr_list` is declared and assigned only inside the `if(!addr)` block:
```js
if(!addr) {
console.putmsg(bbs.text(bbs.text.EnterNetMailAddress));
var addr_list = userprops.get(ini_section, "address", []) || [];
...
}
if(bbs.netmail(addr.split(','), wm_mode)) {
var addr_idx = addr_list.indexOf(addr); // addr_list is undefined here
```
When `addr` is passed in, `addr_list` is hoisted but `undefined`, and `addr_list.indexOf()` throws once `bbs.netmail()` has returned true.
## Effect
- `exec/sdos.js`: `NETMAIL
someone@example.com` sends the message, then the script errors. The address is not saved to the `[netmail sent]` history in the user's properties, and the user sees a JavaScript error instead of returning to the prompt cleanly.
- Calls without an address (`email_sec.js`, `simple.js`, `major.js`, `renegade.js`) are not affected.
Introduced by a4c720b86d (addressing-30-bingo, 2026-04-08), which added the optional address argument; before that the history was always read first.
## Fix
Read the history before the `if(!addr)` block, so it is defined on both paths:
```js
var addr_list = userprops.get(ini_section, "address", []) || [];
if(!addr) {
console.putmsg(bbs.text(bbs.text.EnterNetMailAddress));
addr = console.getstr(256, K_LINE | K_TRIM, addr_list);
...
```
Related: #159 (netmail sent outside this function, e.g. from the message reader, never updates the history at all).
- *Authored by Claude (Claude Code), on behalf of @rswindell*
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)