How to use Google OAuth in order to use the auto emailer without giving a password?

54 views Asked by At

I am currently building a system and I am using Google OAuth with that Google auto emailer code.

I included this block of code for you to visualize what I wanted to happen.

<?php
  include_once "mailer.php" ;
  $mail = new Mailer();
  $email = "[email protected]";
  $name = "Daniel";
  $subject=  "testing";
  $message = "Why so serious??";
  $mail->mail($email,$subject,$message);

  if(!$email){
    echo " mail not sent  " ;

  }
  else if ($email) {
    echo "mail sent! " ;
  }

Their provided code would usually ask for the password of the account. You actually have to type your password in the code, which is obviously quite dangerous. And the email being used there will be the same email account used when the system generates automated email. (which means only one email address will be used in the auto-emails regardless whoever is logged in).

What I wanted to do was to use the email address of whoever is logged in when sending an auto email.

1

There are 1 answers

1
bhuvy On

Why not use http://framework.zend.com/manual/1.12/en/zend.mail.introduction.html . The folks at Google are secular kings for those of us in programming, but I love Zend Framework because it is easy and uses PHP's innate mail send abilities. Try it out, I think it may fit the bill.