WAMP Send Email

How do you send emails using plain PHP mail on WAMP on Windows?

Normally, PHP mail works by using Sendmail which is installed on *nixes, so it doesn’t work on a Windows box. However, normally we just rewrite our code to using a SMTP server, but what about when we really don’t want to – or can’t – modify third-party code?

You need WAMP Server installed (of course!) and http://glob.com.au/sendmail/

Now, we need to edit C:wampsendmailsendmail.ini:

[php]

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password

[/php]

Now we need to edit php.ini and set sendmail_path:
[php]sendmail_path = "C:wampsendmailsendmail.exe -t"[/php]

Now, restart Apache, and that is basically all you need to do. Now we can’t wait to test if it works!
[php]
$to      = ‘some@email.here’;
$subject = ‘Fake sendmail test’;
$message = ‘If we can read this, it means that our fake Sendmail setup works!’;
$headers = ‘From: your@email.here’ . "rn" .
‘Reply-To: your@email.here’ . "rn" .
‘X-Mailer: PHP/’ . phpversion();

if(mail($to, $subject, $message, $headers)) {
echo ‘Email sent successfully!’;
} else {
die(‘Failure: Email was not sent!’);
}
[/php]

Extract Sales Snapshot from mainMenu page

This peace of code bellow will login to your clickbank account and display the ‘Weekly Sales Snapshot’ and ‘Daily Sales Snapshot’ from main page.

[php]

$account_nickname = ‘rapidtrans’;
$baseurl = "https://" . $account_nickname . ".accounts.clickbank.com";
$login_args = array(
"j_username" => $account_nickname,
"j_password" => "WNN9X34K"
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_COOKIEJAR, ‘cookie.txt’);
curl_setopt($curl, CURLOPT_URL,
$baseurl."/account/login");
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($login_args));
$login = curl_exec($curl);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_URL,
$baseurl."/account/mainMenu.htm");
$clickbank_content = curl_exec($curl);
curl_close ($curl);

$pattern = "";
$pattern .= "/<td width="70%" valign="top" align="left">s+?";
$pattern .= "<h2>Weekly Sales Snapshot</h2>s+?";
$pattern .= "(.*?)";
$pattern .= "</td>s+?";
$pattern .= "<td width="60%" valign="top" align="right">/s";

preg_match_all(
$pattern,
$clickbank_content,
$matches,
PREG_SET_ORDER
);

$content_to_display = ‘

‘;
$content_to_display .= ‘

Weekly Sales Snapshot

‘;
$content_to_display .= $matches[0][1];
$content_to_display .= ‘

‘;
echo $content_to_display;

[/php]

 

And some matching css to have the same style as on clickbank.com

[css]

#clickbank1{
background-color:#fff;
padding:10px;
font-family: Verdana;
font-size:12px;
width:250px;
margin:0 auto;
}

#clickbank1 h2{
margin: 0 0 2px;
padding: 0;
color: #BD1E2C;
font-size: 1.5em;

font-weight:bold;
}

#clickbank1 table.list {
border: 2px solid #9B8579;
border-collapse: collapse;
clear: both;
margin: 1px 0 5px;
padding: 0;
width: 100% !important;
}

#clickbank1 table.list thead th {
background-color: #9B8579;
border: 1px solid #EAEBEC;
border-collapse: collapse;
color: #FFFFFF;
font-size: 7pt;
margin: 0;
padding: 3px 5px;
text-align: center;
vertical-align: middle;
}

#clickbank1 table.list tbody tr td {
border: 1px solid #CACBCC;
border-collapse: collapse;
color: #000000;
font-family: verdana;
font-size: 7pt;
margin: 0;
padding: 2px 3px;
}

#clickbank1 .tableColumnDate {
text-align: center;
white-space: nowrap;
}

[/css]

Determine execution time in PHP

[php]

<code><span style="color: #339900;">// put this at the top of the page</span>

   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $starttime = $mtime;

<span style="color: #339900;">// put other code and html in here</span>

<span style="color: #339900;">// put this code at the bottom of the page </span>

   $mtime = microtime();
   $mtime = explode(" ",$mtime);
   $mtime = $mtime[1] + $mtime[0];
   $endtime = $mtime;
   $totaltime = ($endtime – $starttime);
   echo "This page was created in ".$totaltime." seconds";
</code>

[/php]