tcvdveer Posted October 15, 2008 Share Posted October 15, 2008 I use following code to send an e-mail from a custom page in case a creditcard transaction fails. With this example I try to send the e-mail to the client with client id 1. The response result gives a success, but no e-mail is being send. Can anyone point me to what I'm doing wrong here? <?php include("dbconnect.php"); include("includes/functions.php"); include("includes/clientfunctions.php"); $username = "admin"; $password = "xxxxxx"; $url = "http://www.xxxxx.xxx/clients/includes/api.php"; # URL to WHMCS API file $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "sendemail"; $postfields["messagename"] = "Credit Card Payment Failed"; $postfields["id"] = "1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); ?> 0 Quote Link to comment Share on other sites More sharing options...
Shaun Posted October 16, 2008 Share Posted October 16, 2008 Looks to be ok is 1 the id of the user that you are trying to send the email to about the failed card. The doco is a little unclear but i assume that is what its for. 0 Quote Link to comment Share on other sites More sharing options...
tcvdveer Posted October 16, 2008 Author Share Posted October 16, 2008 Thanks for your reply Shaun. After a lot of testing and trying it appeared that I had to use the invoice id here instead of the client id. 0 Quote Link to comment Share on other sites More sharing options...
niels Posted November 29, 2009 Share Posted November 29, 2009 Are you sure it's in the invoice id? That won't work for me. The closest I got is the "hosting id" (as shown in http://xxx/admin/clientshostinglist.php.) 0 Quote Link to comment Share on other sites More sharing options...
_Dudu_1533 Posted December 22, 2009 Share Posted December 22, 2009 I developed a script that send email to customers. <?php /* API SendEmail WHMCS Developed By _Dudu_1533 www.hostcheap.com.br */ $mysql_host = 'localhost'; $mysql_database = 'whmcs'; $mysql_username = 'root'; $mysql_password = '1234'; mysql_connect($mysql_host, $mysql_username, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $admin['user'] = 'hahahaha'; //Admin Username $admin['pass'] = '1234'; //Admin Password $email['template'] = 'Hosting Account Welcome Email'; //Email template $invoice['id'] = 93; //Invoice ID $site['api'] = 'http://www.yoursite.com/whmcs/includes/api.php'; //URL API //Do not change below: $get_hostingid = mysql_query("SELECT a.id FROM tblhosting a WHERE orderid = (SELECT id FROM tblorders WHERE invoiceid = " . $invoice['id'].")") or die(mysql_error()); $row_hostingid = mysql_fetch_array($get_hostingid); $strcurl = "username=".$admin['user']."&password=".md5($admin['pass'])."&action=sendemail&messagename=".$email['template']."&id=".$row_hostingid['id']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $site['api']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $strcurl); $data = curl_exec($ch); curl_close($ch); echo $data; ?> Any doubt, post 0 Quote Link to comment Share on other sites More sharing options...
blackeve Posted March 3, 2010 Share Posted March 3, 2010 I need to send email to custom email address can anyone help me? I developed a script that send email to customers. <?php /* API SendEmail WHMCS Developed By _Dudu_1533 www.hostcheap.com.br */ $mysql_host = 'localhost'; $mysql_database = 'whmcs'; $mysql_username = 'root'; $mysql_password = '1234'; mysql_connect($mysql_host, $mysql_username, $mysql_password) or die(mysql_error()); mysql_select_db($mysql_database) or die(mysql_error()); $admin['user'] = 'hahahaha'; //Admin Username $admin['pass'] = '1234'; //Admin Password $email['template'] = 'Hosting Account Welcome Email'; //Email template $invoice['id'] = 93; //Invoice ID $site['api'] = 'http://www.yoursite.com/whmcs/includes/api.php'; //URL API //Do not change below: $get_hostingid = mysql_query("SELECT a.id FROM tblhosting a WHERE orderid = (SELECT id FROM tblorders WHERE invoiceid = " . $invoice['id'].")") or die(mysql_error()); $row_hostingid = mysql_fetch_array($get_hostingid); $strcurl = "username=".$admin['user']."&password=".md5($admin['pass'])."&action=sendemail&messagename=".$email['template']."&id=".$row_hostingid['id']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $site['api']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $strcurl); $data = curl_exec($ch); curl_close($ch); echo $data; ?> Any doubt, post 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted March 3, 2010 Share Posted March 3, 2010 With API SendEmail you can (only?) send Emailtemplates. Remember to use ProductID for Product Emailtemplates, ClientID for Client Emailtemplates, ... 0 Quote Link to comment Share on other sites More sharing options...
blackeve Posted March 3, 2010 Share Posted March 3, 2010 (edited) tx, I know it, but i want send mail from my callback page ( such as payment checker page ) to submitted email address, this email sent from invoice payment form to check page. for example in invoice page my customer want send my bank information to another email address that not registered in my WHMCS, I want create a gateway module to send my bank information by user request to a custom email address that email submitted. Edited March 3, 2010 by blackeve 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted March 3, 2010 Share Posted March 3, 2010 when email is not stored (think thats not good) you have to send email by self. http://de.php.net/manual/de/function.mail.php or sending email more savely by using THE email class tool: http://sourceforge.net/projects/phpmailer/ ! you do not need to download this package its just in whmcsroot/includes/class.phpmailer.php just include the package and use like documented: for example like this -> http://phpmailer.worxware.com/index.php?pg=examplebmail 0 Quote Link to comment Share on other sites More sharing options...
blackeve Posted March 6, 2010 Share Posted March 6, 2010 tx, it's so useful! but another thing, if i want send this mail by a custom template from WHMCS template, could you help me to call template content and dynamic tags from databases? 0 Quote Link to comment 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.