Email settings for sending email in PHP through custom domain on gmail -


i have custom domain setup on gmail mail.

i have hosted website on different hosting provider , i'm using codeigniter , php send email through account.

what settings need enable sending mail (from contact form) through gmail account? , code need use?

update: i've tried following: - create new email account (@gmail.com, not custom) - enable 2 step verification - generated app-specific password - used send email not working.

here's code i'm using:

$mail = new phpmailer;  $mail->issmtp();                                      // set mailer use smtp $mail->host = 'ssl://smtp.googlemail.com';  // specify main , backup server $mail->smtpauth = true;                               // enable smtp authentication $mail->username = 'samesenderaccount@gmail.com';                            // smtp username $mail->password = 'appspecificpassword';                           // smtp password $mail->smtpsecure = 'ssl';                            // enable encryption, 'ssl' accepted $mail->port = 465;     $mail->from = 'samesenderaccount@gmail.com'; $mail->fromname = 'mailer'; $mail->addaddress('samesenderaccount@gmail.com', 'info');  // add recipient //$mail->addaddress('ellen@example.com');               // name optional $mail->addreplyto('other@gmail.com', 'from try'); //$mail->addcc('cc@example.com'); //$mail->addbcc('bcc@example.com');  $mail->wordwrap = 50;                                 // set word wrap 50 characters                                 // set email format html  $mail->subject = 'here subject'; $mail->body    = 'this html message body in bold!';  if(!$mail->send()) {    echo 'message not sent.';    echo 'mailer error: ' . $mail->errorinfo;    exit; }  echo 'message has been sent'; ?> 

you have use following format send e mail in php codeigniter. might find values change provider.

public function sendmail() {       $config = array(      'protocol' => 'smtp',      'smtp_host' => 'ssl://smtp.googlemail.com',      'smtp_port' => 465,      'smtp_user' => 'axxx@gmail.com', // change yours      'smtp_pass' => '*******', // change yours      'mailtype' => 'html',      'charset' => 'iso-8859-1',      'wordwrap' => true     );        $this->load->library('email', $config);      $this->email->set_newline("\r\n");      $this->email->from('xxx@gmail.com'); // change yours      $this->email->to('yyy@gmail.com');// change yours      $this->email->subject('subject');// change yours      $this->email->message('message');// change yours       if($this->email->send())     {       //success message     }     else    {     show_error($this->email->print_debugger());    } } 

you can use variables , pass email, subject, message etc.


Comments