Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

auto detect smtp server on user's pc

Posted on 2009-04-01
5
Medium Priority
?
589 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 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Check out the latest tech news, community articles, and expert highlights in August's newsletter.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

722 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