Mail sending problem
-
Hai all, In my application i am using System.Net.Mail for sending mail. for that i have used the code as given below. MailMessage mail = new MailMessage(); MailAddress To = new MailAddress("lijorajan2004@gmail.com"); mail.To.Add(To); mail.Body = "Hai"; MailAddress From = new MailAddress("lijo@ourdomain.com"); mail.From = From; SmtpClient client = new SmtpClient("smtp.myserver.com"); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Host = "hostname";//host name is our remote ip address client.UseDefaultCredentials = false; client.Send(mail); here the problem is i am able to send mail to my lijo@mydomain.com(it is our own domain).but i am not able to send mail to other domain(lijorajan2004@gmail.com); here i am getting error like "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for lijorajan2004@gmail.com" plse help me. Thanks in advance. Regds Lijo
-
Hai all, In my application i am using System.Net.Mail for sending mail. for that i have used the code as given below. MailMessage mail = new MailMessage(); MailAddress To = new MailAddress("lijorajan2004@gmail.com"); mail.To.Add(To); mail.Body = "Hai"; MailAddress From = new MailAddress("lijo@ourdomain.com"); mail.From = From; SmtpClient client = new SmtpClient("smtp.myserver.com"); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Host = "hostname";//host name is our remote ip address client.UseDefaultCredentials = false; client.Send(mail); here the problem is i am able to send mail to my lijo@mydomain.com(it is our own domain).but i am not able to send mail to other domain(lijorajan2004@gmail.com); here i am getting error like "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for lijorajan2004@gmail.com" plse help me. Thanks in advance. Regds Lijo
Your server is not allowed to relay messages that are not (either from one of it's users or to one of it's user's inbox) So to send the message either the sender or the receiver has to be from the server's (i.e. me@myserver.com) Nothing wrong with your code. Just the test email addresses need to be reviewed. Cheers Raz
/* Ghazi Hadi Al Wadi, PMP, ASQ SSGB, DBA */
-
Your server is not allowed to relay messages that are not (either from one of it's users or to one of it's user's inbox) So to send the message either the sender or the receiver has to be from the server's (i.e. me@myserver.com) Nothing wrong with your code. Just the test email addresses need to be reviewed. Cheers Raz
/* Ghazi Hadi Al Wadi, PMP, ASQ SSGB, DBA */
Hi, Thank u verymuch for ur reply.If u dont mind could u plse tell me in detail how i can solve this problem? this is my webconfig file plse help me. regrds Lijo
-
Hi, Thank u verymuch for ur reply.If u dont mind could u plse tell me in detail how i can solve this problem? this is my webconfig file plse help me. regrds Lijo
You have to check with your SMTP provider. Before checking with .net code, you can directly make it via telnet: If telnet doesn't work then there is an issue in your code, if not is an issue with your SMTP provider. Take a look at: http://msexchangeteam.com/archive/2006/07/14/428324.aspx[^] A compilation about SMTP material: http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0[SMTP Articles]
/// ------------------------- Braulio Díez tipsdotnet.com /// -------------------------
-
You have to check with your SMTP provider. Before checking with .net code, you can directly make it via telnet: If telnet doesn't work then there is an issue in your code, if not is an issue with your SMTP provider. Take a look at: http://msexchangeteam.com/archive/2006/07/14/428324.aspx[^] A compilation about SMTP material: http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0[SMTP Articles]
/// ------------------------- Braulio Díez tipsdotnet.com /// -------------------------
I second Braulio's openion. As amatter of fact about 9-10 years ago a list of servers that allows relaying was published as ablack list. This was to prevent and fight spamming. Many email servers rejected any messages comming from servers on the list. So how can you do that: you need to be able to find the MX record of the DNS entry for each recepient, or have an account at the server you are using and then use that account to send your messages. It is not a coding issue. It is a protocol limitation. Cheers Raz
/* Ghazi Hadi Al Wadi, PMP, ASQ SSGB, DBA */