I’m experiencing a strange issue with the EEmail class. I’ve developed the following function within the structure of a plugin. All appears to go well until
if ($PREFS->ini('auto_convert_high_ascii') == 'y'){
if(!$email->message($REGX->entities_to_ascii($email_msg))){echo"did not convert message";}
} else{
if(! $email->message($email_msg) ){echo"did not get message";}
}The above always triggers “Did not get message” - I only have it separated out from the REGX because the detail in the docs for this function were only to trigger it if the PREFS statement were true.
function Send_quiz_results()
{
global $DB, $SESS,$PREFS, $REGX;
$recipient="[email protected]";
$from = $SESS->userdata['email'];
$message ='';
$subject ='Submission: Quiz by '.$SESS->userdata['screen_name'];
$user = $SESS->userdata['member_id'];
$results =$DB->query('SELECT metric, SUM(points) totalPoints FROM table WHERE userID = '.$user.' AND points != 0 GROUP BY metric HAVING totalPoints > 0 ORDER BY totalPoints DESC');
foreach ($results->result as $row){
$message.=$row['metric'] .': '.$row['totalPoints'].' points'."\n";
}
$greet="Dear example,\\n\\n".$SESS->userdata['screen_name'].' would like you to see his/her results from the quiz at example.com. Here are the results:';
$email_msg=$greet.$message;
if ( ! class_exists('EEmail'))
{
require PATH_CORE.'core.email'.EXT;
}
$email = new EEmail;
$email->wordwrap = true;
$email->mailtype = 'text';
$email->from($from);
$email->to($recipient);
$email->subject($subject);
if ($PREFS->ini('auto_convert_high_ascii') == 'y'){
if(!$email->message($REGX->entities_to_ascii($email_msg))){echo"did not convert message";}
} else{
if(! $email->message($email_msg) ){echo"did not get message";}
}
if ( ! $email->Send())
{
return $DSP->error_message($LANG->line('error_sending_email'), 0);
} else{
echo "done";
}
}Furthermore, it echos “done” - so it claims to be sending the email - and I haven’t seen one yet.
Thanks for any help or guidance as to what could be going wrong.
Caroline
Here is the object:
EEmail Object (
[protocol] => mail
[mailpath] => /usr/sbin/sendmail
[smtp_host] => [smtp_user] =>
[smtp_pass] => [smtp_auth] =>
[smtp_port] => 25
[smtp_timeout] => 5
[debug] =>
[wordwrap] => 1
[wrapchars] => 76
[mailtype] => text
[charset] => utf-8
[encoding] => 8bit
[multipart] => mixed
[validate] =>
[priority] => 3
[newline] =>
[crlf] =>
[bcc_batch_mode] =>
[bcc_batch_tot] => 250
[safe_mode] =>
[send_multipart] => 1
[subject] =>
[body] => [*correct body]
[plaintext_body] =>
[finalbody] =>
[alt_boundary] =>
[atc_boundary] =>
[header_str] =>
[smtp_connect] =>
[useragent] => ExpressionEngine 1.6.7
[replyto_flag] =>
[debug_msg] =>
Array ( )
[recipients] => [email protected]
[cc_array] => Array ( )
[bcc_array] => Array ( )
[headers] => Array ( [User-Agent] => ExpressionEngine 1.6.7 [Date] => Wed, 21 Apr 2010 19:25:47 -0500 [From] => [Return-Path] => [Subject] => =?utf-8?Q?Submission:?= ) [attach_name] => Array ( ) [attach_type] => Array ( ) [attach_disp] => Array ( ) [protocols] => Array ( [0] => mail [1] => sendmail [2] => smtp ) [base_charsets] => Array ( [0] => iso-8859-1 [1] => us-ascii ) [bit_depths] => Array ( [0] => 7bit [1] => 8bit ) [priorities] => Array ( [0] => 1 (Highest) [1] => 2 (High) [2] => 3 (Normal) [3] => 4 (Low) [4] => 5 (Lowest) ) )caroline:
couple things at a quick glance:
EEMail::message() isn’t going to return boolean, so you can probably just get by with:
$email_msg = ($PREFS->ini('auto_convert_high_ascii' == 'y')) ? $REGX->entities_to_ascii($email_msg) : $email_msg;
$email->message($email_msg);Then the other thing that catches my eye is that the ‘send’ method is not:
EEMail::Send();but
EEMail::send();So I’d try to get the casing on the method fixed up. Then, probably the first thing I”d try is:
var_dump($email->send()); exit;At the end of your script. If it returns FALSE, I’d suggest trying other email auth methods, smtp, next to see if they fail as well.
Hope that helps.
-greg
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.