This topic is locked

Send HTML Email with QR Code

7/4/2014 5:56:36 AM
PHPRunner Tips and Tricks
romaldus author


2. For this tutorial, i create a "customer database" in MysQL with following database structure:




[color="#0000FF"]4. Extract all the PHP QR Code to the root directory of your generated project as you see in screenshot :


5. Create a [color="#FF0000"]generated_barcode folder in your project directory[/b][/color]
6.


//email_address field name in your database table

$email=$values["email_address"];
//replace email with your own domain

$from="admin@yourdomain.com";

$msg="";

$subject="QR code sample";
$msg.= "Dear \n";
//get customer name from database

$msg.= "<b>".$values["customer_name"]."</b> \n";

$msg.= "This is a sample QR Code.\n";
//include qrlib.php. If you extract qrcode in other directory (not in root of your project), please make change the following line

include "qrlib.php";
//define a directory in web server to store generated QR Code

$myBarcodeDir = 'generated_barcode/';
//Content of the QR Code

$codeContents = $values["customer_id"].$values["customer_name"];
//filename of the generated QR Code (value of customer_id field)

$fileName = $values["customer_id"].'.png';
$pngAbsoluteFilePath = $myBarcodeDir.$fileName;

$urlRelativeFilePath = 'generated_barcode/'.$fileName;
//QR_ECLEVEL_L is parameter of the generated barcode. Please read the QR Code manual for other parameters

QRcode::png($codeContents, $pngAbsoluteFilePath, QR_ECLEVEL_L, 4);
$msg.= "<hr> \n";

$msg.= "<hr> \n";
//send email with generated barcode

$msg.='<img src="'.$urlRelativeFilePath.'" />';

$msg.= "<hr> \n";
//replace cc email with your own email

$ret=runner_mail(array('to' => $email, 'cc' => 'someone@anydomain.com', 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];




[color="#0000FF"]7. Done. Generate your phprunner project and upload generated project to your web server


9. [color="#0000FF"]Screenshot of generated QR Code in [color="#FF0000"]generated_barcode folder.[/color]



[color="#0000FF"]
11. Sory for my poor english <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=22390&image=6&table=forumtopics' class='bbc_emoticon' alt=':)' />