Solved

auto detect smtp server on user's pc

Posted on 2009-04-01
5
587 Views
Last Modified: 2013-11-30
Hi,
I have a C++ application that will be run on my clients' destops. Before running my application, my clients are required to perform the activation process, which will cause my app to send an email back to me. I had some code in my app to send mail back to me but it only works if an smtp server is defined. I was just wondering if there is a way for me to determine my users' stmp server automatically through coding?

Thank you very much for  you help. Some coding example would be helpful.
0
Comment
Question by:leloc6787
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:exclamationsoft
ID: 24052029
I have two suggestions:
  1. Launch the user's email program to send the email by shelling out with "mailto:email@domain.com".  MFC C++ code included which will create a new message with the user's defaultemail client.
     
  2. A slightly different approach that we employ with our software: send email completely through your code, using an email component, and use your own mail server.  This will eliminate the requirement for needing an SMTP server or depending on the user to have an email client installed and configured.
HINSTANCE hInstance = ShellExecute ( NULL, "open", "mailto:email@domain.com?subject=my%20subject&body=message%20body", 
   "", NULL, SW_SHOWNORMAL );

Open in new window

0
 

Author Comment

by:leloc6787
ID: 24053376
Do you have an example for second solution? I defined my stmp server in my code but it works only if my laptop is connect to my company's network. I wasn't able to make it work from home.

Thanks
0
 
LVL 2

Expert Comment

by:exclamationsoft
ID: 24053451
Code from the second solution will require the use of an email component.  Choosing the right one would depend on the language you are programming in.
If this is the route you want to go, you can do an Internet search for "email component" and find one that has specific examples for that component.
0
 

Author Comment

by:leloc6787
ID: 24056062
Thank you for your reply. I know my smtp server name but my app failed to connect to the server when I used it with port 25 from my home. Is there a way for me to scan what ports use with my smtp server?

Thank you.
0
 
LVL 2

Accepted Solution

by:
exclamationsoft earned 500 total points
ID: 24097410
The only way I can think of to scan for the correct port, is to go through each number until a connection is made.  
Find out what the correct port number is and ensure that the SMTP server is accessible from outside the network the server is physically on.  If you cannot reach it from outside the network, then try one of my other two suggestions.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

There was an incident about the POP3 issue for the double read receipts and delivery receipts in Exchange 2013.  There was huge research been done and found solution for the duplicate mails. Especially when the user gets  duplicate mails.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

636 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