• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Sending Mail From Web Server via Google Apps

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?
0
kiloelectronvolt
Asked:
kiloelectronvolt
1 Solution
 
singh677Linux AdministratorCommented:
Hello,

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

<?php
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.
0
 
kiloelectronvoltAuthor Commented:
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?
0
 
Allen FalconCEO & Pragmatic EvangelistCommented:
Are the forms from the web site sending emails to addresses in your domain or external?  

Also, did you look at using Google Forms?
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
kiloelectronvoltAuthor Commented:
We used a different plug-in for Wordpress in the end. Thanks!
0
 
Jason C. LevineNo oneCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now