Sending Mail From Web Server via Google Apps

Posted on 2011-04-20
Last Modified: 2012-05-11
We use Google Apps for email and our new website contains forms. For some reason we can't send messages processed by the form using our domain name (so the messages arrives from an email address using our domain name). I have a feeling I need to authorise sending emails using the web server with Google Apps. I'm not sure how to do this, I'm thinking I need to add an SRV record which contains the IP address of our web server?
Question by:kiloelectronvolt
    LVL 2

    Expert Comment


    You can send mail through your domain name using below mail script.

    require_once "Mail.php";

            $from = "test <>";
            $to = "singh <>";
            $subject = "Hi!";
            $body = "Hi,\n\nHow are you?";

            $host = "ssl://";
            $port = "465";
          $username = "";
            $password = "w4o8Y8KOuv1";

            $headers = array ('From' => $from,
              'To' => $to,
              'Subject' => $subject);
            $smtp = Mail::factory('smtp',
              array ('host' => $host,
                'port' => $port,
                'auth' => true,
                'username' => $username,
                'password' => $password));

            $mail = $smtp->send($to, $headers, $body);

            if (PEAR::isError($mail)) {
              echo("<p>" . $mail->getMessage() . "</p>");
             } else {
              echo("<p>Message successfully sent!</p>");


    Note :: Make sure the port 465 must be open your networks/firewall.

    Author Comment

    Thanks Singh677, But do I need a SRV record in the domain name or Google won't authorise sending the messages via their SMTP. That's the issue I think?
    LVL 14

    Expert Comment

    by:Allen Falcon
    Are the forms from the web site sending emails to addresses in your domain or external?  

    Also, did you look at using Google Forms?
    LVL 31

    Accepted Solution


    Author Comment

    We used a different plug-in for Wordpress in the end. Thanks!
    LVL 70

    Expert Comment

    by:Jason C. Levine
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    When the confidentiality and security of your data is a must, trust the highly encrypted cloud fax portfolio used by 12 million businesses worldwide, including nearly half of the Fortune 500.
    Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    755 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

    25 Experts available now in Live!

    Get 1:1 Help Now