Jump to content

Help on making getting mail() or phpmailer to work on a module


iamcorbito

Recommended Posts

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.

Link to comment
Share on other sites

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" }

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated