Email to customer missing $AppName and $CompanyName

When I test the purchasing process, the email that gets sent to the customer is missing $AppName value in the subject line and also in the sentence: "This product key is licensed for 1 user of $AppName value."Also, after the closing "Thank you," the $CompanyName value is missing.These values show up in the Paypal screens successfully. They are just missing in the customer email.

I am having this same issue, with an additional challenge.

The email I received had the subject "Your product key", completely missing my product name.

The customer name looked perfect, and so was the product key.

The final lines read:

"This product key is licensed for 1 user of .

Thank you, "

It was completely missing the $AppName in the subject and bodyt, plus the $CompanyName in the body. Both variables are set correctly in the PaymentSettings.php file, and appear correct everywhere else, so I don't understand how they were not applied.

My final problem is that the email was delivered from my web server administrator email account, which I definitely do not want made public for security reasons. How do I control what account is used to send the email.

I am using PHP from the latest LimeLM Web API Pack, downloaded 10/31/2017.

Thanks,Paul

Hey Paul,

All of the code you want to change is in PaymentSetting.php. You have to set the company name, product name, etc. And if you want to change how emails are sent, then modify the PaymentSettings.php file's use of the mail() function.

There are lots of different ways to send email in PHP. Here's one method: https://github.com/PHPMailer/PHPMailer

Hey Wyatt,

I was able to resolve all my issues by modifying the PaymentSettings.php, but to be clear there is something broken in your delivered code. Somehow, the $AppName and $CompanyName variables are NULL inside the SendPKeys function. I am guessing that this is because the function is being called directly from paychecker.php, so the vars are not set inside the function, but I can't be certain.

To help others, here are the changes I made to Payment Settings.php:

I made an additional copy of both $AppName= and $CompanyName= lines, and placed them inside the SendPKeys function. Though not elegant, this did fix the problem with the NULL values inside the function. I also put myself a note right above their original location that a 2nd copy exists in SendPKeys, so I would remember to update both copies if I ever have a change.

The $header variable inside the mail() command is null, as it is not being set anywhere inside the code. I went ahead and assigned values to the $header variable like this:

// To send HTML mail, the Content-type header must be set $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1';

// Additional headers $headers[] = 'From: Pretty Name <address@website.com>'; $headers[] = 'Bcc: Pretty Name <address@website.com>'; //sending a copy to myself to audit $headers[] = 'Reply-To: Pretty Name <address@website.com>'; $headers[] = 'X-Mailer: PHP/' . phpversion();

Because of how the I added values to the $headers variable (as array elements), you have to use the implode command to add line returns after each array element, as you'll see in the mail() command example below. I also added the top two lines so that I could send richly formatted HTML emails instead of plain-jane text messages.

I added a new variable, $emailSubject, to clean up my mail() command a bit, and also because I am using the same subject line in both the mail() command and in the "<html><header><title>'.$emailSubject.'</title></header>" part of the $emailBody (full HTML example shown below).

Lastly, and the most important bit for me, is I included the optional 5th parameter in the mail() command to change the user sending the email:

$emailSent = mail($email, $emailSubject, $emailBody, implode("\r\n", $headers), '-faddress@website.com');

This solved a lot of issues for me. No longer are my emails sending from my private administrator account, but rather my public facing account. The $headers alone were not enough to do this, as my emails were going out with a 'via hostcompany.com' tag on the email headers, and all my messages were being flagged as spam. The 5th paramter with the -f prefix allows you to physically change to the right email account, any my messages are sent as truly from my website, and not from my hosting company, and are no longer being flagged as spam. Yay!

For those that want to implement HTML email, here's how I did it (in addition to the two $headers parameters above):

First, on the $product_keys variable, I added a ListItem tag, <li>, around each product key. This produces a nice bullet list of product keys in the email:

$product_keys .= '<li>'.$pkey['key'].'</li>'."\r\n";

Then I added HTML tags to the $emailBody var, as follows (note, I also changed some of the verbiage to better fit my product):

$emailBody = '<html> <head> <title>'.$emailSubject.'</title> </head> <body> <p>'.$customerName.',</p> <p>Thank you for your '.$AppName.' order of '.$quantity.' product '.( $quantity > 1 ? 'keys' : 'key' ).'. Your product key'.( $quantity > 1 ? 's are' : ' is' ).':</p>

<b>'.$product_keys.'</b>

<p>Each product key is licensed for 1 PC installation of '.$AppName.'.</p> <p>You may apply the product key by running '.$AppName.', then selecting Settings (Gear icon), then "Activate" on the top right of the Settings screen.</p> <p>If you would like to move an Activated product key to a different PC, please "DeActivate" it first on the Settings screen.<p> <p>For additional support, please visit the <a href="http://www.mywebsite.com/how-to.html">Web Site</a>, <a href="https://twitter.com/myTwitterHandle">Tweet</a>, or reply to this email.</p> <p>Thank You,<br>'.$CompanyName.'</p> </body></html>';

For those that want to do email tracking, the HTML message provides an avenue for implementing it. The basic premise is that you would add a graphic (i.e. a logo, or even just a invisible dot) as an image in your HTML message, with the image src pointing to a file on your web site. You would also include a ?param= on the src link that includes a unique ID for every email sent. Then in your web server logs, every time that graphic is downloaded, it indicates the mail was opened by the recipient, and the unique ID could be used to figure out which email, and thus which recipient, opened the email. No idea what ID value you would use, so you would probably have to start from scratch if you wanted to track at that level.

Hope some of that helped someone else!Paul