Link to home
Start Free TrialLog in
Avatar of ghelaniabhishek
ghelaniabhishek

asked on

VB Script to send email giving error

I am tring to test a script that sends emails.
I have written following code,

It gives me following error:

The server rejected one or more recipient addresses. The server response was: 454 4.7.1 <xxx@xxx.com>: Recipient address rejected: Access denied.

Now, if I run this same script from a different server, it works fine. This means the smtp server I have mentioned is not blocking anything.

Can somebody please help?
Const FOF_CREATEPROGRESSDLG = &H0&
strServer = "mail.server.com"
strTo = "xxx@xxx.com"
strFrom = "xxx@xxx.com"
strSubject = "Test Mail"
Set objMessage = CreateObject("CDO.Message")
strText = "Test mail "
objMessage.To = strTo
objMessage.From = strFrom
objMessage.Subject = strSubject
objMessage.TextBody = strText
 
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer
'Server port (typically 25)
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25      
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send

Open in new window

Avatar of JoeNuvo
JoeNuvo
Flag of Viet Nam image

one simple thing to check is the antivirus setting.
some antivirus software will include the e-mail check/blocking. (POP3/SMTP etc).
Avatar of Ian Pattison
I would think that the SMTP server you are connecting to has relay restrictions applied, which means that certain IP addresses are allowed to send to anyone, however, the server you are trying to connect from is restricted.

I'd check the SMTP connector settings on the server you're connecting through.

As you are getting an SMTP response (albeit an error), I doubt AV settings are getting in the way.
Avatar of ghelaniabhishek
ghelaniabhishek

ASKER

doesnt seem to be antivirus issue. Have chekced, its blocking nothing.

Regarding SMTP server blocking, I doubt about this, since the same script with same SMTP server name works fine from my other machines. Its just one machine where the script is giving error.

some setting on my machine where script is failing needs to be changed or loocked at, not sure what.
Try telnetting to the SMTP server from the problematic machine, and perform the same script functions (i.e., Issue Helo, MailFrom, RcptTo etc commands).

If you get the same knock back using Telnet, then it's the SMTP server not your source server with the problem.

An SMTP restriction can apply to a specific ip address... just becuase it works elsewhere doesn't mean it's the Source server that is at fault, nor the script (as you've proved that works).
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial