mIRC Home    About    Download    Register    News    Help

Print Thread
smtp mailer - confuzled #95495 25/08/04 09:59 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Otay first off the raw socket data from the socket
Quote:

220 comcast.net - Maillennium ESMTP/MULTIBOX rwcrmhc12 #72
HELO comcast.net
250 comcast.net
MAIL FROM: static@suprnovaradio.org
250 ok
RCPT TO: static@suprnovaradio.org
250 ok; [simple] forward to <static@suprnovaradio.org>
DATA
354 ok
X-Mailer: StaticSystems
FROM: static@suprnovaradio.org
TO: static@suprnovaradio.org
Subject: Testing
Hi this is a test
testing 1234
.
250 ok ; id=20040825081451014007o14se

Is the data I send to the stream.
Now heres my code I have.
Code:
alias sendmailcon { sockopen sendmail smtp.comcast.net 25 | set %mail.ok 1 }
on *:text:!mail reset:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    unset %mail.*
    sockclose sendmail
  }
  msg $chan Variables have been reset and mail is now deactivated!
  set %email.status off
}

on *:text:!mail send:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    if (%mail.from == $null) { msg $chan You need to set a sender address with !mail sender }
    if (%mail.to == $null) { msg $chan You need to set a person to receive the message with !mail rcpt }
    if (%mail.body.1 == $null) { msg $chan It helps if you have a message to send use !mail body }
    else { sendmailcon }
  }
}
on *:sockread:sendmail: {
  sockread %sendmail.msg
  if ($left(%sendmail.msg,3) == 220) {
    sockwrite -n $sockname HELO comcast.net
    sockwrite -n $sockname MAIL FROM: %mail.from

  }
  if ($left(%sendmail.msg,3) == 250) &amp;&amp; (%mail.ok == 1) {
    sockwrite -n $sockname RCPT TO: %mail.to
    inc %mail.ok
  }
  if ($left(%sendmail.msg,3) == 250) &amp;&amp; (%mail.ok == 2) {
    sockwrite -n $sockname DATA
    inc %mail.ok
  }
  if ($left(%sendmail.msg,3) == 354) {
    sockwrite -n $sockname X-Mailer: StaticSystems
    sockwrite -n $sockname FROM: %mail.from
    sockwrite -n $sockname TO: %mail.to
    sockwrite -n $sockname Subject: %mail.subject
    var %x = 1
    var %y = $var(%mail.body.*,0)
    :begin
    if (%x &lt;= %y) {
      sockwrite -n $sockname $eval($var(%mail.body.*,%x),2)
      inc %x
      goto begin
    }
    sockwrite -n $sockname .
  }
  if ($left(%sendmail.msg,3) == 250) &amp;&amp; (%mail.ok == 3) {
    sockwrite -n $sockname QUIT
    sockclose $sockname
    msg #static Mail Sent
    unset %mail.ok
    unset %sendmail.msg
  }
}
on *:text:!mail prepare:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == off) {
    msg $chan Email is ready to be setup
    set %email.status on
  }
  elseif ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    msg $chan Email is already in progress. If this is an error please !mail reset
  }
}
on *:text:!mail sender *:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    set %mail.from $3 | msg $chan From: $3
  }
}
on *:text:!mail rcpt *:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    set %mail.to $3 | msg $chan To: $3
  }
}
on *:text:!mail subject *:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    set %mail.subject $3- | msg $chan Subject: $3-
  }
}
on *:text:!mail body *:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    set %mail.body. $+ $calc($var(%mail.body.*,0) + 1) $3- 
    msg $chan Body Line ( $+ $var(%mail.body.*,0) $+ ) $3-
  }
}
on *:text:!mail verify:#: {
  if ($nick isin %admin.nicks) &amp;&amp; (%email.status == on) {
    msg $chan From: %mail.from
    msg $chan To: %mail.to
    msg $chan Subject: %mail.subject
    var %x = 1
    var %y = $var(%mail.body.*,0)
    :begin
    if (%x &lt;= %y) {
      msg $chan $eval($var(%mail.body.*,%x),2)
      inc %x
      goto begin
    }
  }
}

It just doesnt work no clue why. I got it to work once but now plbbs any clues?

Re: smtp mailer - confuzled #95496 25/08/04 12:01 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
If the email arrives but you just can't see the message itself, it would be a good idea to send an empty line after the headers:

...
sockwrite -n $sockname Subject: %mail.subject
sockwrite -n $sockname
...

Re: smtp mailer - confuzled #95497 25/08/04 09:08 PM
Joined: Feb 2003
Posts: 282
S
saragani Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
A thing that I have learned about some smtp servers is that if the socket is just closed after it timed out (it doesn't happened with all the servers), then message is not always sent.

After you have queued the email, send a "quit" to the server.


//EDIT: I see that your script has a "quit". In that case I have no idea what is the problem. If the email is queued then it should be sent my the server.

Re: smtp mailer - confuzled #95498 25/08/04 10:59 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
There's also an option of using an external command-line email sender as demonstrated in this thread.

Re: smtp mailer - confuzled #95499 26/08/04 12:13 AM
Joined: Dec 2002
Posts: 788
C
Coolkill Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Some mail servers require a correct syntax for RCPT TO: and MAIL FROM: lines
in the formats;

MAIL FROM: [color:red]<
user@isp.com>
RCPT TO: <user@isp.com>
[/color]

Failing that, although its wonderful you have done lots of checks to ensure the mail
is sent, perhaps you should start with the bare code, and then add it, heres a start.

on 1:sockread:smtp:{
sockread %a
echo -s Got: %a
}

The above outputs whatever socketname 'smtp' receives to your status window.

On *:Sockopen:smtp:{
sockwrite -n smtp HELO $host
sockwrite -n smtp MAIL FROM: <user@host.com>
sockwrite -n smtp RCPT TO: <user@host.com>
sockwrite -n smtp DATA
sockwrite -n smtp Subject: testing
sockwrite -n smtp hey whats up
sockwrite -n smtp .
sockwrite -n smtp quit
}

This just FORCES the data through, it does not check if its requested, or not, just
merely sends it all, edit 'user@host.com'

Also be aware most (99%) of mail servers will NOT forward, for example;

You cannot, connect to smtp.domain1.com and tell it to send an email
to user@domain2.com, you must connect to domain2.com
smtp server.

Also, if you have the misfortune of using AOL,
you yourself, cannot send an email to an AOL
email from your AOL IP.

Simply, do, /sockopen smtp smtpserver port (Default SMTP port is 25).

Eamonn.