0

Here are my code:-

//Sending mail
if ($this->Session->read('Enrollment.personalinfo_language') == 'English') {
    $language = "english";
    $subject = "Thank you for submitting your enrollment request to Apna Energy.";
} else {
    $language = "spanish";
    $subject = "Gracias por enviar su solicitud de inscripci?n a Apna Energy.";
}
$details = $this->Session->read('Enrollment');
$details['plan_name'] = $product['Product']['name'];
$details['rate'] = $plan_rate;
$details['term'] = $product['Term']['term'];
$this->Email->sendAs = 'html';
$this->Email->from = 'Apna Energy <contact@apnaenergy.com>';
$this->Email->to = $this->Session->read('Enrollment.personalinfo_first_name') . ' ' . $this->Session->read('Enrollment.personalinfo_last_name') . '<' . $this->Session->read('Enrollment.personalinfo_email') . '>';
$this->Email->bcc = array('my@mail.com');
$this->Email->subject = $subject;
$this->set('details', $details);
if ($this->Session->read('Enrollment.personalinfo_language') == 'English') {
    $template = "enrollment_confirmation";
} else {
    $template = "enrollment_confirmation";
}
$this->Email->template = $template;
$this->Email->send();

My problem is if customer fill form they are receiving mail in his/her spam folder.. customer's mail id in "to".. and my mail id in "BCC" for me mail are coming fine in my inbox folder..

I followed two URL but they didn't work out for me..

Cakephp emails going to spam

How do you make sure email you send programmatically is not automatically marked as spam?

Guide me in right direction.. Thanks!!

Community
  • 1
  • 1
Javascript Coder
  • 5,691
  • 8
  • 52
  • 98

1 Answers1

1

by using SMTP

with normal PHP your server must be configured properly which is not easy to do as a beginner (MX records need to match the servers ip etc). So just always stick to SMTP as mailing gateway and you will be fine.

PS: I don't think it has anything to do with your code in general, although it is not very beautiful. for instance: you should cast the array you read from the session to avoid notices thrown:

$details = (array)$this->Session->read('Enrollment');
mark
  • 21,691
  • 3
  • 49
  • 71
  • what did you do? what are your smtp configs passed on to the email component? (no actual data/passwords, just how you did it - some code) – mark Jun 05 '12 at 10:51
  • +1 and answer accepted. You are right, I config SMTP for free trail ... and implement it now it is working fine.. thanks @mark – Javascript Coder Jun 05 '12 at 11:54