peterengland Posted August 12, 2013 Share Posted August 12, 2013 (edited) Hi, I need a php script that connect to a mysql database and retrive the current date birthday information and mail through php mail using gmail smtp to about 1500 mail addresses. I have database ready with me name of database in empmaster like Firstname lastname Date of Birth and this php page is going to run everyday and mail if there is birthday today of anyone. Thanks in Advance please help someone. I have one example (not exactly related to my requirement but for only example i tried it but not worked with exammp) found from Internet pls see in attachment. ----------------------------------------------code------------------------------------------------------------------ <?php require_once('connect/test.php'); ?>//This makes the connection to mysql database<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Home Page</title></head><body><h3>Thank you!</h3><p><?phprequire_once("phpMailer/lib/class.phpmailer.php");require_once("phpMailer/lib/class.smtp.php");require_once("phpMailer/lib/language/phpmailer.lang-en.php");$to_name = "sammuel";$to = "gfgdfgh@gmail.com";$subject = "A new user has been registered to the website";$from_name = "John Smith";$from = "ggffdhfg@gmail.com";//PHP SMTP version$mail = new PHPMailer();$mail->IsSMTP();$mail->Host = "smtp.gmail.com";$mail->Port =587;$mail->SMTPAuth = false;$mail->Username = "gffdhgdhhhd@dgs.com";$mail->Password = "password";$mail->FromName = $from_name;$mail->From = $from;$mail->AddAddress($to, $to_name);$mail->AddAddress("gdhdhdhh@gmail.com");$mail->IsHTML(true);$mail->Body = "<html><head></head><body><h2>A new user has registered at my website</h2>";// ======== get database data ==================$link = mysqli_connect("localhost","root","12345");$database="mydatabase";mysqli_select_db ($database,$link) OR die ("Could not open $database" );$query = "SELECT * FROM A WHERE id= 123"; //xyz is id of desired user name.$result1 = mysqli_query($query);// error checking may be required herewhile ($a_row = mysqli_fetch_array($result1)$mail->Body .= "<p>Name: ". $a_row['name'] . "</p>";$mail->Body .= "<p>Surname: ". $a_row['surname'] . "</p>";$mail->Body .= "<p>Email: " . $a_row['email'] . "</p>";$mail->Body .="</body></html>";// not sure how $mail-->Body in OOP but that is the general idea from a procedure guy.// etc....}// end database code$result = $mail->Send();echo $result ? 'Thanks for your registering... Your information has been recorded in our database.' : 'Error';?></body></html> ---------------------------------------------------end of code-------------------------------------------------------------- Edited August 12, 2013 by peterengland Quote Link to comment https://forums.phpfreaks.com/topic/281083-php-mysql-and-gmail-help/ Share on other sites More sharing options...
AbraCadaver Posted August 12, 2013 Share Posted August 12, 2013 http://forums.phpfreaks.com/forum/20-php-freelancing/ Quote Link to comment https://forums.phpfreaks.com/topic/281083-php-mysql-and-gmail-help/#findComment-1444639 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.