wecuro_blog/application/helpers/email_helper.202103151701.php

166 lines
8.4 KiB
PHP
Executable File

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function send_email($from,$to,$subject,$message){
$CI = &get_instance();
//echo APPPATH;
//$messages='<h3>Test</h3>';
$ch = curl_init();
$senddata = '{
"Messages":[
{
"From": {
"Email": "ujjwal@sentientgeeks.com",
"Name": "Ujjwal"
},
"To": [
{
"Email":"'.$to.'"
}
],
"Subject": "'.$subject.'",
"HTMLPart": "'.$message.'"
}
]
}';
//echo $senddata;die;
$username='bad29f69421a73e83da553fafda450a2';
$password='8ace947e7398c99ec88b2f9646e1a057';
$headers = array(
'Content-Type:application/json'
//'Authorization: Basic YmFkMjlmNjk0MjFhNzNlODNkYTU1M2ZhZmRhNDUwYTI6OGFjZTk0N2U3Mzk4Yzk5ZWM4OGIyZjk2NDZlMWEwNTc='
);
curl_setopt($ch, CURLOPT_URL, "https://api.mailjet.com/v3.1/send");
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$senddata);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"cc\":[\"cc@example.net\":\"cc whom!\"],\"text\":\"This is the text\",\"bcc\":[\"ujjwal@sentientgeeks.com\":\"bcc whom!\"],\"replyto\":[\"ujjwal@sentientgeeks.com\",\"reply to!\"],\"html\":\"This is the <h1>HTML</h1>This is inline image 1.<br/><img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/>Some text<br/>This is inline image 2.<br/><img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/>Some more text<br/>Re-used inline image 1.<br/><img src=\"{myinlineimage1.png}\" alt=\"image3\" border=\"0\">\",\"to\":{\"ujjwal@sentientgeeks.com\":\"to whom!\"},\"attachment\": {\"myfilename.pdf\":\"your_pdf_files_base64_encoded_chunk_data\"},\"from\":[\"ujjwal@sentientgeeks.com\",\"from email!\"],\"subject\":\"My subject\",\"headers\":{\"Content-Type\":\"text/html; charset=iso-8859-1\", \"X-param1\":\"value1\",\"X-param2\":\"value2\", \"X-Mailin-custom\":\"my custom value\",\"X-Mailin-IP\":\"102.102.1.2\", \"X-Mailin-Tag\":\"My tag\"},\"inline_image\":{\"myinlineimage1.png\":\"your_png_files_base64_encoded_chunk_data\", \"myinlineimage2.jpg\":\"your_jpg_files_base64_encoded_chunk_data\"}}");
curl_setopt($ch, CURLOPT_POST, 1);
//$headers = array();
//$headers[] = "user: bad29f69421a73e83da553fafda450a2:8ace947e7398c99ec88b2f9646e1a057";
//$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print_r($result);
// require_once(APPPATH.'sendgrid-php/sendgrid-php.php');
// include APPPATH . 'sendgrid-php/sendgrid-php.php';
// $email = new \SendGrid\Mail\Mail();
/*
$email->setFrom("setfrom@test.com", "testname");
$email->setSubject("MailTest");
$email->addTo('tomail@gmail.com', "User");
$email->addContent("text/plain", "subject");
$email->addContent(
"text/html",'<html><body>Message</body><html>');
$sendgrid = new \SendGrid(('sendgrid-API-KEY_HERE'));
try {
$response = $sendgrid->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."\n";
}
/*
$CI->load->library('email');
/*
$config['protocol'] = 'smtp';
//$config['smtp_host'] = 'smtp.mailtrap.io';
$config['smtp_host'] = 'smtp.sendgrid.net';
$config['smtp_port'] = '587';
$config['smtp_timeout'] = '30';
// $config['smtp_user'] = '505a0d93534180';
// $config['smtp_pass'] = '07433d0ae4879d';
$config['smtp_user'] = 'apikey';
$config['smtp_pass'] = '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';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['mailtype'] = 'html'; // or html
$config['validation'] = TRUE; // bool whether to validate email or not
$CI->email->initialize(array(
'protocol' => 'smtp',
'smtp_host' => 'smtp-relay.sendinblue.com',
'smtp_user' => 'ujjwal@sentientgeeks.com',
'smtp_pass' => '4zT95dpUAYCNLnEO',
'smtp_port' => 587,
'crlf' => "\r\n",
'newline' => "\r\n"
));
//$CI->email->initialize($config);
//$CI->load->library('email');
$CI->email->from($from['email'],$from['name']);
$CI->email->to($to);
$CI->email->subject($subject);
$CI->email->message($message);
$CI->email->send();
echo $CI->email->print_debugger();
*/
}
function cgq_email($to,$subject,$token)
{
$msg= "<!DOCTYPE html><html lang='en' xmlns='http://www.w3.org/1999/xhtml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='x-apple-disable-message-reformatting'><title></title><link href='https://fonts.googleapis.com/css?family=Playfair+Display:400,400i,700,700i' rel='stylesheet'></head><body width='100%' style='margin: 0; padding: 0 !important;'><div style='width: 100%;'><div style='max-width: 600px; margin: 0 auto;' class='email-container'><table role='presentation' cellspacing='0' cellpadding='0' style='margin: auto;border-spacing: 0 !important; border-collapse: collapse !important;text-align: center;border: 0;width: 100%;'><tr><td class='bg_white logo' style='padding: 1em 2.5em; text-align: center'><h1 style='margin: 0;'><a href='#'><img style='width: 75px;' src='<?php echo base_url(); ?>common/app-assets/images/logo/logo.png' width='75' /></a></h1></td></tr><tr><td valign='middle' class='bg_light email-section' style='height: 300px;padding: 1.5em;background: #fafafa;'><table><tr><td><div class='text' style='padding: 0 3em; text-align: center;'><h2 style='font-family: 'Playfair Display', serif;color: #000000;margin-top: 0;'>Onboarding Video And Quiz</h2><p style='font-family: 'Montserrat', sans-serif; font-weight: 400; font-size: 15px; line-height: 1.8; color: rgba(0,0,0,.4);'>Congratulations your deocuments are successfully verified, now you are on the final step of onboarding video tutorial and Quiz process. Just click on the link below to complete the on boarding process.</p><p><a href='".base_url()."onboarding/process/".$token."' class='btn btn-primary' style='border-radius: 30px;background: #f3a333;text-decoration: none; color: #ffffff;padding: 10px 15px;font-family: 'Montserrat', sans-serif; font-weight: 400;font-size: 15px;line-height: 1.8;'>Click Here</a></p></div></td></tr></table></td></tr></table><table style='align-items: center;margin: auto;width: 100%;border: 0;border-spacing: 0 !important; border-collapse: collapse !important;'role='presentation' cellspacing='0' cellpadding='0'><tr><td valign='middle' class='bg_black footer email-section' style='padding: 1.5em;background: #000000;'><table><tr><td valign='top' width='33.333%'><table role='presentation' cellspacing='0' cellpadding='0' style='width: 100%;border: 0;'><tr><td style='text-align: left; padding-right: 10px;text-align: center;'><p style='color: rgba(255,255,255,.5);font-family: sans-serif; font-weight: 400; font-size: 15px; line-height: 1.8;'>&copy; 2021 We Curo. All Rights Reserved</p></td></tr></table></td></tr></table></td></tr></table></div></div></body></html>";
$message = $msg;
// echo $message;
// die();
$CI = &get_instance();
$ch = curl_init();
$senddata = '{
"Messages":[
{
"From": {
"Email": "ujjwal@sentientgeeks.com",
"Name": "Ujjwal"
},
"To": [
{
"Email":"'.$to.'"
}
],
"Subject": "'.$subject.'",
"HTMLPart": "'.$message.'"
}
]
}';
$username='bad29f69421a73e83da553fafda450a2';
$password='8ace947e7398c99ec88b2f9646e1a057';
$headers = array(
'Content-Type:application/json'
//'Authorization: Basic YmFkMjlmNjk0MjFhNzNlODNkYTU1M2ZhZmRhNDUwYTI6OGFjZTk0N2U3Mzk4Yzk5ZWM4OGIyZjk2NDZlMWEwNTc='
);
curl_setopt($ch, CURLOPT_URL, "https://api.mailjet.com/v3.1/send");
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$senddata);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
print_r($result);
}
?>