0

i'm trying to send email to both user and admin after remaining amount successfully paid, record is updating but can't getting the email on both receiver using object oriented php for email here is my code

include("config.php");
include('Email.php');
session_start();

// Declair Veriables

$receiver   = $_SESSION['enrollment_email'];
$receiver2  = "admin@icifb.org";
$username   = $_SESSION['session_fname']." ".$_SESSION['session_lname'];
$studentid  = $_SESSION['studentSeccID'];

$view_content   =   "SELECT * FROM wp_enrollment_info WHERE enrollment_id='$studentid'";
$rs             =   mysql_query($view_content);
$content_rows   =   mysql_fetch_array($rs); 


    $i_email    = $_SESSION['enrollment_email'];    
    $i_rem      = $_SESSION['temp_remaining'];
    $i_paid     = $_SESSION['temp_paid'];

    $query      = mysql_query("UPDATE wp_enrollment_info SET enrollment_paidEnroll=enrollment_paidEnroll+'$i_paid', enrollment_remBalance='$i_rem' WHERE enrollment_email='$i_email'");

    $res        = mysql_insert_id();

    $sqlurow    =   mysql_affected_rows($query);

    if($sqlurow>0)
    {
    // Prepare Email Body Text

$EmailBody  = $EmailBody . "<tr>";
$EmailBody  = $EmailBody . "<td bgcolor='#FAFAFA' style='padding:15px;'>";
$EmailBody  = $EmailBody . "<h4 style='font-family:Verdana; font-size:13px;'>Dear ".$_SESSION['session_fname']." ".$_SESSION['session_lname']."</h4>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'>You have successfully paid your remaining amount.</p>";
$EmailBody  = $EmailBody . "<br />";
$EmailBody  = $EmailBody . "<h4 style='font-family:Verdana; font-size:13px;'><u>Below is the Payment Detail:</u></h4>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px;'><strong>Total Amount Paid: </strong>£".$content_rows['enrollment_paidEnroll']."</p>";
$EmailBody  = $EmailBody . "<br />";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px; text-align:justify; line-height: 20px;'>If you have any query with respect to payments please contact us at <a href='mailto:admin@icifb.org'>admin@icifb.org</a></p>";

// Prepare Email Body2 Text
$EmailBody2 = $EmailBody2 . "<tr>";
$EmailBody2 = $EmailBody2 . "<td bgcolor='#FAFAFA' style='padding:15px;'>";
$EmailBody2 = $EmailBody2 . "<h4 style='font-family:Verdana; font-size:13px;'>Dear Admin</h4>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'>The following student paid due amount.</p>";
$EmailBody2 = $EmailBody2 . "<br />";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Name: </strong>".$_SESSION['session_fname']." ".$_SESSION['session_lname']."</p>";
$EmailBody2 = $EmailBody2 . "<p style='font-family:Verdana; font-size:12px;'><strong>Total Amount Paid: </strong>£".$content_rows['enrollment_paidEnroll']."</p>";

// redirect to contact us page
$email = new Email();

if ($email->send6($EmailBody,$receiver))
{

    $email->send6($EmailBody2,$receiver2);
}
    }

please review my code and suggest me a better way of doing it

Email.php

