?
Solved

Unable to connect to remote server

Posted on 2007-10-18
4
Medium Priority
?
822 Views
Last Modified: 2013-12-18
I have a C# program that runs on my laptop and send an email, using my remote website to relay the email.  But when I run the same program from a Virtual Private Server of mine, I get the error: Unable to Connect to Remote Server.

Dos anyone have any idea about what could be the problem?  I could include the source code, but suspect the problem lies in the configuration or environment, versus the code.

Any idea of what to check?

Thanks,
newbieweb
0
Comment
Question by:newbieweb
4 Comments
 

Author Comment

by:newbieweb
ID: 20106161
Here is the code:

        private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
        {
            // Get the unique identifier for this asynchronous operation.
            MailMessage eMailMessage = (MailMessage)e.UserState;
           
            if (e.Cancelled)
            {
                //Console.WriteLine("[{0}] Send canceled.", token);
            }
            if (e.Error != null)
            {
                //Console.WriteLine("[{0}] {1}", token, e.Error.ToString());
            }
            else
            {
                string emailAddress = (string)eMailMessage.To[0].Address;
                eMailMessage.Dispose();
            }
        }

        public void Send()
        {
            // Command line argument must the the SMTP host.
            SmtpClient client = new SmtpClient(Handles.SMTPServer);

            NetworkCredential nc = new NetworkCredential(Handles.Username, Handles.Password);
            client.UseDefaultCredentials = false;
            client.Credentials = nc;

            // Specify the e-mail sender.
            // Create a mailing address that includes a UTF8 character
            // in the display name.
            MailAddress from = new MailAddress(handles.FromEmail, handles.FromFirstName + " " + handles.FromLastName, System.Text.Encoding.UTF8);

            // Set destinations for the e-mail message.
            MailAddress to = new MailAddress(contact.EmailAddress);
           
            // Specify the message content.
            MailMessage message = new MailMessage(from, to);
            message.Body = "";//"ApplicationPath=" + HttpContext.Current.Request.ApplicationPath;
           
            // Include some non-ASCII characters in body and subject.
            message.Body += Environment.NewLine;
            message.BodyEncoding =  System.Text.Encoding.UTF8;
            message.Subject = "test message from " + handles.Preferences.MachineName;
            message.SubjectEncoding = System.Text.Encoding.UTF8;
           
            // Set the method that is called back when the send operation ends.
            client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
           
            // The userState can be any object that allows your callback
            // method to identify this send operation.
            // For this example, the userToken is a string constant.
            //Object userState = this;
            Object userState = message;
            client.SendAsync(message, userState);
        }
0
 
LVL 4

Accepted Solution

by:
redcelltech earned 800 total points
ID: 20106584
can you telnet from the machine to your mail server on port 25?

telnet mail.host.com 25

Can the virtual server route to the internet?
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 400 total points
ID: 20108316
Yeah, do you need to go through a firewall or proxy?

Bob
0
 
LVL 1

Assisted Solution

by:pothireddysunil
pothireddysunil earned 800 total points
ID: 20111553
I think your Virtual Private Server is having permissions issue in the network.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
Suggested Courses

840 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