Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SMTP email using c#

Posted on 2006-07-17
8
Medium Priority
?
1,698 Views
Last Modified: 2012-06-21
Hello experts,

I am trying to send emails via a web application. when i test it on my local machine, it works fine. But when I upload to the live server it doesn't. I am using the follwoing line to send;-

Utils.Mail.MailSender.SendMailMessage("Localhost", msgWithAttachment);

I got the following code off the internet somewhere;-

Response.Write(bthcu.Message + bthcu.StackTrace);

This outputs the following when the email is not sent;-
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for myemail@yahoo.co.uk at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Utils.Mail.MailSender.SendMailMessage(String SMTPServer, MailMessage message) in C:\VS2005Projects\EasyMailSender\EasyMailSender\MailSender.cs:line 83 at valuation.ImageButton1_Click1(Object sender, ImageClickEventArgs e) in c:\Inetpub\wwwroot\livesite\valuations\valuation2.aspx.cs:line 212
0
Comment
Question by:claracruz
8 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17120954
Hi claracruz,

You might need to use the server's name.  Also check if you need to authenticate against the mail server as i think this is whats happening, if so you need to add smtp fields

Apresto
0
 
LVL 23

Expert Comment

by:apresto
ID: 17120958
http://www.codeproject.com/dotnet/SystemWeb_Mail_SMTP_AUTH.asp

this code demonstrated how to incorporate username and password
0
 
LVL 3

Expert Comment

by:harshits
ID: 17121027
Hi claracruz

Here is code which I generally use in my asp.net applications

System.Web.Mail.MailMessage mm=new System.Web.Mail.MailMessage();
                  mm.To="tomailid";
                                     mm.From="From";
                  mm.Body="Hi, test";                  

System.Web.Mail.SmtpMail.SmtpServer="Name of the SMTP server name which your live server uses";

System.Web.Mail.SmtpMail.Send(mm);

Harshit Sheth
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 23

Expert Comment

by:apresto
ID: 17121063
this error:

The server response was: 5.7.1 Unable to relay for myemail@yahoo.co.uk

generally means that the server cannot reack the yahoo.co.uk domain - probably because you need to authenticate yourself as a sender - i dont think it is the code that is the problem
0
 
LVL 7

Expert Comment

by:irps20001
ID: 17121353
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17121778
0
 
LVL 4

Author Comment

by:claracruz
ID: 17129436
kaliyugkaarjun ,
My code works on my local computer, I know the code is not the probelmAnd am using c#.


apresto ,
How do i  authenticate myself as a sender - i know its not a code problem as it works on my local machine. What I need to know is how to configure my webserver/smtp server to send emails

Many Thanks,

Clara
0
 
LVL 3

Accepted Solution

by:
harshits earned 2000 total points
ID: 17136118
This seems to be the solution to your problem. Just check this...

http://www.mikepope.com/blog/DisplayBlog.aspx?permalink=1251&count=no


" A little googling to learn what the 5.7.1 error is, from which I deduce that the Exchange server is refusing to relay for anyone not in its domain. So I look again at the From and To addresses. Ok, well, one problem is that I misspelled the From address. A few more experiments, and I learn that our internal relay server will send only from and to addresses within our domain. (Or so it seems.)

Anyway, now it works.".....

Harshit Sheth
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question