Try this code:
alias mail {
[color:red];------ SET THESE VALUES THEN CALL /mail -----
set %fromaddress from@email.com
set %toaddress to@email.com
set %subject This is the subject
set %body This is the body
var %host
;------[/color]
;
set %logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
set %sendstate 1
if ($sock(sendmail)) sockclose sendmail
write %logfile # Connect Attempt to
sockopen sendmail shawmail.ok.shawcable.net 25
}
;
on *:sockread:sendmail:{
var %temptext
sockread %temptext
tokenize 32 %temptext
write %logfile $asctime(HH:nn:ss) -> $1-
if ((%sendstate == 1) && ($1 == 220)) {
mailsockwrite HELO localhost
echo 3 -a HELO
inc %sendstate
}
elseif ((%sendstate == 2) && ($1 == 250)) {
mailsockwrite MAIL From: $+ %fromaddress
echo 3 -a MAIL
inc %sendstate
}
elseif ((%sendstate == 3) && ($1 == 250)) {
mailsockwrite RCPT To: $+ %toaddress
echo 3 -a RCPT
inc %sendstate
}
elseif ((%sendstate == 4) && ($1 == 250)) {
mailsockwrite DATA
echo 3 -a DATA
inc %sendstate
}
elseif ((%sendstate == 5) && ($1 == 354)) {
mailsockwrite Subject: %subject
mailsockwrite $crlf
mailsockwrite %body
mailsockwrite .
echo 3 -a SEND
inc %sendstate
}
elseif ((%sendstate == 6) && ($1 == 250)) {
mailsockwrite QUIT
echo 3 -a QUIT
inc %sendstate
}
elseif ((%sendstate == 7) && ($1 == 221)) {
sockclose $sockname
echo 3 -a DONE
}
elseif ((%sendstate < 0) && ($1 == 221)) {
sockclose $sockname
echo 4 -a DONE
}
else {
mailsockwrite QUIT
echo 4 -a ERROR: $1-
set %sendstate -1
}
}
;
alias mailsockwrite {
sockwrite -n $sockname $1-
write %logfile $asctime(HH:nn:ss) <- $1-
}
Note that I knew nothing about SMTP before I read this site:
http://www.opus1.com/www/presentations/emailproto/sld006.htmThe above code should cancel the send if there is an unexpected message from the server (ie. an error). You need to set the variables at the beginning of the /mail alias using your own code/dialogs/etc.. Everything after the ;----- in the /mail alias should remain the same. Once those variables are set, you call the /mail alias to send the email.
-genius_at_work