Results 1 to 26 of 26

Thread: send email from website

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    send email from website

    hi

    i can send an email from my localhost, no problems.
    (set up relay to 127.0.0.1 for local host)

    when i upload the app to the server machine.
    the messages dont seem to come through when i try to send the emails from the website, on remote machine.

    is there anything that should be done extra to ensure that this works or does it have to be coded differently.

    thanks
    Last edited by d2005; Mar 3rd, 2006 at 06:30 AM.
    it works 60% of the time, all the time.

  2. #2

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    ive just noticed that the messages are on the server machine
    in the

    c\inetpub\mailroot\queue

    any idea why the messages are sitting there and not going out to the appropriate email addresses
    it works 60% of the time, all the time.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: send email from website

    Most likely because the website is blocking it? This is more of a server ocnfiguration issue, so if your server is hosted, you should contact them and ask them about the SMTP details.

  4. #4
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    yeh i had this before.
    it is to do with the way relay is set up on your machine - you also have to have CDONTS installed on your server in order to send emails i believe.

  5. #5

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    the server in question is just a compter sitting beside me,
    ill keep messing about with its configuration and let you know.

    just making sure it wasnt my code as the code uses
    SmtpMail.SmtpServer = "localhost"

    thanks
    Last edited by d2005; Mar 6th, 2006 at 04:18 AM.
    it works 60% of the time, all the time.

  6. #6

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    i have the relays set up and the cdonts registsered on the machine

    still everything sts in the queue folder

    what a nightmare
    it works 60% of the time, all the time.

  7. #7
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    just a possibility but could be the ISP denying you setting up relay on the computer - just a thought.

    tried using another smtp service?

    btw - what OS are you using? or rather what version of IIS?

    http://www.microsoft.com/technet/pro...87a2b88f2.mspx

    http://www.experts-exchange.com/Web/..._21599320.html

    http://www.systemwebmail.com/faq/1.6.aspx

  8. #8

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    Code:
    xp pro
    IIS 5.1
    
    SMTP Protocol
    Microsoft Corporation
    Version: Build 6015
    im sitting here on this machine developing the app.
    if i build and run it here it wokrs fine. i recieve the emails no probs

    if i move my app to the machine beside me(xp pro), used as a server for the moment for development purposes all emails sit in that queue folder when i use my app from a remote machine.

    both computers seem to have the same settings, though obviously not

    im considering burning the machine, would this help?
    VB Code:
    1. Dim msg As New MailMessage
    2.         msg.To = "[email protected]"
    3.         msg.From = "[email protected]"
    4.         msg.Cc = "[email protected]"
    5.         msg.Bcc = "[email protected]"
    6.         msg.Subject = "Query from customer"
    7.         msg.BodyFormat = System.Web.Mail.MailFormat.Text
    8.  
    9.         msg.Body = lblcompanyname.Text & ", " & txtComments.Text
    10.  
    11.  
    12.         msg.Priority = MailPriority.High
    13.         SmtpMail.SmtpServer = "127.0.0.1"
    14.         Try
    15.             SmtpMail.Send(msg)
    16.  
    17.             txtComments.Text = "                *          Message Sent Sucessfully          *"
    18.         Catch exc As Exception
    19.             txtComments.Text = ("Send failure: " + exc.ToString())
    20.         End Try
    Last edited by d2005; Mar 6th, 2006 at 07:44 AM.
    it works 60% of the time, all the time.

  9. #9
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    hang on....
    you are saying that all this works fine on computerA, which has the SMTP set up?
    you are saying that this does NOT work on computerB?

    if this is the case, change the SmtpMail.SmtpServer to the computername or IP Address of ComputerA (Which has the SMTP set up successfully)

  10. #10
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: send email from website

    Hello D2005,

    I was reading your e-mail. I understand that you was having trouble sending e-mail from your web server computer. But you was able to send the e-mail out on your own comptuer. Well I am having trouble sending the e-mail out on my own computer. This is just a little problem l am writing myself on my computer. However, I have check the intepub/mailroot/queue and all the e-mail are just sitting there.

    For the IIS I have configured the following. In general tab l have entered the ip address of my computer on port 25. On the access tab - connection i have granted access on 127.0.0.1 and - relay granted access on 127.0.0.1. The code l have is below. I have tried this with winforms and asp.net.

    Please could you tell me what I might be doing wrong to send e-mail out on my own computer.

    If you read my thrend on this forum, just below yours, you can read the history of what l have done.

    Many thanks in advance,

    Steve

    Code:
    using System.Web.Mail;
    
    private void btnSend_Click(object sender, EventArgs e)
            {
                try
                {
                    //Construct a new mail message and fill it with information from the form
                    MailMessage aMessage = new MailMessage();
                    aMessage.From = txtFrom.Text;
                    aMessage.To = txtTo.Text;
                    aMessage.Cc = txtCC.Text;
                    aMessage.Bcc = txtBCC.Text;
                    aMessage.Subject = txtSubject.Text;
                    aMessage.Body = txtMessage.Text;
    
                    //If an attachment file is indicated, create it and add it to the message
                    if (txtAttachment.Text.Length > 0)
                    {
                        aMessage.Attachments.Add(new MailAttachment(txtAttachment.Text, MailEncoding.Base64));
                    }
                    
                    SmtpMail.SmtpServer = "127.0.0.1";  
    
                    //Now send the message
                    SmtpMail.Send(aMessage);
    
                    //Indicate that the message has been sent
                    MessageBox.Show("Message sent to " + txtTo.Text, "E-mail Program", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
    steve

  11. #11

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    Quote Originally Posted by Techno
    hang on....
    you are saying that all this works fine on computerA, which has the SMTP set up?
    you are saying that this does NOT work on computerB?

    if this is the case, change the SmtpMail.SmtpServer to the computername or IP Address of ComputerA (Which has the SMTP set up successfully)
    the ipaddresses of both machines shall be the same. they are both behind a router. i view my webpages through the use of port 88.
    i.e. to view the webpage from server machine
    ipaddress:88/webform1.aspx

    it successfully worked when i just used local host or 127.0.0.1
    not the computer name.
    i seem to be a bit lost.

    how do i change the smtpmail.smtpserver
    it works 60% of the time, all the time.

  12. #12
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    no no, computers cannot have the same IP Address, the router issues a DHCP IP address to your computers - each computer will have a unique IP Address from DHCP

    in your code where it says :

    "SmtpMail.SmtpServer = 127.0.0.1"

    change it to the name of computerA or the IP Address of ComputerA (the one which has the SMTP server working successfully)

  13. #13

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    Quote Originally Posted by steve_rm
    Please could you tell me what I might be doing wrong to send e-mail out on my own computer.

    Steve
    steve

    try my code given above.
    to be honest with you i the only thing i changed was the relay to 127.0.0.1 in my smtp server. this allowed the emails to be sent succsessfully through
    SmtpMail.SmtpServer = "127.0.0.1"
    or
    SmtpMail.SmtpServer = "localhost"

    before you try it again
    stop your smtp
    delete all the files in the queue folder
    then restart it because i think i heard somewhere that that may hold it up.
    it works 60% of the time, all the time.

  14. #14

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    Quote Originally Posted by Techno
    no no, computers cannot have the same IP Address, the router issues a DHCP IP address to your computers - each computer will have a unique IP Address from DHCP

    in your code where it says :

    "SmtpMail.SmtpServer = 127.0.0.1"

    change it to the name of computerA or the IP Address of ComputerA (the one which has the SMTP server working successfully)
    i think the router is issuing us numbers such as

    10.0.0.20
    and 10.0.0.9
    etc.....
    are these the ipconfigs you refer too

    ill try it now in the mean time
    it works 60% of the time, all the time.

  15. #15

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    the ipconfig that works through localhost is 10.0.0.20

    it also works if i relay 10.0.0.20 and name it as my smtp server.

    ill try it now on the other machine. (with different smtpserver)
    it works 60% of the time, all the time.

  16. #16

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    the other machine is 10.0.0.9
    and i changed the code and relays it accordngly

    guess wot..........
    it didnt work lol
    i think ill just use pigeons to send mail.

    what is the queue folder anyways
    it works 60% of the time, all the time.

  17. #17
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    the queue folders are where mail waiting to be sent are stored in.

    so you set the smtp mail server in the code to 10.0.0.20 and that did not work?

  18. #18

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    10.0.0.20 works for the machine i develop on. no problems there

    the ip of the server machine is 10.0.0.9 so i changed my code accordingly
    it did not work on my server machine.
    it works 60% of the time, all the time.

  19. #19
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    interesting, it should as the 10.0.0.20 machine works according to you.
    im out lol

  20. #20

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    Quote Originally Posted by Techno
    interesting, it should as the 10.0.0.20 machine works according to you.
    im out lol


    Ill restart my machine. That always Helps
    Last edited by d2005; Mar 6th, 2006 at 10:56 AM.
    it works 60% of the time, all the time.

  21. #21

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    could the problem be?

    im just throwing this out there.

    because im using xppro, or has that got anything to do with it?
    it works 60% of the time, all the time.

  22. #22
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: send email from website

    Hello D20005,

    I have found some information on another post that told me that you cannot directly send e-mails from the outside to hotmail, yahoo, etc. In order for you to do this you have to send a username and password to be authenticated for hotmail, yahoo, etc. I thought it was possible to send e-mails to these accounts.

    I did what you suggested and my code is similar to yours. I deleted the mails from inetpub/mailroot/queue and restarted IIS. But still did not work.

    Did you manage to send an e-mail from your IIS to hotmail. I noticed that you assigned a hotmail address in your code.

    Thanks,

    Steve
    steve

  23. #23

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    yeah mines goes to hotmail no probs from my local host.

    it just doesnt seem to run on the other machine.

    we have to be doing something wrong
    i dont think its the code, i think its the settings
    lol
    Last edited by d2005; Mar 7th, 2006 at 04:38 AM.
    it works 60% of the time, all the time.

  24. #24

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send email from website

    this maybe a long shot but what the hay,

    does anyone know if you need outlook configured for the emails to send.
    i think that maybe the only difference between the machines



    im actually going to leave this alone now because i am of the thinking that it will work when i put it to a real server. thanks all for your help and time.
    steve, feel free to hijack this thread if yours still isnt working.
    Last edited by d2005; Mar 7th, 2006 at 06:12 AM.
    it works 60% of the time, all the time.

  25. #25
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Question Re: send email from website

    Hi,



    I had some similar problem couple of years ago and when i installed outlook on the server my problem was solved.

    do u have office(outlook) installed on your machine? If yes then check if the server have it too...if the server does not have outlook try to installed id with some default account(virtual) or u can just use the outlook part of the office carnal(shell) or use the outlook dll...

  26. #26
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: send email from website

    remember you need to configure your server to have SMTP if you are sending emails from your own server, or insert the details of your SMTP provider when sending the emails in the smtpclient class

    of course if you use Exchange...then it will do it all for you, the SMTP configuration and what not....

    again, totally depends on how you are setting up SMTP on your server

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

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