How do I configure my settings to enable php to send email from my google apps account?

Asked by:
richard87
Time:
2012-11-30 6:38 pm
Category:
Send Email From A Page
Hits:
346
Usually I would change my php.ini file and install sendmail but this is my first time using cpanel and I'm not sure how to go about it?

Thanks!

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

JacobN
2012-11-30 7:54 pm
Hello richard87, and thanks for your question.

In some cases your PHP application should already have the option built in to use SMTP authentication instead of the default PHP mail() function. If this is the case then you can go ahead and simply fill in your details for your Google Apps account in that section.

If your application doesn't have this built in already, then you would need to set this up somehow in your PHP code to allow for remote SMTP connections.

A very common method used is the PHPMailer class available at:

PHPMailer - Full Featured Email Transfer Class for PHP

Then you would load up that class in your PHP script and utilize it with something along these lines:


<?php

function smtp_mail($to, $subject, $body){
require_once("class.phpmailer.php");

$smtp = new PHPMailer();

$smtp->SMTPAuth = true;
$smtp->SMTPSecure = "ssl";
$smtp->Host = "smtp.gmail.com";
$smtp->Port = 465;
$smtp->Username = "username@gmail.com";
$smtp->Password = "password";

$smtp->SetFrom("username@gmail.com", "User name");

$smtp->Subject = $subject;
$smtp->Body = $body;

$smtp->AddAddress($to);
$smtp->Send();

unset($smtp);
}

smtp_mail("recipient@domain.com", "PHP Test using SMTP", "This is a test")

?>


I hope that information answered your question. If you have any further questions at all please feel free to ask away!

- Jacob

You must login before you can post a comment about this answer.

Like this Question?

Have a Question?

If you need some help, submit your question to our Community! We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)

Recent Questions

  1. my email is being rejected
  2. Can I run the FiverrScript on my hosting
  3. SQL database password

Support Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.