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

Asked by:
richard87 / 13 Points
2012-11-30 2:38 pm EST
Send Email From A Page
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?


To ask this user for more information, please first login.

To submit an answer, please login.



3,713 Points
2012-11-30 3:54 pm EST
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:


function smtp_mail($to, $subject, $body){

$smtp = new PHPMailer();

$smtp->SMTPAuth = true;
$smtp->SMTPSecure = "ssl";
$smtp->Host = "";
$smtp->Port = 465;
$smtp->Username = "";
$smtp->Password = "password";

$smtp->SetFrom("", "User name");

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



smtp_mail("", "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

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: 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.