Sending mail from asp.net (C# coding)
-
hi i am doing an application from which i have to send a mail to the peoples of which i can get the mail ID from the text box. this is the code i have written. using System.Net.Mail; using System.Web.Mail; System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = emailID.Text.ToString().Trim(); mail.Subject = "Focus Consultancy Online Test-User ID & Pasword"; mail.BodyFormat = MailFormat.Text; mail.Body = "this is the test mail"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail); this is the error i got, The server rejected one or more recipient addresses. T he server response was: 550 5.7.1 Unable to relay for xxx@xxx.com Please help me in solving this
-
hi i am doing an application from which i have to send a mail to the peoples of which i can get the mail ID from the text box. this is the code i have written. using System.Net.Mail; using System.Web.Mail; System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = emailID.Text.ToString().Trim(); mail.Subject = "Focus Consultancy Online Test-User ID & Pasword"; mail.BodyFormat = MailFormat.Text; mail.Body = "this is the test mail"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail); this is the error i got, The server rejected one or more recipient addresses. T he server response was: 550 5.7.1 Unable to relay for xxx@xxx.com Please help me in solving this
Hema Bairavan wrote:
SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail);
Did you configure SMTP server Properly ?
cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net
-
hi i am doing an application from which i have to send a mail to the peoples of which i can get the mail ID from the text box. this is the code i have written. using System.Net.Mail; using System.Web.Mail; System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = emailID.Text.ToString().Trim(); mail.Subject = "Focus Consultancy Online Test-User ID & Pasword"; mail.BodyFormat = MailFormat.Text; mail.Body = "this is the test mail"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail); this is the error i got, The server rejected one or more recipient addresses. T he server response was: 550 5.7.1 Unable to relay for xxx@xxx.com Please help me in solving this
Make sure all email addresses specified at MailMessage.To, MailMessage.Cc, MailMessage.Bcc and MailMessage.From are valid email addresses. Make sure you have permissions to relay through the server. Make sure the MailMessage.From has permissions to relay through the server.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Hema Bairavan wrote:
SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail);
Did you configure SMTP server Properly ?
cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net
Thanks for your reply mr Abhijith. i searched in net how to configure the SMTP server, but i dont get any good resources. can you please help me?
-
Make sure all email addresses specified at MailMessage.To, MailMessage.Cc, MailMessage.Bcc and MailMessage.From are valid email addresses. Make sure you have permissions to relay through the server. Make sure the MailMessage.From has permissions to relay through the server.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
mr Bharadwaj, actually i am new for using the smtp servers, can you please explain in detail about the giving permissions and all if you dont mind ?
-
Thanks for your reply mr Abhijith. i searched in net how to configure the SMTP server, but i dont get any good resources. can you please help me?
SMTP Server Setup (IIS 6.0)[^]
cheers, Abhijit CodeProject MVP My Recent Article : Exploring Session in ASP.Net
-
hi i am doing an application from which i have to send a mail to the peoples of which i can get the mail ID from the text box. this is the code i have written. using System.Net.Mail; using System.Web.Mail; System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = emailID.Text.ToString().Trim(); mail.Subject = "Focus Consultancy Online Test-User ID & Pasword"; mail.BodyFormat = MailFormat.Text; mail.Body = "this is the test mail"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(mail); this is the error i got, The server rejected one or more recipient addresses. T he server response was: 550 5.7.1 Unable to relay for xxx@xxx.com Please help me in solving this
Hey hi bhiravan, I hope the line SmtpMail.SmtpServer = "localhost" line creates the main problem. As ur specifying the server name as local host it doesnot allow all the other domain email addresses except your domain.So you need change the server name as "127.1.1.0" which is a global server address and even you need to change the smtp virtual server settings in IIS. Goto start->run->inetmgr where u will get ur IIS settings.right click on the Default smtp server and goto properties,go to Access tab,click on connection tab,then click on Add tab.There you need to enter ip address as 127.1.1.0 then click on ok. Then try it out.I hope now it works. If not let me know.Good luck. :)