Zen Cart Logo
Forums / General Questions / php mail not working as I want it to

php mail not working as I want it to

Views: 509

Results 1 to 2 of 2
20 Sep 2015, 11:46 AM
#1
quickbooksdev avatar

quickbooksdev

New Zenner

Join Date:
Sep 2015
Location:
Daytona Beach, FL USA
Posts:
69
Plugin Contributions:
0

php mail not working as I want it to

I am trying to add a new php module within the ZC admin folder but emailing not working as expected.

I tried this which works outside of ZC
mail($ToEmail,$subject . ' php mail',$tempTemplate,$headers) ;
and there are no errors but nothing happens when running within ZC with the normal
require('includes/application_top.php');
and
require('includes/configure.php');

It works outside of ZC without the above requires.

I even tried using zen_mail but does do what I need it to do.
.
$aaatex_html_msg['EMAIL_FROM_ADDRESS'] = $fromEmail;
.
zen_mail( '', $ToEmail, $subject , $tempTemplate, "AaaTeX Customer Service", "[email protected]", $aaatex_html_msg,'renewals');

It sends the email but there are 2 issues:

  1. It doesn't use the from email above but uses the store email address which I do not want.
  2. It doesn't seem to support Bcc.

So how can I get it to send emails with the from address and Bcc? I think that php mail would be preferable but it does nothing.

20 Sep 2015, 12:24 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,080
Plugin Contributions:
56

Re: php mail not working as I want it to

The zen_mail function's standard processing (except for contact_us and order-confirmation emails) has the reply-to field set to the store's email address. You can override that behavior in the zen_mail call, though:

zen_mail ( '', $ToEmail, $subject , $tempTemplate, STORE_NAME, EMAIL_FROM, $aaatex_html_msg,'renewals', '', "AaaTeX Customer Service", "[email protected]");

While Zen Cart doesn't support bcc: mails out-of-the-box, you could write an observer-class script to receive notifications on NOTIFY_EMAIL_READY_TO_SEND (as its name implies, the email's just ready to send). You receive a copy of the phpMailer object ($mail) as the second notification parameter, allowing you to add the BCC addresses via the phpMailer's *AddBCC *function.