tbener
08-23-2006, 05:04 AM
hi,
i'm trying to send mail from the web site.
what host should i provide???
on the Account Management it says:
SMTP Server: smtp.mysite.com
this is it?
this is my code:
[quote]
Dim mailSmtp As New SmtpClient
Try
mailSmtp.Host = "smtp.mysite.com"
mailSmtp.Send("my site", "somemail@mail.com", "Subject", "Message")
RetMsg = "Message sent"
Return True
Catch ex As Exception
RetMsg = "Could not send message (Error:" & ex.Message & ")"
Return False
End Try</CODE>
the error i get is: Mailbox name not allowed. The server response was: sorry, relaying denied from your location [some ip address](#5.7.1)
p.s. This same code works on my localhost, providing the IP of the mail server of my network as the SMTP Host.
Thanks.
vvsharma
08-23-2006, 06:54 AM
You will have to use your 'localhost' to send mails from within your application.DASP does not let you use its smtp servers for this purpose to avoid any kind of abuse.Your site smtp servers are only used for your mail clients.
Vikram
DiscountASP.NET
www.DiscountASP.NET (http://www.discountasp.net/)
Buzzmaster
08-24-2006, 02:44 AM
Wait a second. Everything was working fine yesterday morning with emails...
No change to code...
Now out of the blue I am getting the following error...
[quote]
Timestamp: 8/23/2006 10:37:26 PM
Message: HandlingInstanceID: ebdaeb5b-785c-4117-862b-ef6503fdae0a
An exception of type 'System.Net.Mail.SmtpException' occurred and was caught.
-----------------------------------------------------------------------------
08/23/2006 15:37:26
Type : System.Net.Mail.SmtpException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication needed Source : System Help link :
StatusCode : MustIssueStartTlsFirst
Data : System.Collections.ListDictionaryInternal
TargetSite : Void CheckResponse(System.Net.Mail.SmtpStatusCode, System.String)
Stack Trace : at System.Net.Mail.MailCommand.CheckResponse(SmtpStat usCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at EmailUtils.SendMail(String toAddress, String toName, String fromAddress, String fromName, String subject, String body, Boolean isHtml, String ccAddress, String ccName, String bccAddress, String bccName, String[] attachments)
at Scheduled_Tasks_ProcessEmailTransactions.ProcessEm ailTransctions()</CODE>That's not nice!!!
Web.Config.... (of course my site data has been ixnayed here)
[quote]
<system.net>
<mailSettings>
<smtp from=administrator@mysite.com>
<network host="smtp.mysite.com" userName=administrator@mysite.com password="myPassword"/>
</smtp>
</mailSettings>
</system.net></CODE>And finally here is the code (a simple public shared method)...
[quote]
Public Shared Sub SendMail(ByVal toAddress As String, ByVal toName As String, _
ByVal fromAddress As String, ByVal fromName As String, _
ByVal subject As String, ByVal body As String, _
Optional ByVal isHtml As Boolean = False, _
Optional ByVal ccAddress As String = "", _
Optional ByVal ccName As String = "", _
Optional ByVal bccAddress As String = "", _
Optional ByVal bccName As String = "", _
Optional ByVal attachments() As String = Nothing)
Try
Dim message As MailMessage = New MailMessage()
Dim client As SmtpClient = New SmtpClient()
' From (maditory)
message.From = New MailAddress(Trim(fromAddress), Trim(fromName))
' To (maditory)
message.To.Add(New MailAddress(Trim(toAddress), Trim(toName)))
' CC (if applicable)
If Not ccAddress = "" Then
message.CC.Add(New MailAddress(Trim(ccAddress), Trim(ccName)))
End If
' Bcc (if applicable)
If Not bccAddress = "" Then
message.Bcc.Add(New MailAddress(Trim(bccAddress), Trim(bccName)))
End If
' Set final email property values (all maditory)
message.Subject = subject
message.Body = body
message.IsBodyHtml = isHtml
' Send it (HOST SHOULD BE SET IN CONFIG)
client.Send(message)
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Support Exception Policy")
If (rethrow) Then
Throw
End If
End Try
End Sub</CODE>This has been working for months now... Why did it suddenly stop. My email has already been migrated and all that jazz.. Any ideas?
Bz
Post Edited (Buzzmaster) : 8/24/2006 2:47:07 PM GMT
bruce
08-24-2006, 07:13 AM
We always recommend our user to use "localhost" to relay email from the web application.
Using SMTP.domain.com should never worked.
Change
<network host="smtp.mysite.com" userName=administrator@mysite.com password="myPassword"/>
to
<network host="localhost"/>
Bruce
DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)
Buzzmaster
08-24-2006, 07:28 AM
Thanks Bruce.
I tried that a few times and it didn't work. Got the same error.
I used the NEW IIS Tools, Start/ Stop and Recycle App Pool and I was in business, it worked.
Many thanks,
BZ
vBulletin® ©Jelsoft Enterprises Ltd.