CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Mar 2008
    Posts
    161

    [RESOLVED] Creating Smtp Server

    I was wondering if it was possible to create an Smtp server with my application and then use my application to send an email using the Smtp server i just created?

    Can someone show me how to do this if it is even possible?

    Thanks,

    Pale.
    Last edited by Pale; July 29th, 2008 at 07:06 PM.

  2. #2
    Join Date
    Nov 2006
    Posts
    146

    Re: Creating Smtp Server

    So you want to create an SMTP server?

    Look at the RFC: http://www.ietf.org/rfc/rfc0821.txt

    That will get you started. I think you will only be able to send mails locally unless you get it hosted somewhere.
    If this post helps you out, please rate it!

  3. #3
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Quote Originally Posted by messycan
    So you want to create an SMTP server?

    Look at the RFC: http://www.ietf.org/rfc/rfc0821.txt

    That will get you started. I think you will only be able to send mails locally unless you get it hosted somewhere.
    No i mean use C# To Create the Smtp server.

  4. #4
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Let me enlighten you on what i am actually wanting to do. I want to send an email without showing the From Address and make the from address show something specified by me.

    I have this code now but how can i change it to do the above:

    Code:
    System.Net.Mail.MailMessage MyMessage = new System.Net.Mail.MailMessage(from,to,subject,body);
                                    MyMessage.IsBodyHtml = false;
                                    System.Net.NetworkCredential mailAuthentication = new
                                    System.Net.NetworkCredential("smtpusername", "smtppassword");
                                    System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtpserver", port);
                                    mailClient.EnableSsl = false;
                                    mailClient.UseDefaultCredentials = false;
                                    mailClient.Credentials = mailAuthentication;
                                    mailClient.Send(MyMessage);
    I want to make the from address show something other than the actual from address.

    The original question was because i thought that had something to do with the Smtp settings, so i wanted to create one and change the settings.

    But if there is any other way than changing the smtp server settings please let me know.

    If you have any other suggestions on this if it is impossible to do without changing the smtp settings please also let me know.

    Because i know someone is going to say this, i am not wanting to spam, if i wanted to spam i could use one of those free online anonymous email services.

    Thanks,

    Pale.

  5. #5
    Join Date
    Jan 2006
    Location
    18° 32' N / 73° 52' E
    Posts
    416

    Re: Creating Smtp Server

    Quote Originally Posted by Pale
    Let me enlighten you on what i am actually wanting to do. I want to send an email without showing the From Address and make the from address show something specified by me.

    I have this code now but how can i change it to do the above:

    Code:
    System.Net.Mail.MailMessage MyMessage = new System.Net.Mail.MailMessage(from,to,subject,body);
    MyMessage.IsBodyHtml = false;
    System.Net.NetworkCredential mailAuthentication = new
    System.Net.NetworkCredential("smtpusername", "smtppassword");
    System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtpserver", port);
    mailClient.EnableSsl = false;
    mailClient.UseDefaultCredentials = false;
    mailClient.Credentials = mailAuthentication;
    mailClient.Send(MyMessage);
    I want to make the from address show something other than the actual from address.

    The original question was because i thought that had something to do with the Smtp settings, so i wanted to create one and change the settings.

    But if there is any other way than changing the smtp server settings please let me know.

    If you have any other suggestions on this if it is impossible to do without changing the smtp settings please also let me know.

    Because i know someone is going to say this, i am not wanting to spam, if i wanted to spam i could use one of those free online anonymous email services.

    Thanks,

    Pale.

    There is one way.... but for that you need to configure/install SMTP server in the IIS. In IIS6 SMTP server is present. You can use it to send mails.

    Nampespace
    Code:
    using System.Web.Mail;
    Code Snippet
    Code:
     MailMessage myMail = new MailMessage();
     myMail.To = txtTo.Text.ToString();
     myMail.From = txtFrom.Text.ToString();
     myMail.Subject = txtSubject.Text.ToString();
     myMail.BodyFormat = MailFormat.Html; // here you can choose: Plain or HTML
     string body = txtMessage.Text.ToString();
     myMail.Body = body; //set the body message
     SmtpMail.Send(myMail);

  6. #6
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Creating Smtp Server

    You dont need your own server to do that, and anyway, unless you own the dmoain youre claiming to be from and have a valid MX record, most en-route SMTP servers withh deem it spam anyway

    You want to send an email to someone, pretending to be from someone else? Just use your existing mail server. If you dont own it, authenticate with it and it'll let you claim that youre god@heaven.net if you wish

    End of the day, you need to read up on how SMTP works. There is NO difference between writing your own server, and just establishing a client based conenction to your ISPs server. If you own your own domain, run a free smtp server (dont bother writing one). If you can conenct direct to the target domain's MX then jsut use that (i.e. if you can from your PC telnet straight to hotmail.com's port 25 then you can send, but again, you fall foul of possibly not having your own MX record and hotmail wont believe your intentions to be good, regardless of whether you wrote a server or not
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  7. #7
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Quote Originally Posted by cjard
    You dont need your own server to do that, and anyway, unless you own the dmoain youre claiming to be from and have a valid MX record, most en-route SMTP servers withh deem it spam anyway

    You want to send an email to someone, pretending to be from someone else? Just use your existing mail server. If you dont own it, authenticate with it and it'll let you claim that youre god@heaven.net if you wish

    End of the day, you need to read up on how SMTP works. There is NO difference between writing your own server, and just establishing a client based conenction to your ISPs server. If you own your own domain, run a free smtp server (dont bother writing one). If you can conenct direct to the target domain's MX then jsut use that (i.e. if you can from your PC telnet straight to hotmail.com's port 25 then you can send, but again, you fall foul of possibly not having your own MX record and hotmail wont believe your intentions to be good, regardless of whether you wrote a server or not
    So what are you saying i should do something like this?

    Code:
                            System.Net.Mail.MailMessage MyMessage = new System.Net.Mail.MailMessage();
                            MyMessage.BodyEncoding = System.Text.Encoding.ASCII;
                            MyMessage.SubjectEncoding = System.Text.Encoding.ASCII;
                            MyMessage.From = new System.Net.Mail.MailAddress("God@heaven.com");
                            MyMessage.To.Add(to);
                            MyMessage.Subject = subject;
                            MyMessage.Body = body;
                            MyMessage.IsBodyHtml = isbodyhtml;
                            System.Net.NetworkCredential mailAuthentication = new
                            System.Net.NetworkCredential(from, password);
                            System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient(smtp, port);
                            mailClient.EnableSsl = ssl;
                            mailClient.UseDefaultCredentials = false;
                            mailClient.Credentials = mailAuthentication;
                            mailClient.Send(MyMessage);
    That doesn't work, i get an exception, "The Sender email address does not match the one logged in."

  8. #8
    Join Date
    Aug 2005
    Location
    Seattle, Wa
    Posts
    179

    Re: Creating Smtp Server

    Most mail servers will let you do exactly what you just tried. Yours apparently doesnt.

    Unless you have another mail server to try, or the ability to install and host a new mail server, you are stuck.

    Writing a mail server would be pointless.

  9. #9
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Creating Smtp Server

    the most important thing you can do is to read how smtp works.

    you've missed the forest for the trees there. from and password are used by the smtp server to authenticate that you have permission to send a mail message on that server. you need a mail (smtp) server to send the mail. authentication name / password do not have to match the "from" header on the mail message itself, but the authentication credentials are often stored, and can be looked up in reverse (if its not sent along w/ the message itself, which is often the case), so it does you no good to spoof the from address, as most spam filters look for this as their #1 rule to process, so you have little chance of succeeding there.

    as has been said, unless you own an smtp server, that "smtp client" code you're using will do nothing.

  10. #10
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Quote Originally Posted by crackersixx
    Most mail servers will let you do exactly what you just tried. Yours apparently doesnt.

    Unless you have another mail server to try, or the ability to install and host a new mail server, you are stuck.

    Writing a mail server would be pointless.
    I have yet to find one that allows that, can you provide me with the name of one that does?

  11. #11
    Join Date
    Aug 2005
    Location
    Seattle, Wa
    Posts
    179

    Re: Creating Smtp Server

    My mail server at work allows this just fine as I use this ability to send email alerts from some of my applications, such as "appfailure@mydomain.com".

    my hosting provider for my domain (and domain email) allows this...
    Although it is marked as spam, you can see i sent the following mail as someone@testing.com


    Code:
    Return-Path: <someone@testing.com>
    Delivered-To: crackersixx@reversers.net
    Received: (qmail 20801 invoked by uid 399); 30 Jul 2008 16:52:27 -0000
    X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on localhost
    X-Spam-Level: ******
    X-Spam-Status: No, score=6.8 required=14.0 tests=MISSING_DATE,MISSING_HB_SEP,
         MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,RDNS_NONE autolearn=disabled
         version=3.2.4
    Received: from unknown (HELO reversers.net) (152.157.85.196)
         by mail.myhsphere.biz with ESMTP; 30 Jul 2008 16:52:27 -0000
    Received-SPF: none (mail.myhsphere.biz: domain at testing.com does not designate permitted sender hosts)
         identity=mailfrom; client-ip=***;
         envelope-from=<someone@testing.com>;
        this is a test

  12. #12
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Quote Originally Posted by crackersixx
    My mail server at work allows this just fine as I use this ability to send email alerts from some of my applications, such as "appfailure@mydomain.com".

    my hosting provider for my domain (and domain email) allows this...
    Although it is marked as spam, you can see i sent the following mail as someone@testing.com


    Code:
    Return-Path: <someone@testing.com>
    Delivered-To: crackersixx@reversers.net
    Received: (qmail 20801 invoked by uid 399); 30 Jul 2008 16:52:27 -0000
    X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on localhost
    X-Spam-Level: ******
    X-Spam-Status: No, score=6.8 required=14.0 tests=MISSING_DATE,MISSING_HB_SEP,
         MISSING_HEADERS,MISSING_MID,MISSING_SUBJECT,RDNS_NONE autolearn=disabled
         version=3.2.4
    Received: from unknown (HELO reversers.net) (152.157.85.196)
         by mail.myhsphere.biz with ESMTP; 30 Jul 2008 16:52:27 -0000
    Received-SPF: none (mail.myhsphere.biz: domain at testing.com does not designate permitted sender hosts)
         identity=mailfrom; client-ip=***;
         envelope-from=<someone@testing.com>;
        this is a test
    What about an smtp that i have access to.

  13. #13
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Creating Smtp Server

    the header he posted is what I was talking about (the received headers).

    that's something that unless you write your own smtp server, you have very little control over (what it adds to your message).

    and if you did have that (your own mail server implementation), all it takes is for your server to come to the attention of one major ISP and the IP will go on a black list that takes for ever to get removed from (we run our own mail server and had to go to hell and back to get it removed from everybody's black list).

    what you're looking for is called an open relay. open relays are a security hole that need to cease to exist.

    if you don't mind me asking, why are you so interested in spoofing your from address?
    Last edited by MadHatter; July 30th, 2008 at 02:43 PM.

  14. #14
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Creating Smtp Server

    Quote Originally Posted by Pale
    What about an smtp that i have access to.
    What about telling us:

    What domain youre actually from
    What domain you want to appear to be from
    What email address you want to spoof
    What email address will be the recipient
    What is the name of your existing SMTP software (and version)
    Why you want the address to be spoofed
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  15. #15
    Join Date
    Mar 2008
    Posts
    161

    Re: Creating Smtp Server

    Ive seen other software that can do that, i was just wondering how i could do something like that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured