Forum Moderators: open

Message Too Old, No Replies

Why is My Mailer Failing?

         

yisraelharris

9:03 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



I wish to generate an email but I receive an error message.

My code:

set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress= "name@domain.com"
Mailer.RemoteHost = "mail.example.com"
Mailer.AddRecipient "nickname", "name@domain.com"
if Mailer.SendMail then
Response.Write "Mail sent..."
else
Response.Write "Failure:" & Mailer.Response & ". "
end if
set Mailer = nothing

I get the following error message: Failure:503 5.5.1 Incorrect command sequence.

I would be grateful for solutions.

Please note:
1. I got the same error message even when I assigned the subject and bodyText.
2. Regarding the order of assigning the FromAddress, RemoteHost and AddRecipient fields, I tried all 6 possible orders, and got the same error message each time.

[edited by: tedster at 11:44 pm (utc) on Jan. 3, 2004]

Dreamquick

9:34 pm on Jan 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could it be because you're not setting either the subject or the body? Here's an example I found elsewhere (it even came complete with the ubiquitous widget reference).

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "widgets-r-us"
Mailer.FromAddress= "joe@widgets.example.com"
Mailer.RemoteHost = "<your mailserver>"
Mailer.AddRecipient "John Smith", "jsmith@consumer.example.com"
Mailer.Subject = "Your widgets..."
Mailer.BodyText = "Your widgets order has been processed!"
If Mailer.SendMail then
Response.Write "Mail sent..."
Else
Response.Write "Mail send failure. Error was " & Mailer.Response
End If
Set Mailer = Nothing

- Tony

txbakers

11:35 pm on Jan 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just checked my code for this and Tony is probably right. The syntax looks good, but without a body or subject it might not send. Here is my syntax of the same mailer:

set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Request.Form ("name")
Mailer.FromAddress= Request.Form("email")
Mailer.RemoteHost = "mail.mydomain.com"
Mailer.AddRecipient "My Name","myaddress@mydomain.com"
Mailer.Subject = "Forms Registration"
strMsgHeader = "Form Information Follows: " & vbCrLf
for i = 1 to Request.Form.Count
strMsgInfo = strMsgInfo & Request.Form.Key(i) & " - " & Request.Form.Item(i) & vbCrLf
next
strMsgFooter = vbCrLf & "End of form information"
Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter
Mailer.SendMail
set Mailer = nothing

This one just takes the form data and mails it to me.

yisraelharris

5:52 am on Jan 4, 2004 (gmt 0)

10+ Year Member



If you look at my original post again, you'll see that I wrote the following:

Please note:
1. I got the same error message even when I assigned the subject and bodyText.

txbakers

6:11 am on Jan 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you look at my original post again

Yes, I saw what you said, but I can't see anything wrong in your syntax for the mailer. You didn't post the code for the body or subject, so it could be that syntax is not correct.

There could also be other VBscript errors in your code which cause it not to function.

Without looking at everything you wrote (please don't post the whole file here) we can only help you to a point.

yisraelharris

8:13 am on Jan 4, 2004 (gmt 0)

10+ Year Member



Here is my code, with the subject and bodyText. It gave the same error:

set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress= "name@domain.com"
Mailer.Subject = "hi"
Mailer.BodyText = "hi"
Mailer.RemoteHost = "mail.example.com"
Mailer.AddRecipient "nickname", "name@domain.com"
if Mailer.SendMail then
Response.Write "Mail sent..."
else
Response.Write "Failure:" & Mailer.Response & ". "
end if
set Mailer = nothing

(Just so you know, if the problem would have been my omitting the subject and/or bodyText, then the error message would have been different. I say this because when I had the exact same code as above but omitted the FromAddress field, I got a different error message, telling me that FromAddress is a required field.)

txbakers

4:17 pm on Jan 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't have a line for "FromName"

Also, since your error relates to command sequence, I would duplicate the exact sequence Tony and I are using:

Mailer.FromName
Mailer.FromAddress
Mailer.RemoteHost
Mailer.AddRecipient
Mailer.Subject
Mailer.BodyText

Maybe that will help. Who knows.

yisraelharris

4:42 pm on Jan 4, 2004 (gmt 0)

10+ Year Member



Thanks for your time. It turns out that the remotehost had an incorrect value. Working fine now.