i am using for send mail my smtp server is "xxx.xx.x", its working fine. But now i am changing the mail server for emails. i am using new mail smtp server ip address is "xxxxxxx.xxx.xxx", in this case get the error like "The server rejected one or more recipient addresses. The server response was: 554 5.7.1 : Client host "
i am using the bellow code
Dim eMail As MailMessage = New MailMessage
eMail.To = "xxxxxxx"
eMail.BodyFormat = MailFormat.Html
eMail.From = "xxxxxxxx"
eMail.Subject = "intermedia mail test using 127.0.0.1"
eMail.Body = sMsg
SmtpMail.SmtpServer = "xxxxxxx 'AppSettings("MailServer")
SmtpMail.Send(eMail)
Thanks in advance
You are getting this error because the mail server is configured to only send mail from certain domains or the client is not in its list of accepted senders.
You need to get in touch with the mail server administrator and ask them to allow the IP address of the machine that the application resides on or send the mail using an address in the correct domain.
http://www.ietf.org/rfc/rfc1893.txt
Related
I have a website hosted through IIS and want to have an include . In that testfile.aspx I want to get the IP address of the client and redirect based off of requirements. However when I try to get the ip address I am given the ip of the machine my website is being hosted on and not the user
How to get a user's client IP address in ASP.NET?
I have tried all the methods in the link above and they all return the ip address of the host machine. Ive tried the code in the include page as well as the code behind of a sample test page and it still does not work.
Version 1
Dim ipAdd As String
ipAdd = Request.ServerVariables("REMOTE_ADDR")
ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('This is your ip " & ipAdd & "');", True)
Version 2
ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('This is your ip " & Request.UserHostAddress & "');", True)
Both those methods return the public ip of my IIS web server
It seems the client IP address is being translated somewhere in the data path on its way to your application, for example by a proxy, NAT, or load balancer.
You need to figure out where and configure it to retain the original IP address in the x-forwarded-for header. Modern network appliances all have this option.
Without the original IP address being forwarded, it is not possible your code to retrieve it from any API. You can't read what you don't have.
I use this in a class file to get the UserHostAddress, which is the IP address of the connecting client:
string sUserHostAddress = HttpContext.Current.Request.UserHostAddress;
I am working with WebForms and there I can use this to get it in the code behind file:
string sUserHostAddress = Request.UserHostAddress;
Hope this helps.
EDIT:
I have put a page on my website where you can see the result.
Check your IP address
I have a Windows Server 2003 R2 running IIS and a website using classic ASP.
Trying to get it to use CDOSYS to email using our own (externally) hosted office365 exchange server.
I get the following error
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
Which usually means one of 3 problems:
1. Incorrect SMTP server / port
2. Incorrect login/password
3. FROM address not valid according to SMTP server (wrong domain)
The SMTP server and port are correct according to supplier.
The login/password is correct as I can log into the mail account using those details
The FROM address is correct as that is the account I am using to log in.
I can telnet to the exchange server from the web server on that address and port, so a connection can be made from the server at least.
So at the moment I'm at a loss as to what the problem might be.
Does anyone have any pointers as to anything else I need to look at?
This is the config the website is using
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
Did you setup an SMTP relay in Office 365?
From the Office 365 Admin go to:
Admin > Exchange
Mail Flow > Connectors
Click add new SMTP relay connector
Select from "your organization's email server" to "office 365"
Give the connector a name and description
Select verify by IP address and add your web server IP
Save
Try Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
With Office 365, cdo seems to prefer port 25, even when using authentication.
Here's a tried and tested configuration if it helps
Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
.Update
End With
objMail.Configuration = iConfg
Try
.Item("http://schemas.microsoft.com/cdo/configuration/smtpsendtls") = 1
instead of
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
Well I eventually got this solved.
I needed to use a different method of connecting to the office365 server.
So all is working as it should now.
I have a code for sending mail using SMTP settings in asp.net. That code is working well on live but when i am testing the same on localhost. It shows the error:
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc.xyz.com
I know this is some configuration related error, but i don't know exactly what i need to change to test the same on localhost. I have defined these attributes for SMTP:
smtp.Host = "abc.server.net";
smtp.Port = 123;
smtp.EnableSsl = false;
fromEmail="any email";
password="password"
Any help would be appreciated.
You have to configure relay restrictions in the IIS admin. see this article
try this
Open IIS Manager using Control Panel --> Administrative Tools.
Open SMTP Virtual Server properties.
On General tab, Set IP address of the Web server instead of "All Unassigned".
In Access tab, click on Relay button, this will open Relay Restrictions dialog.
In relay computers list, add the loopback IP address i.e 127.0.0.1 and IP address of the Web server, so that they can pass/relay emails through the SMTP server.
source : SO
I am trying to send an email using a simple button in asp.net. But I am getting following error-"The transport failed to connect to the server".
SmtpMail.SmtpServer = "localhost";
I've used localhost because,I don't know smtp server name of my computer..
how can i fix it? how can I know the SMTP server name?? My os is win xp
hope someone can help me...
To test email locally set up a drop folder called 'maildrop' on your C:\ drive and add the following to your Web.Config file:
<system.net>
<mailSettings>
<smtp deliveryMethod='SpecifiedPickupDirectory'>
<specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" />
</smtp>
</mailSettings>
</system.net>
ASP.NET: Using pickup directory for outgoing e-mails
UPDATE:
You should be using the newer email library...
using System.Net.Mail;
MailMessage msg = new MailMessage();
msg.To = "sudheej.j800#outlook.com";
msg.From = "sudheej.j800#gmail.com";
msg.Subject = "hi";
msg.Body = "yes";
SmtpClient smtpClient = new SmtpClient("localhost");
smtpClient.Send(msg);
Standard SMTP runs on port 25. If you don't have anything listening on port 25 on your machine, then you likely don't have an SMTP server running. Try:
telnet localhost 25
and see if that connects to something. I ssupect not (i.e. you don't have an SMTP server on localhost)
You need a SMTP server on your machine before do that.
I am using cdo to send email the following code fails
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "localhost"
.Update
End With
When I send an email I get the following error
8004020f
I then changed the code to the following:
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPickup
.Item(cdoSMTPServer) = "localhost"
.Update
End With
The email sends without a problem. What steps could I take to troubleshoot why cdoSendUsingPort is not working?
With cdoSendUsingPort, CDO tries to open a connection to the SMTP server you specify (in your case, localhost) on TCP port 25. I guess you're not running an SMTP server on your machine, so nothing is listening on port 25 and the call fails.
With cdoSendUsingPickup, CDO forwards the message to the pickup directory of your local IIS instance for later processing. I guess you have IIS installed on your machine and its SMTP module is configured to use pickup, so the call succeeds.
Professor Google finds (in order):
- Several options: server disallows anonymous relaying, server rejects specific recipient domains, recipient is rejected by SMTP server in unexpected way, and/or proxy or firewall settings are blocking the mail.
- Your mailserver is configured to not relay from your source machine.
- ... and several more things which boil down to the first link listed.
Some of these things you can test directly by telnet-ing from the sending machine to the mailserver, performing a normal SMTP interaction, and seeing what messages are displayed.