I am using a plugin wordpress-simple-paypal-shopping-cart for my cart requirement. I am trying to send an email through this plugin when some payment is made by using IPN.
My code :
$invoiceProducts = $_SESSION['simpleCart'];
if(isset($invoiceProducts) && !empty($invoiceProducts)){
$html = renderHTML($invoiceProducts);
generatePDF($html);
unset($invoiceProducts);
}
function renderHTML($param){
$IPN = $_POST;
$name = $IPN['first_name'];
$donationAmount = $IPN['payment_gross'];
$contributorsEmail = $IPN['payer_email'];
$contributorsPhone = $IPN['payer_email'];
$contributorsAddr = $IPN['address_name'] . ', ' . $IPN['address_city'] . ', ' . $IPN['address_country'];
//We will need to shoot email to laura of successfull payment.
$to = 'myemail@domain.com';
$subject = 'Donation made on your website';
$message = '';
$message .= '<html><body>';
$message .= '<p>You have received a contribution from<strong>'.$name.'</strong> of <strong>'.$donationAmount.'</strong></p>';
$message .= '<p>Contributor Information:</p>';
$message .= '<ul>';
$message .= '<li>Name:'.$name.'</li>';
$message .= '<li>Amount:'.$donationAmount.'</li>';
$message .= '<li>Email:'.$contributorsEmail.'</li>';
$message .= '<li>Address:'.$contributorsAddr.'</li>';
$message .= '</ul>';
$message .= '</body></html>';
wp_mail( $to, $subject, $message, $headers, $attachments );
}
But when this function is called I am getting this error :
Fatal error: Call to undefined function wp_mail()
I know why I am getting this error, its just that my plugin is getting loaded first rather then wp_mail()
.
In my case how can I call wp_mail()
first then my plugin?