Outgoing emails to be encoded in ISO-8859-15 (ASCII)

This commit is contained in:
Karl Cordes 2009-02-13 09:38:34 +11:00
parent b6baa8ecd8
commit 8b6312ad47
2 changed files with 18 additions and 20 deletions

View file

@ -258,7 +258,7 @@ class EnquiriesController extends AppController {
'timeout' => '15',
'host' => '192.168.0.6');
$this->Email->delivery = 'smtp';
$this->Email->charset = 'iso-8859-15';
$enquiry = $this->Enquiry->read(null, $id);
$this->Email->to = $enquiry['Contact']['email'];
$this->Email->cc = array($enquiry['User']['email']);
@ -269,6 +269,7 @@ class EnquiriesController extends AppController {
$this->Email->from = 'CMC Technologies - Sales <sales@cmctechnologies.com.au>';
$this->Email->template = 'enquiry_added';
$this->Email->sendAs = 'both';
$this->set('enquiry', $enquiry);
if($this->Email->send()) {
$this->Session->setFlash(__('The Enquiry has been added and the Contact has been emailed', true));

View file

@ -13,11 +13,11 @@ class VaultShell extends Shell {
/******************************************************
* Config Variables
* *****************************************************/
$testing = 1; //Whether to actually move the emails. 1=test, 0=production
$testing = 0; //Whether to actually move the emails. 1=test, 0=production
/* Setup Connection to the IMAP server */
$username = 'vault';
$password = 'xjdYOsmJWc37'; /* The password for the account to be checked */
$email_dir = '/var/www/quotenik1.2/app/emails/working';
$email_dir = '/var/www/cakephp/app/emails/working';
$temp_filename = 'temp.eml';
$mbox = imap_open("{saturn:143/novalidate-cert}INBOX", $username, $password) or die("can't connect: " . imap_last_error());
@ -27,11 +27,10 @@ class VaultShell extends Shell {
/* Loop through the messages and sort them into ones to be processed or discarded */
for ($i=1; $i <= $number_of_messages; $i++) {
$this_header = imap_headerinfo($mbox, $i);
$enquiry = $this->checkIfValidEnquiry($mbox, $i, $this_header, $testing);
if($enquiry != FALSE) {
$message = $this->getMessage($mbox, $i, $this_header);
$enquiry = $this->checkIfValidEnquiry($message['subject'], $testing);
if($enquiry) {
//Process it and store the message and its attachments.
$message = $this->getMessage($mbox, $i, $this_header);
$this->Email->create();
$this->data['Email']['enquiry_id'] = $enquiry['Enquiry']['id'];
$this->data['Email']['to'] = $message['to'];
@ -238,28 +237,26 @@ function getBody($mbox, $msgnumber) {
return $body;
}
function checkIfValidEnquiry($mbox, $msgnumber, $this_header, $testing) {
function checkIfValidEnquiry($subject, $testing) {
$output = array();
preg_match("/CMC\d+([NVQWSO]|ACT|NT)E\d+-\d+/", $subject, $output);
preg_match("/CMC\d+([NVQWSO]|ACT|NT)E\d+-\d+/", $this_header->subject, $output);
if(isset($output[0])) { //Found a valid-looking Enquiry Number
$fetched_enquirynumber = $output[0];
$enquiry = $this->Enquiry->findByTitle($fetched_enquirynumber);
if($enquiry['Enquiry']['id'] == NULL) { //It passes the Regex - but we don't find an Enquiry for it in the MER.
if($testing == 0) { //testing mode == 1, production == 0.
imap_mail_move($mbox, $i, 'INBOX/Discarded'); //Discard it.
}
}
else {
return $enquiry; // Valid Enquiry if we've found the enquiry in the Master Enquiry Register
if($enquiry) {
return $enquiry;
}
}
else {
return FALSE;
else {
return FALSE;
}
}
}
?>