Email Functions
$t->Email
The Blink Mobility Platform has a simple email helper located at $t->email.
$t->email sends an email to specified email address, from another specified email
Parameters # | An array of options including the following. |
---|---|
$to | Email address that is to receive the email |
$subject | Subject heading of the email |
$body | The main body of the email |
$from | Senders email address. If this is left blank it will send from bmp@blinkmobile.com.au |
$cc | Email address to send a Carbon Copy to |
$bcc | Email address to send a Blind Carbon Copy to |
$attachments | The attachments to send with the email attachments |
$replyto | he reply to email address |
Notes #
cc - Carbon Copy indicates that you are getting a copy but are not the primary addressee.
Carbon copy also allows all recipients to see who else has received the mail.
bcc - Blind Carbon Copy is the same as Carbon Copy except that the address in bcc: is hidden from all recipients in To: and cc:
$email_txt = "This is the body of the email."; $t->email("reciever.address@email.com","example subject heading",$email_txt,"sender.address@email.com","carbon.copy@email.com","hidden.email@bussiness.com");
Sending images as attachments
Custom Code Area
$donotsave = true; // First, base64 decode the raw image data sent by Blink $img = base64_decode($data['foto']); // Then attach the image $t->AddStringAttachment($img, 'photo.png', 'base64', 'image/png'); // Then send your email $t->email('test@test.com', 'subject', 'email body');
Complex Emails
For complicated emails (i.e. multiple attachments, from, cc, bcc, reply-to, html emails etc) the PHPMailer library is included: http://phpmailer.worxware.com/index.php?pg=methods.
A complicated example could look like this:
Custom Code Area
$subject = "Some Council online enquiry - {$data['type']}";$msg = "<p> <b>Enquiry about:</b> {$data['type']}<br /> <b>How can we help:</b> " . nl2br($data['message']) ."<br /> <b>Does your enquiry relate to a specific address:</b> {$data['specific_address']}<br />"; if ($data['specific_address'] == 'Yes') { $msg .= "<b>Address:</b> {$data['street']}<br /> <b>Suburb:</b> {$data['suburb']}<br />"; } $msg .= "<br /> <b>Full name:</b> {$data['name']}<br /> <b>Phone number:</b> {$data['phone']}<br /> <b>Email address:</b> {$data['email']}<br /><br /> <b>Would you require a copy of the email:</b> {$data['copy']}"; $mail = new PHPMailer(); $mail -> charSet = "UTF-8"; //Override default encoding $mail->SetFrom ('no-reply@somecouncil.gov.au', 'no-reply'); //Change the reply to address $mail->ClearReplyTos(); $mail->AddReplyTo($data['email'], $data['name']); $mail->addAddress('enquiry@somecouncil.gov.au'); $mail->Subject = $subject; $mail->MsgHTML($msg);// Sets body and configures headers to HTML type. if ($data['copy'] === 'Yes') { $mail->AddCC($data['email']); //Adds user to CC if they have opted in } if (isset($data['image']) && !empty($data['image'])) { $img = base64_decode($data['image']); $mail->AddStringAttachment($img, 'photo.png', 'base64', 'image/png'); //If the user has included an image, we can attach it easily. } $mail->Send();