I have a web application built with CodeIgniter 3. Tank auth is used as authentication layer. Emails will be sent to users based on accounts created and other triggers. I do not want users see my actual from email address but noreply@example.com
.
I use Gmail SMTP configurations:
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "
";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'xxxx@gmail.com';
$config['smtp_pass'] = 'xxxx';
And here is my testing mail function:
$from = $reply_to = 'noreply@example.com';
$subject = lang('test_send_email_subject');
$this->config->load('email', TRUE);
$email_config = $this->config->item('email');
$this->load->library('email', $email_config);
$this->email->from($from, 'example');
$this->email->reply_to($reply_to, 'example');
$this->email->to($to);
$this->email->subject($subject);
$this->email->message(lang('test_send_email_message'));
$result = $this->email->send(FALSE);
$this->session->set_flashdata('debugger_result', $this->email->print_debugger());
The debugger result I got is actually correctly showing from email address as noreply@example.com, which is what I set in codes:
220 smtp.gmail.com ESMTP i192sm2099289lfb.14 - gsmtp
hello: 250-smtp.gmail.com at your service, [89.166.7.101]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
from: 250 2.1.0 OK i192sm2099289lfb.14 - gsmtp
to: 250 2.1.5 OK i192sm2099289lfb.14 - gsmtp
data: 354 Go ahead i192sm2099289lfb.14 - gsmtp
250 2.0.0 OK 1454662672 i192sm2099289lfb.14 - gsmtp
quit: 221 2.0.0 closing connection i192sm2099289lfb.14 - gsmtp
Your message has been successfully sent using the following protocol: smtp
User-Agent: CodeIgniter
Date: Fri, 5 Feb 2016 16:57:50 +0800
From: "example" <noreply@example.com>
Return-Path: <noreply@example.com>
Reply-To: "example" <noreply@example.com>
To: xxx@example.com
Subject: Test Email
X-Sender: noreply@example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <56b4640e47745@example.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_56b4640e4776b"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_56b4640e4776b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a test email, nice to know it works.
--B_ALT_56b4640e4776b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
This is a test email, nice to know it works.
--B_ALT_56b4640e4776b--
However, the email I received is not:
Please help, thank you.