Go Back   eXceem > Websites > Website Discussion


Get a Free iPhone 3GS with Free3GiPhone.com


Reply
 
LinkBack Thread Tools
Old 02-02-10, 09:27 AM   #1
Mini Mac
 
beezer123's Avatar
 
Join Date: Dec 2006
Location: Aberdeenshire
Posts: 3,622
Thanks: 1,276
Thanked 935 Times in 580 Posts
beezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud of
Send a message via MSN to beezer123

Help with an automatic php mailer


Right guys I need to set up an automatic email system that can email a customer 48 hours after they have their appointment to get their tyres fitted.

So far this is what I've come up with.

-I need to set up a cron job to run the script once a day.

Code:
<?php 

//include the connection file

require_once('connection.php');

$query  = "SELECT email FROM table WHERE TO_DAYS(date)=TO_DAYS(NOW())-2";

$object=mysql_fetch_object($query);

mail($object->emailid,'Subject here','Message here'); // more info on this function: http://uk.php.net/manual/en/function.mail.php

echo $object->emailid; // this will echo the users email ID as corresponding to your database. $object-> simply is calling the fields it can corresponding to the query we made, such as $object->emailid;

?>
Would i then need to somehow link this into phpmailer or something?

Just want tips on whether I'm on the right track. These are just snips of code I've found and mashed together.

Cheers
__________________
Currently:



My Sites

Free Nintendo DSi
www.macbook4u.co.uk
Free Android
Free PS3 Games


open spoiler to see what im doing
Spoiler

Last edited by beezer123; 02-02-10 at 09:28 AM..
Offline  
Reply With Quote
Old 02-02-10, 09:43 AM   #2
Mini Mac
 
beezer123's Avatar
 
Join Date: Dec 2006
Location: Aberdeenshire
Posts: 3,622
Thanks: 1,276
Thanked 935 Times in 580 Posts
beezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud of
Send a message via MSN to beezer123
In fact scrap that. I think I've come up with a better code.

Code:
<?php

#include PHPMailer class and database connection
include("class.phpmailer.php");
include("db.php");

#remove slashes from content
$html = stripslashes($_POST["html"]);
$plain = stripslashes($_POST["plain"]);

#initiate PHPMailer class
$mail = new PHPMailer();
#set the from e-mail address
$mail->From = "email@domain.co.uk";
#set the from name
$mail->FromName = "Company Name";
#set the e-mail type to HTML
$mail->IsHTML(true);

#the subject of the email
$mail->Subject = "Our Newsletter";
#the HTML content of the email
$mail->Body = $html;
#the plain text version
$mail->AltBody = $plain;

#loop through e-mail addresses
$query  = "SELECT email FROM table WHERE TO_DAYS(date)=TO_DAYS(NOW())-2";
$result = mysql_db_query ("$databasename", $query);
while ($myrow = mysql_fetch_array($result)){

#add applicable address as the recipient
$mail->AddAddress($myrow["fldEmail"]);
#sends the email
$mail->Send();
#clears the recipient address
$mail->ClearAddresses();

}

?>
__________________
Currently:



My Sites

Free Nintendo DSi
www.macbook4u.co.uk
Free Android
Free PS3 Games


open spoiler to see what im doing
Spoiler
Offline  
Reply With Quote
Old 02-02-10, 09:56 AM   #3
iBook
 
messyhead's Avatar
 
Join Date: Oct 2007
Location: Glasgow
Posts: 2,000
Thanks: 323
Thanked 538 Times in 428 Posts
messyhead is a glorious beacon of lightmessyhead is a glorious beacon of lightmessyhead is a glorious beacon of light
You could have a look at this tutorial for creating a secure mailer script, and adapt it to what you need;

PHP Mail Form: Secure and Protected » tutorialtastic.co.uk

Did you do much PHP on your course - actually, PM on it's way - meant to do that the other day.
__________________
Received about £1600 worth so far!
Spoiler

Online  
Reply With Quote
Old 02-02-10, 09:59 AM   #4
Mini Mac
 
beezer123's Avatar
 
Join Date: Dec 2006
Location: Aberdeenshire
Posts: 3,622
Thanks: 1,276
Thanked 935 Times in 580 Posts
beezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud ofbeezer123 has much to be proud of
Send a message via MSN to beezer123
Quote:
Originally Posted by messyhead View Post
You could have a look at this tutorial for creating a secure mailer script, and adapt it to what you need;

PHP Mail Form: Secure and Protected » tutorialtastic.co.uk

Did you do much PHP on your course - actually, PM on it's way - meant to do that the other day.
Thanks


I did absolutely no PHP during my course and I'm just trying to self teach myself.

I think you did send me a PM but I may be wrong, haven't had a chance to reply if it was you. I'll reply now.
__________________
Currently:



My Sites

Free Nintendo DSi
www.macbook4u.co.uk
Free Android
Free PS3 Games


open spoiler to see what im doing
Spoiler
Offline  
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 04:21 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts