| | |
SMTP server Unable to relay for [email]
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Aug 2009
Posts: 10
Reputation:
Solved Threads: 0
i am currently trying to configure a email sending function using an SMTP server.
when i send a mail to and from a person with the email extension of @dtss.com (The company employes) it works perfectly with attachments and everything
if i change the ToAddress to anything else (i.e. matthew@crimzone.com) it gives me this error: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for matthew@crimzone.com
ive search forums and turned relaying on, allow anonymous on authentification and enabled logging... it still doesnt work
this is the code:
the message details are determined in another method and that works fine. Username and password is null.
can anybody help? have i missed out something?
when i send a mail to and from a person with the email extension of @dtss.com (The company employes) it works perfectly with attachments and everything
if i change the ToAddress to anything else (i.e. matthew@crimzone.com) it gives me this error: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for matthew@crimzone.com
ive search forums and turned relaying on, allow anonymous on authentification and enabled logging... it still doesnt work
this is the code:
the message details are determined in another method and that works fine. Username and password is null.
C# Syntax (Toggle Plain Text)
public static void SendMailQ(MailMessage Message) { SmtpClient cli = new SmtpClient("172.16.252.8"); bool useAuth = false; string userName = string.Empty; string password = string.Empty; string authDomain = string.Empty; NetworkCredential cred = null; cli.UseDefaultCredentials = false; cli.UseDefaultCredentials = false; if (string.IsNullOrEmpty(authDomain)) { cred = new NetworkCredential(userName, password); } else { cred = new NetworkCredential(userName, password, authDomain); } cli.Credentials = cred; cli.Send(Message); //////bombs out here
can anybody help? have i missed out something?
Last edited by John A; Aug 26th, 2009 at 12:30 am. Reason: added code tags
That looks like my code.... Where did you get it from? Anyways yes you did miss something. In your case you're initializing the username and password to null which will fail authentication with the server so you should just use the default credentials.
By the way -- You should never turn on anonymous relaying. You should create a user on your mailserver for the application.
Also please use code tags when posting code on daniweb:
[code=csharp]
...code here...
[/code]
By the way -- You should never turn on anonymous relaying. You should create a user on your mailserver for the application.
Also please use code tags when posting code on daniweb:
[code=csharp]
...code here...
[/code]
Last edited by sknake; Aug 25th, 2009 at 6:57 am.
Let me ask you this -- What do you want to do? Enabling relay on the mailserver is a bad idea, you should really use authentication. If you want to use anonymous relay then remove all of the user/pass/credential related code.
If you want to make a good decision
and use authentication then set up a user on your server and let me know and i'll post modified code
If you want to make a good decision
and use authentication then set up a user on your server and let me know and i'll post modified code •
•
Join Date: Aug 2009
Posts: 10
Reputation:
Solved Threads: 0
the thing is that i cant change anything on the web server... this SMTP sending function i am using works off someone else's pc for a different application. and it works(any email address)... with a private coding program that doesnt pass a username and password to the SMTP server.
i changed it so that it uses default credentials and the error states that he server response was: 5.1.1 User unknown....
i changed it so that it uses default credentials and the error states that he server response was: 5.1.1 User unknown....
Try this and tell me if it works:
C# Syntax (Toggle Plain Text)
public static void SendMailQ(MailMessage Message) { SmtpClient cli = new SmtpClient("172.16.252.8"); cli.UseDefaultCredentials = false; cli.Credentials = null; cli.Send(Message); }
Wait a minute here... You say it works on someone elses PC? Are you running your application from the other persons PC? You can allow "10.1.1.5" to relay anonymously but require everyone else to authenticate. There are a number of ways to punch holes in the security.
In order to test this you will have to run the application from the same PC as the current application.
In order to test this you will have to run the application from the same PC as the current application.
![]() |
Similar Threads
- smtp server mails goes to spam folder (VB.NET)
- mail in asp.net (ASP.NET)
- SMS through SMTP Server (C++)
- Windows Server 2003 SMTP Forward (Windows NT / 2000 / XP)
- Hooking SMTP Server (C)
- Email server on a personal computer (PHP)
- Need help regarding the E-mail..!! (Java)
- need help wid smtp server (PHP)
- My mac won't connect with SMTP server (OS X)
- sendmail config (Linux Servers and Apache)
Other Threads in the C# Forum
- Previous Thread: C# help with Access and Databases
- Next Thread: how to create ListViewItemCollection instance?
Views: 1145 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client code combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ http httpwebrequest image index input install label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming regex remote remoting resource richtextbox saving serialization server sleep socket sql statistics stream string tcp text textbox time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






