Mysql
 sql >> база данни >  >> RDS >> Mysql

PHP изпраща имейл до всеки потребител

В кода ви липсваха къдрави скоби ( {} ):

include ("../dbconnect.php");

$sql='SELECT c.endofmonthform, c.startofmonthform, c.email, c.id, c.formlevel, c.mastersite, c.opmanager, u.userEmail FROM `clients` as c LEFT JOIN `users` as u on c.opmanager = u.userName WHERE endofmonthform="22/09/2016"'; //TODAYS DATE BACK HERE!

$result=mysql_query($sql); 

 while($row=mysql_fetch_array($result)){  

    $enddate = $row['endofmonthform']; // End

    $startdate = $row['startofmonthform']; // Start

    $email = $row['email']; //Email to send email to

    $id = $row['id'];

    $formlevel = $row['formlevel']; //To update and check formlevel

    $sitegroupname = $row['mastersite'];

    $manager = $row['opmanager'];

    $opemail = $row['userEmail'];

    /* If end date is today and form level is still ZERO then send email to op manager */
    $mail = new EMail;

    $mail->Username = 'Sender email';    
    $mail->Password = 'mypwd';
    $mail->SetFrom("[email protected]","companyname");  
    $mail->ContentType = "text/html";
    $mail->Subject = "Client feedback incomplete NEW LAYOUT";

    //Enter the email address you wish to send TO (Name is an optional friendly name):
    $mail->AddTo($opemail,$manager);


    $mail->Message = "<!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></title>
    <style type=text/css >
    body {margin: 0; padding: 0; min-width: 100%!important;}
    .content {width: 100%; max-width: 600px;}  
    </style>
    </head>
    <body yahoo bgcolor=#f6f8f1 >
    <table width=100% bgcolor=#f6f8f1 border=0 cellpadding=0 cellspacing=0>
    <tr>
    <td>
    <table class=content  align=center  cellpadding=0  cellspacing=0  border=0 >
    <tr>
    <td>

    ID: ".$id." <br>

    Clients group name: ".$sitegroupname." <br>

    Managers Name: ".$manager." <br>

    Managers Email: ".$useremail." <br>

    Please log into your account as you have feedback notifications
    <br>

    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>";

    echo $success = $mail->Send(); //Send the email.
}

Също така почистих някои от PHP, за да опростя всичко. ЗАБЕЛЕЖКА:Изключих имейл класа, тъй като не е подходящ за този проблем.

РЕДАКТИРАНЕ:

TS ме информира, че частта за поща не работи, така че опитайте да използвате стандартната php поща:

<?php 
include ("../dbconnect.php");

$sql='SELECT c.endofmonthform, c.startofmonthform, c.email, c.id, c.formlevel, c.mastersite, c.opmanager, u.userEmail FROM `clients` as c LEFT JOIN `users` as u on c.opmanager = u.userName WHERE endofmonthform="22/09/2016"'; //TODAYS DATE BACK HERE!

$result=mysql_query($sql); 

 while($row=mysql_fetch_array($result)){  

    $enddate = $row['endofmonthform']; // End

    $startdate = $row['startofmonthform']; // Start

    $email = $row['email']; //Email to send email to

    $id = $row['id'];

    $formlevel = $row['formlevel']; //To update and check formlevel

    $sitegroupname = $row['mastersite'];

    $manager = $row['opmanager'];

    $opemail = $row['userEmail'];

    mail($opemail, "subject", "message", "from");
}



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MySql:Сравнете 2 низа, които са числа?

  2. ГРЕШКА 2002 (HY000):Не мога да се свържа с локален MySQL сървър чрез сокет '/tmp/mysql.sock'

  3. Как да импортирате данни от mysql в solr

  4. MySQL еквивалент за слушане на известие

  5. Проблем при вмъкване от скрипт на python в база данни на mysql с innondb двигател