2012-06-26 17 views
5

Sto utilizzando SMTP per inviare email nel mio progetto CAKEPHP. mia email config come segueImpostazioni SMTP di Cakephp 2.0 su Email non funzionanti

class EmailConfig { 

    public $Smtp = array(
     'transport' => 'Smtp', 
     'from' => array('[email protected]' => 'domainname.com'), 
     'host' => 'myhostingserver', 
     'port' => 2525, 
     'timeout' => 60, 
     'username' => '[email protected]', 
     'password' => 'secret', 
     'client' => null, 
     'log' => false 
    ); 

e il mio codice funzionalità di posta elettronica come segue

$email = new CakeEmail('Smtp'); 
    $result = $email->template('welcome_mail','default') 
         ->emailFormat('html') 
         ->to($to_email) 
         ->from('[email protected]') 
         ->subject('Welcome to my domain name') 
         ->viewVars($contents); 

    if($email ->send('Smtp')) 
    { 
     echo ('success'); 

    } 

mentre io sono l'invio di posta il suo lancio seguente errore timeout SMTP. I dettagli del mio server SMTP sono corretti e funzionano correttamente in un server esistente. Non so dove ho sbagliato

risposta

6

Controllare il tipo di crittografia (se applicabile), ad esempio, SSL o TLS

L'URL di serie dovrebbe essere simile a questa in tal caso

'host' => 'ssl://myhostingserver' 

o

'host' => 'tls://myhostingserver' 
1

Se il server SMTP ha SSL, è necessario abilitare php_openssl in php.ini per utilizzare questo servizio. È possibile utilizzare questo codice per verificare

if(!in_array('openssl',get_loaded_extensions())){ 
    die('you have to enable php_openssl in php.ini to use this service');  
} 
0

accanto a quello che già è stato qui sugested qui che il modulo deve essere caricato. ho scoperto che alcuni server hanno alcune porte bloccate. Ho usato questo script per testare alcuni server:

<?php 

if(!in_array('openssl',get_loaded_extensions())){ 
    die('you have to enable php_openssl in php.ini to use this service');  
} else { 
    echo "php_openssl in php.ini is enabled <br />"; 
} 

// fill out here the smpt server that you want to use 
$host = 'ssl://smtp.gmail.com'; 
// add here the port that you use for for the smpt server 
$ports = array(80, 465); 

foreach ($ports as $port) 
{ 
    $connection = @fsockopen($host, $port); 
    if (is_resource($connection)) 
    { 
     echo $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.<br />' . "\n"; 
     fclose($connection); 
    } else { 
     echo $host . ':' . $port . ' is not responding.<br />' . "\n"; 
    } 
} 

?> 
Problemi correlati