Solved

auto detect smtp server on user's pc

Posted on 2009-04-01
5
585 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
change colour of repeater control in asp.net c# 7 163
Using ANSI C how to Read a .csv file 10 133
Configure SPF check on IMSVA 2 114
Exchange 2013 fills up C drive with logs 4 29
What is Usenet? There are many different opinions on exactly what Usenet is an isn't. Many opinions are incorrect simply out of ignorance. The Wikipedia listing about Usenet does a good job of explaining it, so instead of repeating it all here I wi…
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 and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

751 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