Solved

auto detect smtp server on user's pc

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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.
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 and use conditional statements in the C programming language.

867 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

20 Experts available now in Live!

Get 1:1 Help Now