Welcome Guest, Not a member yet? Register   Sign In
Does Gmail API Support Codeigniter Without SMTP?
#1

Does Gmail API Support Codeigniter? I searched on the internet and just found the code using the SMTP server only. I want to use Gmail API instead of SMTP. It will be really appreciated if you guys can help me with it... Smile
Reply
#2

See https://developers.google.com/gmail/api/quickstart/php
Reply
#3

(This post was last modified: 11-30-2021, 02:04 AM by captain-sensible.)

if your question is can you use gmail , say for using with a contact form , in a view on your web , so that you can get feedback /messages from web surfers, then the answer is yes.

The text entered into the form in my case , I use POST to a route, and the route then evokes a controller class and a method to do the processing . In the controller I make use of PHPMAiler library .

There is a codeigniter class for using SMTP but to be honest couldn't get my head; i'm using PHPMailer and have had no problems.

The section to use google in a contoller using PHPMAILer is along the lines of is along the lines of :

Code:
<?php namespace App\Controllers;

use CodeIgniter\Controller;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\OAuth;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
use \App\Andy\CheckSpam;
use \App\Andy\Utility;
use CodeIgniter\I18n\Time;

Obviously those more clever than me won't do it directly in a controller but use a manager class or something

then :

Code:
$mail->Host = 'smtp.gmail.com';
                            $mail->Port = 587;
                            $mail->SMTPSecure = 'tls';        
                            $mail->SMTPAuth = true;
                            //Username to use for SMTP authentication - use full email address for gmail
                            $mail->Username = "[email protected]";
                            //Password to use for SMTP authentication
                            $mail->Password = "passwordGeneratedByGoogle2Step";

i put PHPMailer at web root then used in autoloader:

Code:
ublic $psr4 = [
        APP_NAMESPACE => APPPATH, // For custom app namespace
        
        
        'Config'      => APPPATH . 'Config',
        'PHPMailer\\PHPMailer'=> ROOTPATH.'PHPMailer/src',
        
        
    ];


if thats not your question can you elaborate. Just re-read your post - you don't want to use SMTP never mind my post might give option/ help other user ?
Reply
#4

Hello, Can i use Gmail Api in codeigniter to send emails or not?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB