How to send email using the mail function on Windows XP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Warren Tang

    How to send email using the mail function on Windows XP?


    Hi

    I am using the mail function to send a mail like this:

    $b = mail("my_real_e mail_address@gm ail.com", "Hello from PHP",
    "Hi, finally sent an email successfully");

    But it failed. Could you guide me to get it work?

    Regards
    Warren
  • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

    #2
    Re: How to send email using the mail function on Windows XP?

    Warren Tang escribió:
    I am using the mail function to send a mail like this:
    >
    $b = mail("my_real_e mail_address@gm ail.com", "Hello from PHP",
    "Hi, finally sent an email successfully");
    >
    But it failed. Could you guide me to get it work?

    Find these lines in your php.ini file:

    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    You need to install/enable a local mail server (I believe some versions
    of Windows XP have one) or replace "localhost" with the address of an
    external mail server that would accept mail from your machine (perhaps
    your ISP's server).


    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --

    Comment

    • Jerry Stuckle

      #3
      Re: How to send email using the mail function on Windows XP?

      Warren Tang wrote:
      >
      Hi
      >
      I am using the mail function to send a mail like this:
      >
      $b = mail("my_real_e mail_address@gm ail.com", "Hello from PHP",
      "Hi, finally sent an email successfully");
      >
      But it failed. Could you guide me to get it work?
      >
      Regards
      Warren
      Not enough information.

      What do you mean "it failed"? What does the mail() function return?

      What OS are you running on, and do you have an MTA (Mail Transfer Agent)
      running on that machine?

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Curtis

        #4
        Re: How to send email using the mail function on Windows XP?

        On Tue, 11 Nov 2008 06:33:26 -0500, jstucklex@attgl obal.net wrote:
        Warren Tang wrote:

        Hi

        I am using the mail function to send a mail like this:

        $b = mail("my_real_e mail_address@gm ail.com", "Hello from PHP",
        "Hi, finally sent an email successfully");

        But it failed. Could you guide me to get it work?

        Regards
        Warren
        >
        Not enough information.
        >
        What do you mean "it failed"? What does the mail() function return?
        >
        What OS are you running on, and do you have an MTA (Mail Transfer Agent)
        running on that machine?
        The OP specifies the OS is Windows XP in the subject. XP (perhaps
        only professional) should have an SMTP server stock with IIS.

        @OP: for help with setting it up, you may wish to consult a Windows
        newsgroup. You may need to check with your ISP to see if they block
        port 25 (default port on which most SMTP servers run), too.
        --
        Curtis
        $email = str_replace('si g.invalid', 'gmail.com', $from);

        Comment

        • Jerry Stuckle

          #5
          Re: How to send email using the mail function on Windows XP?

          Curtis wrote:
          On Tue, 11 Nov 2008 06:33:26 -0500, jstucklex@attgl obal.net wrote:
          >Warren Tang wrote:
          >>Hi
          >>>
          >>I am using the mail function to send a mail like this:
          >>>
          >> $b = mail("my_real_e mail_address@gm ail.com", "Hello from PHP",
          >> "Hi, finally sent an email successfully");
          >>>
          >>But it failed. Could you guide me to get it work?
          >>>
          >>Regards
          >>Warren
          >Not enough information.
          >>
          >What do you mean "it failed"? What does the mail() function return?
          >>
          >What OS are you running on, and do you have an MTA (Mail Transfer Agent)
          >running on that machine?
          >
          The OP specifies the OS is Windows XP in the subject. XP (perhaps
          only professional) should have an SMTP server stock with IIS.
          >
          Yes, but he only specified XP Whether it is Home or Professional
          edition is very important - and affects the response.
          @OP: for help with setting it up, you may wish to consult a Windows
          newsgroup. You may need to check with your ISP to see if they block
          port 25 (default port on which most SMTP servers run), too.


          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Warren Tang

            #6
            Re: How to send email using the mail function on Windows XP?

            Thank you guys. It's Windows XP professional.

            I once tried to configure php.ini to use smtp.gmail.com, but found that
            the php.ini does not allow me to specify the user name and password, say
            nothing of SSL.

            Now I am focusing on how to make use of the SMTP Server in IIS which has
            been installed on my PC. Is it possible to send an email to gmail using
            my SMTP server?

            Regards
            Warren

            Comment

            • Warren Tang

              #7
              Re: How to send email using the mail function on Windows XP?

              This is a home computer and my ISP doesn't provide an SMTP server (in my
              country?).

              Warren Tang wrote:
              Thank you guys. It's Windows XP professional.
              >
              I once tried to configure php.ini to use smtp.gmail.com, but found that
              the php.ini does not allow me to specify the user name and password, say
              nothing of SSL.
              >
              Now I am focusing on how to make use of the SMTP Server in IIS which has
              been installed on my PC. Is it possible to send an email to gmail using
              my SMTP server?
              >
              Regards
              Warren
              >

              Comment

              • Jerry Stuckle

                #8
                Re: How to send email using the mail function on Windows XP?

                Warren Tang wrote:
                Thank you guys. It's Windows XP professional.
                >
                I once tried to configure php.ini to use smtp.gmail.com, but found that
                the php.ini does not allow me to specify the user name and password, say
                nothing of SSL.
                >
                Now I am focusing on how to make use of the SMTP Server in IIS which has
                been installed on my PC. Is it possible to send an email to gmail using
                my SMTP server?
                >
                Regards
                Warren
                >
                Warren,

                OK, so you've got a local email server - that's a good start. Once you
                get your SMTP server going properly, you should be able to send email to
                anyone, including gmail. The only restriction might be your ISP - as
                Curtis said, many are not blocking port 25. You can easily test this
                from a MS DOS Prompt, type:

                C:>telnet smtp.gmail.com 25

                If you get a response such as "220 mx.google.com ..." then your port 25
                is not blocked. But if you get "Could not open a connection to host on
                port 25 : connection failed" or similar, then your port 25 is blocked
                and you won't be able to do anything about it (except change ISP's).

                If the above test works, then you should be able to send email from your
                machine to anyone on the planet (or off :-) ). Whether it will be
                received is another story, however. Since you probably have a dynamic
                IP address, some sites will reject email from dynamic IP addresses. The
                last time I checked, gmail wasn't one of them, but others do.

                Finally, your last hurdle is to bypass the anti-spam filters. One of
                the more common reasons (other than the content, and one that you can
                handle from your end) that emails are rejected as SPAM is because the
                From: header doesn't have a valid email address (ReplyTo:, if present,
                also needs a valid email address).

                If your port 25 is blocked, or you're having problems getting past spam
                filters, you might want to try PHPMailer. It's a great tool which will
                do a lot of things, including the necessary authentication. And if your
                port 25 is blocked, you can use port 587 (an alternate for authenticated
                users only) to connect to gmail.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Warren Tang

                  #9
                  Re: How to send email using the mail function on Windows XP?

                  Hi, Jerry

                  Thanks for your detailed guidance. I've tested using the telnet command
                  and the port 25 is not blocked.

                  The big problems lies here:
                  >Once you get your SMTP server going properly
                  Actually I don't know how to configure it... I just installed it. But
                  when I sent an email, it went into the Badmail folder. So it even didn't
                  have the chance to be filtered by anti-spam.

                  Regards
                  Warren

                  Jerry Stuckle wrote:
                  Warren Tang wrote:
                  >Thank you guys. It's Windows XP professional.
                  >>
                  >I once tried to configure php.ini to use smtp.gmail.com, but found
                  >that the php.ini does not allow me to specify the user name and
                  >password, say nothing of SSL.
                  >>
                  >Now I am focusing on how to make use of the SMTP Server in IIS which
                  >has been installed on my PC. Is it possible to send an email to gmail
                  >using my SMTP server?
                  >>
                  >Regards
                  >Warren
                  >>
                  >
                  Warren,
                  >
                  OK, so you've got a local email server - that's a good start. Once you
                  get your SMTP server going properly, you should be able to send email to
                  anyone, including gmail. The only restriction might be your ISP - as
                  Curtis said, many are not blocking port 25. You can easily test this
                  from a MS DOS Prompt, type:
                  >
                  C:>telnet smtp.gmail.com 25
                  >
                  If you get a response such as "220 mx.google.com ..." then your port 25
                  is not blocked. But if you get "Could not open a connection to host on
                  port 25 : connection failed" or similar, then your port 25 is blocked
                  and you won't be able to do anything about it (except change ISP's).
                  >
                  If the above test works, then you should be able to send email from your
                  machine to anyone on the planet (or off :-) ). Whether it will be
                  received is another story, however. Since you probably have a dynamic
                  IP address, some sites will reject email from dynamic IP addresses. The
                  last time I checked, gmail wasn't one of them, but others do.
                  >
                  Finally, your last hurdle is to bypass the anti-spam filters. One of
                  the more common reasons (other than the content, and one that you can
                  handle from your end) that emails are rejected as SPAM is because the
                  From: header doesn't have a valid email address (ReplyTo:, if present,
                  also needs a valid email address).
                  >
                  If your port 25 is blocked, or you're having problems getting past spam
                  filters, you might want to try PHPMailer. It's a great tool which will
                  do a lot of things, including the necessary authentication. And if your
                  port 25 is blocked, you can use port 587 (an alternate for authenticated
                  users only) to connect to gmail.
                  >

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: How to send email using the mail function on Windows XP?

                    Warren Tang wrote:
                    Jerry Stuckle wrote:
                    >Warren Tang wrote:
                    >>Thank you guys. It's Windows XP professional.
                    >>>
                    >>I once tried to configure php.ini to use smtp.gmail.com, but found
                    >>that the php.ini does not allow me to specify the user name and
                    >>password, say nothing of SSL.
                    >>>
                    >>Now I am focusing on how to make use of the SMTP Server in IIS which
                    >>has been installed on my PC. Is it possible to send an email to gmail
                    >>using my SMTP server?
                    >>>
                    >>Regards
                    >>Warren
                    >>>
                    >>
                    >Warren,
                    >>
                    >OK, so you've got a local email server - that's a good start. Once
                    >you get your SMTP server going properly, you should be able to send
                    >email to anyone, including gmail. The only restriction might be your
                    >ISP - as Curtis said, many are not blocking port 25. You can easily
                    >test this from a MS DOS Prompt, type:
                    >>
                    >C:>telnet smtp.gmail.com 25
                    >>
                    >If you get a response such as "220 mx.google.com ..." then your port
                    >25 is not blocked. But if you get "Could not open a connection to
                    >host on port 25 : connection failed" or similar, then your port 25 is
                    >blocked and you won't be able to do anything about it (except change
                    >ISP's).
                    >>
                    >If the above test works, then you should be able to send email from
                    >your machine to anyone on the planet (or off :-) ). Whether it will
                    >be received is another story, however. Since you probably have a
                    >dynamic IP address, some sites will reject email from dynamic IP
                    >addresses. The last time I checked, gmail wasn't one of them, but
                    >others do.
                    >>
                    >Finally, your last hurdle is to bypass the anti-spam filters. One of
                    >the more common reasons (other than the content, and one that you can
                    >handle from your end) that emails are rejected as SPAM is because the
                    >From: header doesn't have a valid email address (ReplyTo:, if present,
                    >also needs a valid email address).
                    >>
                    >If your port 25 is blocked, or you're having problems getting past
                    >spam filters, you might want to try PHPMailer. It's a great tool
                    >which will do a lot of things, including the necessary
                    >authentication . And if your port 25 is blocked, you can use port 587
                    >(an alternate for authenticated users only) to connect to gmail.
                    >>
                    Hi, Jerry
                    >
                    Thanks for your detailed guidance. I've tested using the telnet
                    command and the port 25 is not blocked.
                    >
                    The big problems lies here:
                    >Once you get your SMTP server going properly
                    >
                    Actually I don't know how to configure it... I just installed it. But
                    when I sent an email, it went into the Badmail folder. So it even
                    didn't have the chance to be filtered by anti-spam
                    >
                    Regards
                    Warren
                    >
                    (Top posting fixed)

                    The Badmail folder on your receiving system? That would mean the mail
                    got sent, but the receiving system didn't like what it saw (I don't use
                    gmail). So you would have to find out what is bad about it. The
                    easiest way would be to look at the headers for your email, and compare
                    them to headers for a "good" email to see what the difference is.

                    I still recommend PHPMailer - it makes your life much easier.

                    And please don't top post. Thanks.

                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    • Warren Tang

                      #11
                      Re: How to send email using the mail function on Windows XP?

                      Hi, Jerry
                      >
                      Thanks for your detailed guidance. I've tested using the telnet
                      command and the port 25 is not blocked.
                      >
                      The big problems lies here:
                      >Once you get your SMTP server going properly
                      >
                      Actually I don't know how to configure it... I just installed it. But
                      when I sent an email, it went into the Badmail folder. So it even
                      didn't have the chance to be filtered by anti-spam
                      >
                      Regards
                      Warren
                      >
                      >
                      (Top posting fixed)
                      >
                      The Badmail folder on your receiving system? That would mean the mail
                      got sent, but the receiving system didn't like what it saw (I don't use
                      gmail). So you would have to find out what is bad about it. The
                      easiest way would be to look at the headers for your email, and compare
                      them to headers for a "good" email to see what the difference is.
                      >
                      After testing for many times, it seems that I cannot configure "Domains"
                      properly in IIS. After reading some links I realized that it's not
                      intuitive at all to configure the SMTP Server in IIS.

                      Fortunately I managed to send emails to "myself" - localhost. That's
                      enough for testing purpose so I stopped the attempt to send mails to
                      Gmail. The instructions is listed below and I hope it can help those who
                      need it:

                      I still recommend PHPMailer - it makes your life much easier.
                      I'll definitely have a look at it. In fact it's not long since I started
                      learning PHP.
                      >
                      And please don't top post. Thanks.
                      >
                      Just searched for "top post" and found that I've broken the netetiquette
                      on usenet newsgroups... Thanks for reminding me that. And I hope this
                      post is in a good manner:)

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: How to send email using the mail function on Windows XP?

                        Warren Tang wrote:
                        >
                        > Hi, Jerry
                        > >
                        > Thanks for your detailed guidance. I've tested using the telnet
                        > command and the port 25 is not blocked.
                        > >
                        > The big problems lies here:
                        > >Once you get your SMTP server going properly
                        > >
                        > Actually I don't know how to configure it... I just installed it. But
                        > when I sent an email, it went into the Badmail folder. So it even
                        > didn't have the chance to be filtered by anti-spam
                        > >
                        > Regards
                        > Warren
                        > >
                        >>
                        >(Top posting fixed)
                        >>
                        >The Badmail folder on your receiving system? That would mean the mail
                        >got sent, but the receiving system didn't like what it saw (I don't
                        >use gmail). So you would have to find out what is bad about it. The
                        >easiest way would be to look at the headers for your email, and
                        >compare them to headers for a "good" email to see what the difference is.
                        >>
                        >
                        After testing for many times, it seems that I cannot configure "Domains"
                        properly in IIS. After reading some links I realized that it's not
                        intuitive at all to configure the SMTP Server in IIS.
                        >
                        Yes, IIS's SMTP server can be a bit tricky to configure. I'd recommend
                        you check one of the IIS newsgroups for help.

                        Alternatively, I use ArgoSoft mail server for testing here. Pretty easy
                        to set up and it does well enough for lightweight stuff.
                        Fortunately I managed to send emails to "myself" - localhost. That's
                        enough for testing purpose so I stopped the attempt to send mails to
                        Gmail. The instructions is listed below and I hope it can help those who
                        need it:

                        >
                        >I still recommend PHPMailer - it makes your life much easier.
                        >
                        I'll definitely have a look at it. In fact it's not long since I started
                        learning PHP.
                        >
                        Yes, it's a good package. I recommend it highly (and no, I don't have
                        anything to do with the project).
                        >>
                        >And please don't top post. Thanks.
                        >>
                        >
                        Just searched for "top post" and found that I've broken the netetiquette
                        on usenet newsgroups... Thanks for reminding me that. And I hope this
                        post is in a good manner:)
                        No problem - everyone makes a misteak once in a while :-)

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Warren Tang

                          #13
                          Re: How to send email using the mail function on Windows XP?

                          Jerry Stuckle wrote:
                          Alternatively, I use ArgoSoft mail server for testing here. Pretty easy
                          to set up and it does well enough for lightweight stuff.
                          Heard about the ArgoSoft mail server when I was searching for a
                          solution. I'd like to try it later.

                          Comment

                          • Warren Tang

                            #14
                            Re: How to send email using the mail function on Windows XP?

                            Jim Carlock wrote:
                            1) You should have a DNS MX pointer that points to your home
                            machine. The MX names for mail servers usually end up like:
                            >
                            mail.example.co m
                            Thanks Jim for your help, but I don't know how to configure a MX record...

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: How to send email using the mail function on Windows XP?

                              Warren Tang wrote:
                              Jim Carlock wrote:
                              >1) You should have a DNS MX pointer that points to your home
                              > machine. The MX names for mail servers usually end up like:
                              >>
                              > mail.example.co m
                              >
                              Thanks Jim for your help, but I don't know how to configure a MX record...
                              Warren,

                              You don't need an MX record to forward to gmail. You only need them for
                              receiving email.

                              Chances are something you're doing is causing GMail's spam filters to
                              throw it out. Comparing headers in what you receive locally with an
                              email sent to gmail from your regular email program can help find the
                              differences.

                              There is a slight chance gmail is just dropping your connection; that
                              would show up in your smtp log.

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...