Creating an account and sending mail using applescript
Everything I've read (granted most of it, quite old) indicates that you need to include the words "smtp server" before "addsmtp", even though it should be quite obvious from the context.
There is also apparently a bug in the way AppleScript handles references to the new server.
Remove from the first set smtp server
to the end of the script, and replace with this:
set smtpservername to "smtp.mail.yahoo.com"
set smtpusername to "[email protected]"
set addsmtp to make new smtp server with properties {server name: smtpservername}
tell addsmtp
set authentication to password
set password to "ThePassword"
set uses ssl to true
set port to 465
set user name to smtpusername
end tell
set newsmtpserver to smtp server (smtpservername & ":" & smtpusername)
set smtp server of newacct to smtp server newsmtpserver
end tell