I do think there is a way to try to accomplish your needs here:
#!/usr/bin/bash
add_email_account(){
local email=$1
local password=$2
expect <<EOF
spawn devil mail account add $email
expect "Password:"
send "$password\r"
expect "Confirm password:"
send "$password\r"
expect eof
EOF
}
add_email_account admin@example.com password
I've tested it and it works fine.