public function send6($EmailBodyParam,$receiver)
{
    // Email Body

$sendername     =   "ICIFB | Finance Department";
$sender         =   "payments@icifb.org";
$Subject        =   "Payment Confirmation";

$EmailBody  = "<table cellpadding='0' cellspacing='0' width='800'>";
$EmailBody  = $EmailBody . "<tr height='100'>";
$EmailBody  = $EmailBody . "<td bgcolor='#5BA7FF' align='center'>";
$EmailBody  = $EmailBody . "<h3 style='color:#FFF; font-family:Verdana;'>Welcome to International Center for Islamic Finance & Business</h3>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";

$EmailBody.=$EmailBodyParam;        

$EmailBody  = $EmailBody . "<br />";
$EmailBody  = $EmailBody . "<h4 style='font-family:Verdana; font-size:13px;'>Regards,</h4>";
$EmailBody  = $EmailBody . "<p style='font-family:Verdana; font-size:12px; text-align:justify; line-height: 20px;'>ICIFB | Finance Department</p>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";
$EmailBody  = $EmailBody . "<tr height='50'>";
$EmailBody  = $EmailBody . "<td bgcolor='#62B54F' align='center'>";
$EmailBody  = $EmailBody . "<h2 style='color:#FFF; font-size:12px; font-family:Verdana; font-weight:normal;'>Copyright &copy; 2015 | International Center for Islamic Finance & Business</h2>";
$EmailBody  = $EmailBody . "</td>";
$EmailBody  = $EmailBody . "</tr>";
$EmailBody  = $EmailBody . "</table>";

    // Send Email

$success = "MIME-Version: 1.0 \r\n"; 
$success.= "Content-type: text/html;charset=utf-8 \r\n"; 
$success.= "X-Priority: 3\r\n"; 
$success.= "X-Mailer: smail-PHP ".phpversion()."\r\n";
$success = mail($receiver, $Subject, $EmailBody, "From: $sendername<$sender>\nReply-To: $sender\nContent-Type: text/html");
return $success;
}
}
Kashif Latif
  • 47
  • 1
  • 11
  • new Email its your custom class or some non standard library. We cannot know what is wrong with it – Daimos Oct 06 '15 at 07:30
  • What is the code for `// Prepare Email Body Text` and `// Prepare Email Body2 Text` ? – Kuya Oct 06 '15 at 07:35
  • None of the $EmailBody, $EmailBody2 variables are assigned a value in the above code. So it seems that you are trying to send an empty email to the recipients. Either show us the code where these variables are assigned any value or assign them value. – Shadow Oct 06 '15 at 07:47
  • @Daimos yes it is my custome class, i'm updating my question, please see – Kashif Latif Oct 06 '15 at 07:51
  • @Kuya this is for email body, i just removed it because it was too lengthy – Kashif Latif Oct 06 '15 at 07:52
  • Sending the email is your problem... correct? We need to see the code that formulates and sends the email. – Kuya Oct 06 '15 at 07:54
  • @Kuya i just update my question please see the below code – Kashif Latif Oct 06 '15 at 07:56
  • What does `$EmailBodyParam` contain? I will presume that it contains information from a DB query regarding the payment/transaction. If an error occurs there, the code breaks. – Kuya Oct 06 '15 at 08:02
  • What errors are you getting? – Kuya Oct 06 '15 at 08:04
  • it contains the remaining part of the email body, which is different for both receiver, but i'm not getting the mail not even blank mail – Kashif Latif Oct 06 '15 at 08:04
  • let me explain again in simple words.... user will paid his remaining amount... record is updating in database and then i want to send an email to both user and admin with latest payment details... everything is working fine except emails... – Kashif Latif Oct 06 '15 at 08:08
  • hope u r getting my point – Kashif Latif Oct 06 '15 at 08:09
  • I get your point. The update functions fine. The email is not sent. That's why I'm concentrating my questions regarding how the email is formulated and sent. That's what we need to see. If an error occurs ANYWHERE inside the code for formulating and sending the email (including `$EmailBodyParam`) the email will not be sent. – Kuya Oct 06 '15 at 08:12
  • Have you checked your error logs to see what's going on? – Kuya Oct 06 '15 at 08:16
  • i just share my all code.... see the latest update in email body... that's all i have – Kashif Latif Oct 06 '15 at 08:18
  • not getting any error in error_log – Kashif Latif Oct 06 '15 at 08:19
  • ps you know that you can write only $EmailBody .= "
    "; instead of repeat it twice? ;)
    – Daimos Oct 06 '15 at 08:21
  • server sending mails ? Checked with simple mail function? – Daimos Oct 06 '15 at 08:22
  • well that was my first try :) did you found any isuue? – Kashif Latif Oct 06 '15 at 08:24

0 Answers0