Cakephp Send Email - Not Send to Gmail but Send to Yahoo


#1

I want to send email activation to every user after sign up. But the email did not send to gmail. please help.
this is email.php:

public $smtp = array(
		'transport' => 'Smtp',
		'from' => array('****@gmail.com' => 'Virlen'),
		'host' => 'ssl://smtp.gmail.com',
		'port' => 465,
		'timeout' => 300,
		'username' => '****@gmail.com',
		'password' => '****',
		'client' => null,
		'log' => false,
		//'charset' => 'utf-8',
		//'headerCharset' => 'utf-8',
	);

This is app controller:

public function __sendMail($To, $Subject, $message, $From, $template = 'default', $smtp = 1, $attachment = array() ) {
        		
        App::uses('CakeEmail', 'Network/Email');
        // echo $smtp;die;
        $email  = 	new CakeEmail();
        $email->config();
            $email->to($To);
            $email->from($From); 
            $email->subject($Subject);
    		$email->emailFormat('html');
            $email->attachments($attachment) ;
            $email->template($template);
    		
            $email->layout 	= 	'default';
    		
    		//$smtp = 1;
    		/* if ($smtp == 1) {
    			$EmailConfig->smtpOptions = array(
                   'port' => 465,
                    'timeout' => 300,
                    'host' => 'ssl://smtp.gmail.com',
                    'username' => 'test@gmail.com',
                    'password' => 'test@123',
    				'transport' => 'Smtp'
                );
                $EmailConfig->delivery = 'smtp';
            } */ 
    		
    		// unset($this->helpers['Paginator']);
    		
    		if ($email->send($message)) {
    		    return true;
            } else {
    		    return false;
            }
        }

#2
  1. try to change ‘log’ to true and look there for errors.
  2. Also add some readable info (like flash message or write to log) in if($email->send(…)) so you can see does it works.
  3. try send email for non-working address via WWW gateway and check if it will came.
  4. try send above via some mail client like Thunderbird or Outlook and check for errors