Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Sending Mail From Web Server via Google Apps

Posted on 2011-04-20
Medium Priority
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

Expert Comment

ID: 35432008

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

require_once "Mail.php";

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

        $host = "ssl://smtp.gmail.com";
        $port = "465";
      $username = "user@domain.com";
        $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

ID: 35432016
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 15

Expert Comment

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

Also, did you look at using Google Forms?
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 31

Accepted Solution

gwkg earned 2000 total points
ID: 35444474

Author Comment

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

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the spotlight very much on Cloud technology within the IT industry, it’s difficult to avoid the topic these days. Due to the constant flood of new information, added pressure, emphasis and focus on cloud migration is driving corporations to in…
As we talk to multiple clients across the globe, one common discussion thread seems to be that DevOps for one company, may not necessarily be the same as for another company.
The viewer will learn how to dynamically set the form action using jQuery.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Suggested Courses

564 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