Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHPMailer(CodeIgniter 3)向Gmail发送QRCode_Php_Gmail_Phpmailer_Codeigniter 3 - Fatal编程技术网

如何使用PHPMailer(CodeIgniter 3)向Gmail发送QRCode

如何使用PHPMailer(CodeIgniter 3)向Gmail发送QRCode,php,gmail,phpmailer,codeigniter-3,Php,Gmail,Phpmailer,Codeigniter 3,我有一些脚本Codeigniter,用户需要在其中注册,qrcode被发送到用户的gmail。但是,如何发送呢?变量为$mailContent 这是我的密码 $name = $this->input->post('name'); $email = $this->input->post('email'); $no_hp = $this->input->post('no_hp'); $gen = $t

我有一些脚本Codeigniter,用户需要在其中注册,qrcode被发送到用户的gmail。但是,如何发送呢?变量为
$mailContent

这是我的密码

        $name = $this->input->post('name');
        $email = $this->input->post('email');
        $no_hp = $this->input->post('no_hp');
        $gen = $this->input->post('gen');
        $method = $this->input->post('method');

        $this->load->library('ciqrcode');

        $config['cacheable']    = true; //boolean, the default is true
        $config['cachedir']     = './assets/'; //string, the default is application/cache/
        $config['errorlog']     = './assets/'; //string, the default is application/logs/
        $config['imagedir']     = './assets/images/'; 
        $config['quality']      = true; //boolean, the default is true
        $config['size']         = '1024'; //interger, the default is 1024
        $config['black']        = array(224,255,255); // array, default is array(255,255,255)
        $config['white']        = array(70,130,180); // array, default is array(0,0,0)
        $this->ciqrcode->initialize($config);

        $image_name=$name.'.png'; 

        $params['data'] = $name; 
        $params['level'] = 'H'; //H=High
        $params['size'] = 10;
        $params['savename'] = FCPATH.$config['imagedir'].$image_name; 
        $this->ciqrcode->generate($params); 

        //PHP Mailer
        // Load PHPMailer library
        $this->load->library('phpmailer_lib');

        // PHPMailer object
        $mail = $this->phpmailer_lib->load();

        // SMTP configuration
        $mail->isSMTP();
        $mail->Host     = 'smtp.gmail.com';
        $mail->SMTPAuth = true;
        $mail->Username = 'xxxxx@gmail.com';
        $mail->Password = '******';
        $mail->SMTPSecure = 'tls';
        $mail->Port     = 587;

        $mail->setFrom('xxxxx@gmail.com', 'RyanK');
        $mail->addReplyTo('xxxxx@gmail.com', 'RyanK');

        // Add a recipient
        $mail->addAddress($email);

        // Add cc or bcc 
        $mail->addCC('cc@example.com');
        $mail->addBCC('bcc@example.com');

        // Email subject
        $mail->Subject = 'Send Email via SMTP using PHPMailer in CodeIgniter';

        // Set email format to HTML
        $mail->isHTML(true);

        // Email body content
        $mailContent = "<h1>Send HTML Email using SMTP in CodeIgniter</h1>
            <p></p>";
        $mail->Body = $mailContent;

        // Send email
        if(!$mail->send()){
            echo 'Message could not be sent.';
            echo 'Mailer Error: ' . $mail->ErrorInfo;
        }else{
            echo 'Message has been sent';
        }
$name=$this->input->post('name');
$email=$this->input->post('email');
$no_hp=$this->input->post('no_hp');
$gen=$this->input->post('gen');
$method=$this->input->post('method');
$this->load->library('ciqrcode');
$config['cacheable']=true//布尔值,默认值为true
$config['cachedir']='./资产/'//字符串,默认值为应用程序/缓存/
$config['errorlog']='./资产/'//字符串,默认值为应用程序/日志/
$config['imagedir']='./assets/images/';
$config['quality']=true//布尔值,默认值为true
$config['size']='1024'//整数,默认值为1024
$config['black']=数组(224255255);//数组,默认为数组(255255)
$config['white']=数组(70130180);//数组,默认为数组(0,0,0)
$this->ciqrcode->initialize($config);
$image_name=$name.'.png';
$params['data']=$name;
$params['level']='H'//H=高
$params['size']=10;
$params['savename']=FCPATH.$config['imagedir'].$image\u name;
$this->ciqrcode->generate($params);
//PHP邮件程序
//加载PHPMailer库
$this->load->lib('phpmailer_lib');
//PHPMailer对象
$mail=$this->phpmailer_lib->load();
//SMTP配置
$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->SMTPAuth=true;
$mail->Username=xxxxx@gmail.com';
$mail->Password='******';
$mail->SMTPSecure='tls';
$mail->Port=587;
$mail->setFrom('xxxxx@gmail.com","RyanK",;
$mail->addReplyTo('xxxxx@gmail.com","RyanK",;
//添加收件人
$mail->addAddress($email);
//添加抄送或密件抄送
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
//电子邮件主题
$mail->Subject='使用CodeIgniter中的PHPMailer通过SMTP发送电子邮件';
//将电子邮件格式设置为HTML
$mail->isHTML(true);
//电子邮件正文内容
$mailContent=“在CodeIgniter中使用SMTP发送HTML电子邮件

”; $mail->Body=$mailContent; //发送电子邮件 如果(!$mail->send()){ echo“无法发送消息”; 回显“邮件错误:”。$mail->ErrorInfo; }否则{ 回音“消息已发送”; }
您已经在使用它设置
$mail->Body=$mailContent中的
Body
属性。要从外部文件添加图像,请执行以下操作:

$mail->addAttachment('path/to/file.png');
如果二维码生成器创建包含PNG数据的二进制字符串,请使用:


或者,您可能希望嵌入它并创建对它的引用,以便在邮件正文中使用。

您已经在使用它设置
$mail->body=$mailContent。要从外部文件添加图像,请执行以下操作:

$mail->addAttachment('path/to/file.png');
如果二维码生成器创建包含PNG数据的二进制字符串,请使用:

或者,您可能希望嵌入它并创建对它的引用,以便在消息体中使用