Solved

auto detect smtp server on user's pc

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
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 conditional statements in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now