使用Codeigniter在邮件中发送PHP变量数据


send php variable data in mail using codeigniter

你好,我是codeigniter的新手。这似乎是一个简单的问题。但我不知道如何解决它。

在我的应用程序中,我必须将数据发送给用户。该数据将包括 php 变量,现在我如何将这些变量作为消息发送。

这是我的代码

要通过电子邮件发送的配置设置

$config = Array(        
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'user@gmail.com',
        'smtp_pass' => '******',
        'smtp_timeout' => '4',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
        $this->load->library('email', $config);
        $this->email->set_newline("'r'n");

电子邮件代码是

$phpVariable="some data";       
    $message="<html><body><span>This is php data $phpVariable</span></body></html>";
 $this->email->from('review@findacarehome.com','Review for Find a care home');
        $this->email->to('anotheruser@gmail.com');
        $this->email->Subject('Subject');
        $this->email->message($message);
        $this->email->send();

请帮助我,我没有收到错误,我只是在没有php数据的情况下收到邮件

尝试在变量周围使用 {},应该可以。

$message="<html><body><span>This is php data {$phpVariable}</span></body></html>";

尝试:

$message="<html><body><span>This is php data " . $phpVariable . "</span></body></html>";