View Full Version : Send e-mail on button click.

02-11-2010, 08:13 PM
Hi there,

I've a new plan. Basically, I now want to send a HTML e-mail to the corresponding person. Here's a brief:

User clicks on a button, sends a HTML e-mail (code below) to the e-mail which would be carried over via the URL by using GET. E-mail output by a left join.
HTML E-mail sends

How would I accomplish this?

Any code would be greatly appreciated.


<style type="text/css">
text-align: center;

width: 1648px;
height: 821px;
margin: 0 auto;
background: url('/img/certjpg.jpg');
margin-left: -10px;
margin-top: -10px;
margin-bottom: -10px;

padding-top: 33em;
float: left;
padding-left: 9em;
width: 900px;
height: 80px;
background: none;
font-family: georgia;
color: #fff;
font-size: 50px;
text-align: center;
border: 0;

<div id="cert">

<div id="input">
<input type=xt class="input" name="name" value="<?php echo $_GET['name'] ?>" readonly>



02-12-2010, 11:41 AM
Thankfully emailing is quite simple in PHP

* Send an email
* @param array $recipients Recipients to send to
* @param string $subject The Email Subject
* @param string $body - The Email body
* @param string $headers - Email headers if any
function sendMail(array $recipients, $subject, $body, $headers = null) {
foreach($recipients as $to) {
mail($to, $subject, $body, $headers);

Then call using

$subject = 'Your Subject';
$body = 'Your Body'

$recipients[] = "Blah@Blah.com";
$recipients[] = "Blah2@Blah2.com";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

sendMail($recipients, $subject, $body, $headers);