Don't thank me until it works.
return true;
$headers .= "From: Website<[email protected]>\n"; $headers .= "BCC: <[email protected]>\n"; $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // $message = ' <p>A member has recently updated their membership details. Details of the user who has updated their profile details are outlined below:</p> <p>Full Name: <strong>'.$hook->getValue('fullname'). '</strong></br> Email Address: <strong>'.$hook->getValue('email').'</strong></p> <p>$output;</p> <p> </p> <p>The website team.</p> '; $to = "[email protected]"; $subject = "Member profile update changes notification"; if (mail($to, $subject, $message, $headers)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } /* tell our snippet we're good and can continue */ return true;
When you tried it, was the email sent, and if so, what did it look like?
If you put the email code in a separate snippet (not a postHook), does it send mail?
Sorry, no. I've never done anything similar that I can recall.
Can you post the full code of the postHook with the email in it? A PHP syntax error could be stopping the whole thing from working.
<?php
$oldProfile = isset($_SESSION['user_profile'])
? $_SESSION['user_profile']
: array();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$newProfile = $profile->toArray();
}
$output = '';
if (!empty($newProfile) && (!empty($oldProfile))) {
foreach ($newProfile as $key => $value) {
if ($oldProfile['key'] != $newProfile['key']) {
$output .= '<br />' . $key . ' changed from ' . $oldProfile['key'] . ' to ' . $newProfile['key'];
}
}
}
if (!empty($output)) {
$output = '<br />Changes:<br />' . $output;
} else {
$output = '<br />Changes: none<br />';
}
/* Change report will be in the $output variable here */
$modx->log(modX::LOG_LEVEL_ERROR,'Profile update: $output'.$err);
/* tell our snippet we're good and can continue */
return true;
<?php
$oldProfile = isset($_SESSION['user_profile'])
? $_SESSION['user_profile']
: array();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$newProfile = $profile->toArray();
}
$output = '';
if (!empty($newProfile) && (!empty($oldProfile))) {
foreach ($newProfile as $key => $value) {
if ($oldProfile['key'] != $newProfile['key']) {
$output .= '<br />' . $key . ' changed from ' . $oldProfile['key'] . ' to ' . $newProfile['key'];
}
}
}
if (!empty($output)) {
$output = '<br />Changes:<br />' . $output;
} else {
$output = '<br />Changes: none<br />';
}
if (! empty($output)) {
die($output);
} else {
die('Output is empty');
}
/* Change report will be in the $output variable here */
$modx->log(modX::LOG_LEVEL_ERROR, 'Profile update: $output' . $err);
/* tell our snippet we're good and can continue */
return true;