Mengirim QRCode ke Gmail dengan PHPMailer

Ditanyakan pada tanggal 7 May 2019 oleh Ryan Kurniawan

Saya sedang membuat sebuah form register yang nantinya akan generate qrcode lalu dikirim ke gmail. Mungkin kalau dilihat lagi yg saya generate itu name, tapi nantinya yg saya generate adalah id. Yang jadi permasalahan, bagaimana syntax CI agar qrcode ini terkirim ke gmail, mungkin ada yg pernah pakai. Atau ada saran selain PHPMailer.

    $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 = '[email protected]';
    $mail->Password = '******';
    $mail->SMTPSecure = 'tls';
    $mail->Port     = 587;

    $mail->setFrom('[email protected]', 'RyanK');
    $mail->addReplyTo('[email protected]', 'RyanK');

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

    // Add cc or bcc 
    $mail->addCC('[email protected]');
    $mail->addBCC('[email protected]');

    // 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>qr code di sini</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';
    }

1 JAWABAN / 1 KOMENTAR

Generic placeholder image
Hermansyah menjawab 3 bulan yang lalu

qr codenya dalam bentuk gambar? atau raw string yang bakal di convert ke qr code?

kalau dalam bentuk gambar bisa diunggah aja gambar qr codenya ke hosting di $mailContent bisa pakai html, pakai img src link ke gambar qrcodenya

Comment ..

iya sudah fix mas, dlm bentuk gambar tinggal di src aja. Terima kasih

Dikomentari 3 bulan yang lalu oleh Ryan Kurniawan