Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi i have a program that can send email using smtp. I've tried to use smtp.gmail.com as the server host and my program totally work. But When I try to use smtp from mandrillapp.com which is smtp.mandrillapp.com I've got an error that says "Relay Access Denied". Is anyone here would like to help me in this problem?
I have already this code:


Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()

If txtFrom.Text = "" Or txtBody.Text = "" Or txtPwd.Text = "" Or txtSubject.Text = "" Or txtTo.Text = "" Then
MsgBox("Fill Data Correctly")
Exit Sub
End If

' SMTP server setting .
SmtpServer.Credentials = New Net.NetworkCredential(txtFrom.Text, txtPwd.Text)
SmtpServer.Port = 587
SmtpServer.Host = "smtp.mandrillapp.com"

' Code To Validate The from EMailID
Dim emailExpression As New Regex("^[_a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$")
If Not emailExpression.IsMatch(txtFrom.Text) Then
MsgBox("EMail Id is Not Correct", MsgBoxStyle.Exclamation, "Validation for EMail ID")
txtFrom.Focus()
Exit Sub
End If

mail = New MailMessage()
mail.From = New MailAddress(txtFrom.Text)

' Code To Add Receipants EMail ID's

Dim Toaddr As String = txtTo.Text
Dim i As Integer
Try
For i = 0 To Toaddr.Length - 1
If Not emailExpression.IsMatch(Toaddr) Then
MsgBox("EMail Id is Not Correct", MsgBoxStyle.Exclamation, "Validation for EMail ID")
txtTo.Focus()
Exit Sub
End If
mail.To.Add(Toaddr)
Next
Catch ex As Exception
End Try

Try
Dim Attach() As String = txtAttachements.Text.Split(",")
Try
For i = 0 To Attach.Length - 2
Dim atach As New Attachment(Attach(i))
mail.Attachments.Add(atach)
Next
Catch ex As Exception
End Try
Catch ex As Exception
End Try
mail.Subject = txtSubject.Text
mail.Body = txtBody.Text
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
MsgBox("Mail send Successfully ", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.ToString)
End Try

Any help would be greatly appreciated.
Thanks
Posted
Updated 19-Jul-13 10:02am
v2
Comments
ZurdoDev 19-Jul-13 16:12pm    
No one here can help because Access is denied means you need to talk with the admin and find out how to connect.
Sergey Alexandrovich Kryukov 19-Jul-13 16:30pm    
Ask mandrillapp representatives. Probably, they don't relay...
—SA

1 solution

"Relay access denied" means that you're trying to use their server to send an email using code outside of their network. The way the server is configured right now means that you cannot use that server with your application.

The only people who can help you with this problem are the people who own the server you're trying to use. We can't help you with this because we don't have admin access to that server.

There is nothing you can do in your code to change this situation.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900