0

你好我对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 数据的情况下收到邮件

4

2 回答 2

1

尝试:

$message="<html><body><span>This is php data " . $phpVariable . "</span></body></html>";
于 2013-11-08T14:35:49.687 回答
1

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

$message="<html><body><span>This is php data {$phpVariable}</span></body></html>";
于 2013-11-08T14:36:03.570 回答