iamcorbito Posted February 9, 2017 Share Posted February 9, 2017 Hi, Im new to making modules for whmcs so i am having a bit of a hard time getting things to work. Problem: Im having issues sending mails to clients through mail() function when the inputs are parsed from a txt file. $file = file( BSC_ROOT . "/site.txt"); foreach( $file as $line ) { $parsedLine = explode(",", $line); mail( $parsedLine[1] ,"My Subject", $parsedLine[0]); -> this fails to send } mail('myemail@gmail.com',"My Subjec","THIS IS A TEST"); -> this works I am still unsure how to setup or use the phpmailer so i ended up using mail() instead. 0 Quote Link to comment Share on other sites More sharing options...
servetas Posted February 9, 2017 Share Posted February 9, 2017 can you do a var_dump of the $parsedLine before sending the email? 0 Quote Link to comment Share on other sites More sharing options...
iamcorbito Posted February 9, 2017 Author Share Posted February 9, 2017 Yes, i am able to get the values just fine. here is the result of that var_dump array(2) { [0]=> string(19) "http://ianfette.org" [1]=> string(24) "reyesmarkdaryl@gmail.com" } - - - Updated - - - Yes, i am able to get the values just fine. here is the result of that var_dump array(2) { [0]=> string(19) "http://ianfette.org" [1]=> string(24) "reyesmarkdaryl@gmail.com" } 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 9, 2017 Share Posted February 9, 2017 Why not use the API function SendEmail ? http://developers.whmcs.com/api-reference/sendemail/ . Though if you are in a function without client vars given, you will need to search first using getclients - http://developers.whmcs.com/api-reference/getclients/ . Just set the the custommessage and customsubject to what you need and the ID to the client id found in getclients. As for parsing the file, you'll need to double check the parsed information is correct. Also, depending on the size of the file using a while might be better such as : $filename = "test.txt"; $source_file = fopen( $filename, "r" ) or die("Couldn't open $filename"); while (!feof($source_file)) { $buffer = fread($source_file, 4096); // use a buffer of 4KB $buffer = str_replace($old,$new,$buffer); /// } as grabbed from http://stackoverflow.com/questions/13246597/how-to-read-a-file-line-by-line-in-php . 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.