michouis
asked on
Send Email to External Address ASP.Net IIS6
I have developed an ASP.Net Web Site (VB) and need to be able to send emails to external addresses. We are using an Exchange Server for email but it will not send to external addresses, only internal. What a pain. I installed the Virtual SMTP Server in IIS6 and specified our ISP in the Smart Host box in Delivery options. I also added 127.0.0.1 to Relay Restrictions to allow... No where can I find how the <Mailsettings> section of my web.config should be set to work with the virtual smtp server in IIS6. In my code, see below, what should I specify in place of our exchange server address? How do I get this to work??
Dim smtp As New SmtpClient("exchangeserveraddress")
What do I specify instead of "exchangeserveraddress" if I need to use the Virtual SMTP Server??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The actual solution was to run System Manager on our Exchange server and get to the SMTP Protocol ACCESS option and add the Web Server IP address as an allowed IP address for relaying messages... I do not want to place the hst and credentials in the web.config file... I set the host in the smart host box in my web server virtual smtp folder etc...
First to quickly answer your "exchangeserveraddress" question, you can provide the machine name if the server is accessible on LAN or fully qualified URL. However, it is always a recommended or good practice to provide IP Address of the server and also provide the port number using the overload constructor.
Check the code snippet which has been copied and modified from: http://www.systemnetmail.com/faq/4.2.aspx. Make sure the Network Credentials (User Name/Password) provided have appropriate account in Mail Server.
Further, some public web-based mail services such as Gmail allow to send emails using Gmail Accounts. For this purpose, you have to provide a little extra information to the SmtpClient object. Sample code for sending email from Gmail is also in snippet.
Open in new window