Announcement

Collapse
No announcement yet.

Unable to send Email using php mail() to external domain(gmail) from localhost

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

    Unable to send Email using php mail() to external domain(gmail) from localhost

    Hi,
    I tried to send Email from my localhost using php(installed) mail() function but the Email has not been delivered to external domains(gmail,yahoomail).

    1.I'm using kubuntu linux with kernal release 2.6.35-22-generic,KDE 4.5.1,Grub is GRand Unified Bootloader(Legacy version)and operating system GNU/LINUX.
    kubuntu is not installed inside windows.I also have windows xp installed in my laptop 32 bit intel pentium dual-core processor.
    2.I have already installed the following:PEAR mail packages
    i.sudo pear install mail
    ii.sudo pear install Net_SMTP
    iii.sudo pear install Auth_SASL
    iv.sudo pear install mail_mime
    3.Later sudo apt-get install postfix
    Then in configuration window I have selected Internet site->localhost as System mail name
    configured mailbox format and configured Postfix to do SMTP AUTH using SASL.
    Generated certificates to be used for TLS and configured postfix for the same.
    4.Then I have installed libsasl2-2,sasl2-bin and libsasl2-modules and I activeted saslauthd by setting START=yes and by adding PWDIR,PARAMS,PIDFILE to appropriate paths as mentioned in the help.ubuntu.com.
    5.Finally I have installed amavis,clamav,spamassasin.
    On running php script,does not show any error message,even then mail has not been delivered.
    I have tried telnet localhost 25 it works fine.

    Please help
    The help is greatly appreciated.
    Thanks.

    #2
    Re: Unable to send Email using php mail() to external domain(gmail) from localhost

    I have little experience with mail and postfix, other than knowing it's not the easiest thing to do with IMAP. Perhaps you could consider mutt, it's a client/MTA in one. A good link, should apply to Ubuntu as well:
    http://crunchbanglinux.org/wiki/howt...ith_gmail_imap
    "The only way Kubuntu could be more user friendly would be if it came with a virtual copy of Snowhog and dibl"

    Comment


      #3
      Re: Unable to send Email using php mail() to external domain(gmail) from localhost

      First thing you have to do is determine if postifx is working. I'll give you fair warning -- postfix setup is not trivial, and debugging it via bbs can be a very long and tedious process.

      Check the documentation here:
      https://help.ubuntu.com/community/Postfix

      Once you have it set up, you need to test it with a simple mail client like mail. Logs are in /var/log/mail.err /var/log/mail.info /var/log/mail.warn and /var/log/mail.log . Check them for messages and problems.

      Also, I don't know how you are connecting to the internet, but if through a commercial ISP, many block sending on port 25, and you may need to use a relay. The ISP may provide one, and can give further instructions on how to use it; if not, you may need to use gmail or yahoo.

      When you get postfix working, then you can move on to pear and php (I have no familiarity with either).
      We only have to look at ourselves to see how intelligent life might develop into something we wouldn't want to meet. -- Stephen Hawking

      Comment


        #4
        Re: Unable to send Email using php mail() to external domain(gmail) from localhost

        I have followed the help.ubuntu.com/comunity/postfix.And I tried to send email from KMailbut an error message is poped up.

        telnet localhost 25 is running when executed in the terminal.
        I have attached the snapshot of error message,Could anybody please explain why this error has occured

        Thanks
        Attached Files

        Comment


          #5
          Re: Unable to send Email using php mail() to external domain(gmail) from localhost

          Looks like kmail isn't set up for using postfix.

          First see if postfix is running:

          sudo service postfix status

          I don't know the details of setting up kmail, maybe someone else does.

          We only have to look at ourselves to see how intelligent life might develop into something we wouldn't want to meet. -- Stephen Hawking

          Comment


            #6
            Re: Unable to send Email using php mail() to external domain(gmail) from localhost

            Are you getting bounce messages from the receiving domain?

            postfix listening on port 25 only tells you postfix is listening on port 25

            What do your mail logs say?

            edit: Try tailing the mail log - in a terminal window,

            tail -f /var/log/maillog

            then try sending an email. tail will update the terminal window with information from the log as postfix writes to it. I tail mail logs at work and it's a great way to gather information but we use exim, not postfix - but you can tail any log file; or any text file for that matter

            Ctrl-C to stop tailing.
            we see things not as they are, but as we are.
            -- anais nin

            Comment


              #7
              Re: Unable to send Email using php mail() to external domain(gmail) from localhost

              I have checked the mail.log file in the terminal which shows status=bounced(Host or Domain name does not found.Name service error for name=amruth-xeon.localhost type=AAAA:Host not found).[i]amruth-xeon is my computer name[/i]

              While configuring the postfix I have given the system mail name as localhost,but it suggests that mail name must be (eg myname@example.com) in this case example.com,but how can I give mail name for localhost as it is my domain,Is it possible?
              Thanks

              Comment


                #8
                Re: Unable to send Email using php mail() to external domain(gmail) from localhost

                Originally posted by amruthxeon
                I have checked the mail.log file in the terminal which shows status=bounced(Host or Domain name does not found.Name service error for name=amruth-xeon.localhost type=AAAA:Host not found).[i]amruth-xeon is my computer name[/i]

                While configuring the postfix I have given the system mail name as localhost,but it suggests that mail name must be (eg myname@example.com) in this case example.com,but how can I give mail name for localhost as it is my domain,Is it possible?
                This is a DNS issue. The receiving mail server bounced your email because your IP address didn't resolve to a registered domain (the AAAA record means they're looking for an IPV6 DNS entry).

                You have two choices - either have your ISP create A, AAAA, MX and PTR records for your mail server or run your own DNS and create the entries yourself.

                Short version - the mail servers aren't gonna talk to you unless youor domain name resolves to a valid domain.

                Hope this helps -
                we see things not as they are, but as we are.
                -- anais nin

                Comment


                  #9
                  Re: Unable to send Email using php mail() to external domain(gmail) from localhost

                  The other option is to use a mail relay, such as gmail or yahoo. If you have an email account with a service that offers POP access, they almost certainly also offer SMTP relay.

                  A lot of this depends on what you are trying to do. If you are running a website with a registered domain name through a hosting service, then you should do as suggested -- have your service set up the appropriate records for you. If you are running it yourself, then set them up on your own server, but there again, if you are going through an ISP, they probably block direct SMTP as a spam prevention measure, and you will need to discuss with them how to get it going.

                  If this is something you are running on your own desktop through an ISP, and you have an email account with your ISP, then mail relay is the way to go. It is similar to the way you set up Thunderbird for email. Unfortunately, you can't just set up a mail server and talk to the world these days. In the old days, you could do that, but the internet is no longer the "free and open" environment it is so often touted as being. As you have discovered.
                  We only have to look at ourselves to see how intelligent life might develop into something we wouldn't want to meet. -- Stephen Hawking

                  Comment


                    #10
                    Re: Unable to send Email using php mail() to external domain(gmail) from localhost

                    Thanks all of you for your precious tips and suggestions.

                    Comment

                    Working...
                    X