From a718f293c694e27f2a850ce0cb161560f3b23f7c Mon Sep 17 00:00:00 2001 From: rMalie Date: Wed, 8 Feb 2012 16:07:41 +0000 Subject: [PATCH] // Add mail with identifiers in installer + some missing trad --- install-dev/controllers/http/database.php | 14 ++++--- install-dev/controllers/http/process.php | 45 ++++++++++++++++++++ install-dev/langs/de/install.php | 32 +++++++++++++++ install-dev/langs/de/mail_identifiers.txt | 8 ++++ install-dev/langs/en/mail_identifiers.txt | 10 +++++ install-dev/langs/es/install.php | 32 +++++++++++++++ install-dev/langs/es/mail_identifiers.txt | 11 +++++ install-dev/langs/fr/install.php | 42 ++++++++++++++++--- install-dev/langs/fr/mail_identifiers.txt | 13 ++++++ install-dev/langs/it/install.php | 32 +++++++++++++++ install-dev/langs/it/mail_identifiers.txt | 12 ++++++ install-dev/models/install.php | 2 +- install-dev/models/mail.php | 50 +++++++++++++++++------ 13 files changed, 278 insertions(+), 25 deletions(-) create mode 100644 install-dev/langs/de/mail_identifiers.txt create mode 100644 install-dev/langs/en/mail_identifiers.txt create mode 100644 install-dev/langs/es/mail_identifiers.txt create mode 100644 install-dev/langs/fr/mail_identifiers.txt create mode 100644 install-dev/langs/it/mail_identifiers.txt diff --git a/install-dev/controllers/http/database.php b/install-dev/controllers/http/database.php index 2edd6308c..fbddbe961 100644 --- a/install-dev/controllers/http/database.php +++ b/install-dev/controllers/http/database.php @@ -44,9 +44,6 @@ class InstallControllerHttpDatabase extends InstallControllerHttp { require_once _PS_INSTALL_MODELS_PATH_.'database.php'; $this->model_database = new InstallModelDatabase(); - - require_once _PS_INSTALL_MODELS_PATH_.'mail.php'; - $this->model_mail = new InstallModelMail(); } /** @@ -136,11 +133,16 @@ class InstallControllerHttpDatabase extends InstallControllerHttp $password = Tools::getValue('smtpPassword'); $email = Tools::getValue('testEmail'); - $result = $this->model_mail->sendTestMail($smtp_checked, $server, $login, $password, $port, $encryption, $email); + require_once _PS_INSTALL_MODELS_PATH_.'mail.php'; + $this->model_mail = new InstallModelMail($smtp_checked, $server, $login, $password, $port, $encryption, $email); + $result = $this->model_mail->send( + $this->l('Test message from PrestaShop'), + $this->l('This is a test message, your server is now available to send email') + ); $this->ajaxJsonAnswer( - (bool)$result, - ($result) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters') + $result === false, + ($result === false) ? $this->l('A test e-mail has been sent to %s', $email) : $this->l('An error occurred while sending email, please verify your parameters') ); } diff --git a/install-dev/controllers/http/process.php b/install-dev/controllers/http/process.php index ed6cd2b72..61035703b 100644 --- a/install-dev/controllers/http/process.php +++ b/install-dev/controllers/http/process.php @@ -93,6 +93,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp $this->processInstallFixtures(); else if (Tools::getValue('installTheme') && !empty($this->session->process_validated['installModules'])) $this->processInstallTheme(); + else if (Tools::getValue('sendEmail') && !empty($this->session->process_validated['installTheme'])) + $this->processSendEmail(); else { // With no parameters, we consider that we are doing a new install, so session where the last process step @@ -235,6 +237,47 @@ class InstallControllerHttpProcess extends InstallControllerHttp if ($this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + $this->session->process_validated['installTheme'] = true; + $this->ajaxJsonAnswer(true); + } + + /** + * PROCESS : sendEmail + * Send information e-mail + */ + public function processSendEmail() + { + require_once _PS_INSTALL_MODELS_PATH_.'mail.php'; + $mail = new InstallModelMail( + $this->session->use_smtp, + $this->session->smtp_server, + $this->session->smtp_login, + $this->session->smtp_password, + $this->session->smtp_port, + $this->session->smtp_encryption, + $this->session->admin_email + ); + + if (file_exists(_PS_INSTALL_LANGS_PATH_.$this->language->getLanguageIso().'/mail_identifiers.txt')) + $content = file_get_contents(_PS_INSTALL_LANGS_PATH_.$this->language->getLanguageIso().'/mail_identifiers.txt'); + else + $content = file_get_contents(_PS_INSTALL_LANGS_PATH_.InstallLanguages::DEFAULT_ISO.'/mail_identifiers.txt'); + + $vars = array( + '{firstname}' => $this->session->admin_firstname, + '{lastname}' => $this->session->admin_lastname, + '{shop_name}' => $this->session->shop_name, + '{passwd}' => $this->session->admin_password, + '{email}' => $this->session->admin_email, + '{shop_url}' => Tools::getHttpHost(true).__PS_BASE_URI__, + ); + $content = str_replace(array_keys($vars), array_values($vars), $content); + + $mail->send( + $this->l('%s - Login information', $this->session->shop_name), + $content + ); + // If last step is fine, we store the fact PrestaShop is installed $this->session->last_step = 'configure'; $this->session->step = 'configure'; @@ -256,6 +299,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp if ($this->session->install_type == 'full') $this->process_steps[] = array('key' => 'installFixtures', 'lang' => $this->l('Install demonstration data')); $this->process_steps[] = array('key' => 'installTheme', 'lang' => $this->l('Install theme')); + if ($this->session->send_informations) + $this->process_steps[] = array('key' => 'sendEmail', 'lang' => $this->l('Send information e-mail')); $this->displayTemplate('process'); } diff --git a/install-dev/langs/de/install.php b/install-dev/langs/de/install.php index 1618c1118..683d88784 100644 --- a/install-dev/langs/de/install.php +++ b/install-dev/langs/de/install.php @@ -155,5 +155,37 @@ 'I agree to the above terms and conditions.' => 'Ich stimme den oben genannten Vertragsbedingungen zu.', 'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL, 'If you have any questions, please visit our documentation and community forum.' => NULL, + 'Test message from PrestaShop' => 'Test-Mail - Installation von PrestaShop', + 'This is a test message, your server is now available to send email' => 'Dies ist eine Testnachricht, Ihr E-Mail-Server funktioniert korrekt.', + '%s - Login information' => NULL, + 'An SQL error occured for entity %1$s: %2$s' => NULL, + 'Cannot create image "%1$s" for entity "%2$s"' => NULL, + 'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL, + 'Cannot create image "%s"' => NULL, + 'SQL error on query %s' => NULL, + 'Server name is not valid' => NULL, + 'You must enter a database name' => NULL, + 'You must enter a database login' => NULL, + 'Tables prefix is invalid' => NULL, + 'Wrong engine chosen for MySQL' => NULL, + 'Cannot convert database data to utf-8' => NULL, + 'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL, + 'Database Server is not found. Please verify the login, password and server fields' => NULL, + 'Connection to MySQL server succeeded, but database "%s" not found' => NULL, + 'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL, + '%s file is not writable (check permissions)' => NULL, + '%s folder is not writable (check permissions)' => NULL, + 'Cannot write settings file' => NULL, + 'Database structure file not found' => NULL, + 'Cannot create group shop' => NULL, + 'Cannot create shop' => NULL, + 'Cannot create shop URL' => NULL, + 'File "language.xml" not found for language iso "%s"' => NULL, + 'File "language.xml" not valid for language iso "%s"' => NULL, + 'Cannot install language "%s"' => NULL, + 'Cannot create admin account' => NULL, + 'Cannot install module "%s"' => NULL, + 'Fixtures class "%s" not found' => NULL, + '"%s" must be an instane of "InstallXmlLoader"' => NULL, ), ); \ No newline at end of file diff --git a/install-dev/langs/de/mail_identifiers.txt b/install-dev/langs/de/mail_identifiers.txt new file mode 100644 index 000000000..93ae0aa85 --- /dev/null +++ b/install-dev/langs/de/mail_identifiers.txt @@ -0,0 +1,8 @@ +Hallo {firstname} {lastname}, + +Ihre persönlichen Login-Daten + +Kennwort: {passwd} +E-Mail-Adresse: {email} + +{shop_name} powered with PrestaShop™ diff --git a/install-dev/langs/en/mail_identifiers.txt b/install-dev/langs/en/mail_identifiers.txt new file mode 100644 index 000000000..3f768acb3 --- /dev/null +++ b/install-dev/langs/en/mail_identifiers.txt @@ -0,0 +1,10 @@ +Hi {firstname} {lastname}, + +Here is your personal login information for {shop_name}: + +Password: {passwd} +E-mail address: {email} + +{shop_name} - {shop_url} + +{shop_url} powered by PrestaShop™ \ No newline at end of file diff --git a/install-dev/langs/es/install.php b/install-dev/langs/es/install.php index ce87c2e7b..4b9306574 100644 --- a/install-dev/langs/es/install.php +++ b/install-dev/langs/es/install.php @@ -155,5 +155,37 @@ 'I agree to the above terms and conditions.' => 'Estoy de acuerdo con los términos y condiciones.', 'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL, 'If you have any questions, please visit our documentation and community forum.' => NULL, + 'Test message from PrestaShop' => 'Instalación Prestashop - Prueba del servidor de correo', + 'This is a test message, your server is now available to send email' => 'Este es un mensaje de prueba, el servidor de correo funciona correctamente.', + '%s - Login information' => NULL, + 'An SQL error occured for entity %1$s: %2$s' => NULL, + 'Cannot create image "%1$s" for entity "%2$s"' => NULL, + 'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL, + 'Cannot create image "%s"' => NULL, + 'SQL error on query %s' => NULL, + 'Server name is not valid' => NULL, + 'You must enter a database name' => NULL, + 'You must enter a database login' => NULL, + 'Tables prefix is invalid' => NULL, + 'Wrong engine chosen for MySQL' => NULL, + 'Cannot convert database data to utf-8' => NULL, + 'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL, + 'Database Server is not found. Please verify the login, password and server fields' => NULL, + 'Connection to MySQL server succeeded, but database "%s" not found' => NULL, + 'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL, + '%s file is not writable (check permissions)' => NULL, + '%s folder is not writable (check permissions)' => NULL, + 'Cannot write settings file' => NULL, + 'Database structure file not found' => NULL, + 'Cannot create group shop' => NULL, + 'Cannot create shop' => NULL, + 'Cannot create shop URL' => NULL, + 'File "language.xml" not found for language iso "%s"' => NULL, + 'File "language.xml" not valid for language iso "%s"' => NULL, + 'Cannot install language "%s"' => NULL, + 'Cannot create admin account' => NULL, + 'Cannot install module "%s"' => NULL, + 'Fixtures class "%s" not found' => NULL, + '"%s" must be an instane of "InstallXmlLoader"' => NULL, ), ); \ No newline at end of file diff --git a/install-dev/langs/es/mail_identifiers.txt b/install-dev/langs/es/mail_identifiers.txt new file mode 100644 index 000000000..685c56930 --- /dev/null +++ b/install-dev/langs/es/mail_identifiers.txt @@ -0,0 +1,11 @@ +Hola {firstname} {lastname}, + +Tu información personal en {shop_name} es: + +* Contraseña: {passwd} +* Email: {email} + +{shop_name} - {shop_url} + + +{shop_url} desarrollado por PrestaShop® \ No newline at end of file diff --git a/install-dev/langs/fr/install.php b/install-dev/langs/fr/install.php index 9a4d44622..fe42995aa 100644 --- a/install-dev/langs/fr/install.php +++ b/install-dev/langs/fr/install.php @@ -50,7 +50,7 @@ return array( 'Shoes and accessories' => 'Chaussures et accessoires', 'Sports and Entertainment' => 'Sports et loisirs', 'Travel' => 'Voyage et tourisme', - 'Database is connected' => 'La base de donnée est connectée', + 'Database is connected' => 'La base de données est connectée', 'A test e-mail has been sent to %s' => 'Un e-mail de test a été envoyé à %s', 'An error occurred while sending email, please verify your parameters' => 'Une erreur est survenue lors de l\'envoi de l\'e-mail, merci de vérifier vos paramètres', 'Create settings.inc file' => 'Création du fichier settings.inc', @@ -97,9 +97,9 @@ return array( 'Re-type to confirm:' => 'Confirmation du mot de passe :', 'Receive this information by e-mail' => 'Recevez ces informations par e-mail', 'Warning: You will recieve these informations only if your e-mail configuration is correct.' => 'Attention : vous ne recevrez ces informations que si votre configuration des e-mails est correcte', - 'Configure your database by filling out the following fields:' => 'Configurez la connection à votre base de donnée en remplissant les champs suivants :', - 'You have to create a database, help available in ~/install/langs/%1$s/README.txt' => 'Vous devez créer une base de donnée, de l\'aide est disponible dans le fichier ~/install/langs/%1$s/README.txt', - 'You have to create a database, help available in ~/install/README.txt' => 'Vous devez créer une base de donnée, de l\'aide est disponible dans le fichier ~/install/README.txt', + 'Configure your database by filling out the following fields:' => 'Configurez la connection à votre base de données en remplissant les champs suivants :', + 'You have to create a database, help available in ~/install/langs/%1$s/README.txt' => 'Vous devez créer une base de données, de l\'aide est disponible dans le fichier ~/install/langs/%1$s/README.txt', + 'You have to create a database, help available in ~/install/README.txt' => 'Vous devez créer une base de données, de l\'aide est disponible dans le fichier ~/install/README.txt', 'Database server address:' => 'Addresse du serveur de la base :', 'If you want to use a different port, add :XX after your server address where XX is your port number.' => 'Si vous souhaitez utiliser un port différent, ajoutez :XX à l\'adresse de votre serveur, XX étant le numéro de votre port.', 'Database name:' => 'Nom de la base :', @@ -156,6 +156,38 @@ return array( 'PrestaShop core is released under the OSL 3.0 while PrestaShop modules and themes are released under the AFL 3.0.' => 'Le coeur de PrestaShop est publié sous licence OSL 3.0 tandis que les modules et thèmes sont publiés sous licence AFL 3.0.', 'I agree to the above terms and conditions.' => 'J\'approuve les termes et conditions du contrat ci-dessus.', 'I agree to participate in improving the solution by sending anonymous information about my configuration.' => 'J\'accepte de participer à l\'amélioration de la solution en envoyant des informations anonymes sur ma configuration', - 'If you have any questions, please visit our documentation and community forum.' => 'Si vous avez la moindre question, n\'hésitez pas à visiter notre documentation et notre forum communautaire.' + 'If you have any questions, please visit our documentation and community forum.' => 'Si vous avez la moindre question, n\'hésitez pas à visiter notre documentation et notre forum communautaire.', + 'Test message from PrestaShop' => 'Message test de PrestaShop', + 'This is a test message, your server is now available to send email' => 'Ceci est un message de test, votre serveur d\'email fonctionne correctement.', + '%s - Login information' => '%s - Identifiants de connection', + 'An SQL error occured for entity %1$s: %2$s' => 'Une erreur SQL est survenue pour l\'entité %1$s : %2$s', + 'Cannot create image "%1$s" for entity "%2$s"' => 'Impossible de créer l\'image "%1$s" pour l\'entité "%2$s"', + 'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => 'Impossible de créer l\'image "%1$s" (mauvaises permissions sur le dossier "%2$s")', + 'Cannot create image "%s"' => 'Impossible de créer l\'image "%s"', + 'SQL error on query %s' => 'Erreur SQL sur la requête %s', + 'Server name is not valid' => 'L\'adresse du serveur est invalide', + 'You must enter a database name' => 'Vous devez choisir une base de données', + 'You must enter a database login' => 'Vous devez entrer un identifiant pour la base', + 'Tables prefix is invalid' => 'Le préfixe des tables est invalide', + 'Wrong engine chosen for MySQL' => 'Moteur pour MySQL invalide', + 'Cannot convert database data to utf-8' => 'Impossible de convertir la base en utf-8', + 'At least one table with same prefix was already found, please change your prefix or drop your database' => 'Au moins une table avec le même préfixe a été trouvée, merci de changer votre préfixe ou de supprimer vos tables existantes', + 'Database Server is not found. Please verify the login, password and server fields' => 'Impossible de se connecter au serveur de la base de données. Vérifiez vos identifiants de connection', + 'Connection to MySQL server succeeded, but database "%s" not found' => 'La connection au serveur de base de données a réussi, mais la base "%s" n\'a pas été trouvée', + 'Engine innoDB is not supported by your MySQL server, please use MyISAM' => 'Le moteur innoDB n\'est pas supporté par votre serveur SQL, merci d\'utiliser MyISAM', + '%s file is not writable (check permissions)' => 'Le fichier %s ne peut être écrit (vérifiez vos permissions fichiers)', + '%s folder is not writable (check permissions)' => 'Le dossier %s ne peut être écrit (vérifiez vos permissions fichiers)', + 'Cannot write settings file' => 'Impossible de générer le fichier settings', + 'Database structure file not found' => 'Le fichier de structure de base de donnée n\'a pu être trouvé', + 'Cannot create group shop' => 'Impossible de créer le groupe de boutique', + 'Cannot create shop' => 'Impossible de créer la boutique', + 'Cannot create shop URL' => 'Impossible de créer l\'URL pour la boutique', + 'File "language.xml" not found for language iso "%s"' => 'Le fichier "language.xml" n\'a pas été trouvé pour l\'iso "%s"', + 'File "language.xml" not valid for language iso "%s"' => 'Le fichier "language.xml" est invalide pour l\'iso "%s"', + 'Cannot install language "%s"' => 'Impossible d\'installer la langue "%s"', + 'Cannot create admin account' => 'Impossible de créer le compte administrateur', + 'Cannot install module "%s"' => 'Impossible d\'installer le module "%s"', + 'Fixtures class "%s" not found' => 'La classe "%s" pour les fixtures n\'a pas été trouvée', + '"%s" must be an instane of "InstallXmlLoader"' => '"%s" doit être une instance de "InstallXmlLoader"', ), ); \ No newline at end of file diff --git a/install-dev/langs/fr/mail_identifiers.txt b/install-dev/langs/fr/mail_identifiers.txt new file mode 100644 index 000000000..51badd98f --- /dev/null +++ b/install-dev/langs/fr/mail_identifiers.txt @@ -0,0 +1,13 @@ +Bonjour {firstname} {lastname}, + +Voici les informations personnelles concernant votre nouvelle boutique {shop_name} : + +Mot de passe : {passwd} +Adresse électronique : {email} + + +{shop_name} - {shop_url} + + + +{shop_url} réalisé par PrestaShop™ \ No newline at end of file diff --git a/install-dev/langs/it/install.php b/install-dev/langs/it/install.php index f3e84e488..757157d82 100644 --- a/install-dev/langs/it/install.php +++ b/install-dev/langs/it/install.php @@ -155,5 +155,37 @@ 'I agree to the above terms and conditions.' => 'Accetto i termini e le condizioni del contratto seguente.', 'I agree to participate in improving the solution by sending anonymous information about my configuration.' => NULL, 'If you have any questions, please visit our documentation and community forum.' => NULL, + 'Test message from PrestaShop' => 'Installazione di Prestashop - prova del server di e-mail', + 'This is a test message, your server is now available to send email' => 'Questo è un messaggio di testo. Il tuo server è adesso impostato per inviare e-mail.', + '%s - Login information' => NULL, + 'An SQL error occured for entity %1$s: %2$s' => NULL, + 'Cannot create image "%1$s" for entity "%2$s"' => NULL, + 'Cannot create image "%1$s" (bad permissions on folder "%2$s")' => NULL, + 'Cannot create image "%s"' => NULL, + 'SQL error on query %s' => NULL, + 'Server name is not valid' => NULL, + 'You must enter a database name' => NULL, + 'You must enter a database login' => NULL, + 'Tables prefix is invalid' => NULL, + 'Wrong engine chosen for MySQL' => NULL, + 'Cannot convert database data to utf-8' => NULL, + 'At least one table with same prefix was already found, please change your prefix or drop your database' => NULL, + 'Database Server is not found. Please verify the login, password and server fields' => NULL, + 'Connection to MySQL server succeeded, but database "%s" not found' => NULL, + 'Engine innoDB is not supported by your MySQL server, please use MyISAM' => NULL, + '%s file is not writable (check permissions)' => NULL, + '%s folder is not writable (check permissions)' => NULL, + 'Cannot write settings file' => NULL, + 'Database structure file not found' => NULL, + 'Cannot create group shop' => NULL, + 'Cannot create shop' => NULL, + 'Cannot create shop URL' => NULL, + 'File "language.xml" not found for language iso "%s"' => NULL, + 'File "language.xml" not valid for language iso "%s"' => NULL, + 'Cannot install language "%s"' => NULL, + 'Cannot create admin account' => NULL, + 'Cannot install module "%s"' => NULL, + 'Fixtures class "%s" not found' => NULL, + '"%s" must be an instane of "InstallXmlLoader"' => NULL, ), ); \ No newline at end of file diff --git a/install-dev/langs/it/mail_identifiers.txt b/install-dev/langs/it/mail_identifiers.txt new file mode 100644 index 000000000..b3c12c478 --- /dev/null +++ b/install-dev/langs/it/mail_identifiers.txt @@ -0,0 +1,12 @@ +Salve {firstname} {lastname}, + +I dati personali di login del tuo negozio {shop_name}: + +* Password: {passwd} +* Indirizzo e-mail: {email} + +{shop_name} - {shop_url} + + + +{shop_url} powered by PrestaShop™ \ No newline at end of file diff --git a/install-dev/models/install.php b/install-dev/models/install.php index e5f3f05ac..6497fcb3b 100644 --- a/install-dev/models/install.php +++ b/install-dev/models/install.php @@ -114,7 +114,7 @@ class InstallModelInstall extends InstallAbstractModel if ($errors = $sql_loader->getErrors()) { foreach ($errors as $error) - $this->setError($this->language->l('An SQL error occured: %1$s', $error['error'])); + $this->setError($this->language->l('SQL error on query %s', $error['error'])); return false; } diff --git a/install-dev/models/mail.php b/install-dev/models/mail.php index 93673e3f7..22225e0ea 100644 --- a/install-dev/models/mail.php +++ b/install-dev/models/mail.php @@ -28,23 +28,49 @@ class InstallModelMail extends InstallAbstractModel { /** - * Send a test email + * @param bool $smtp_checked + * @param string $server + * @param string $login + * @param string $password + * @param int $port + * @param string $encryption + * @param string $email */ - public function sendTestMail($smtp_checked, $server, $login, $password, $port, $encryption, $email) + public function __construct($smtp_checked, $server, $login, $password, $port, $encryption, $email) { + parent::__construct(); + require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift.php'); require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift/Connection/SMTP.php'); require_once(_PS_INSTALL_PATH_.'../tools/swift/Swift/Connection/NativeMail.php'); + $this->smtp_checked = $smtp_checked; + $this->server = $server; + $this->login = $login; + $this->password = $password; + $this->port = $port; + $this->encryption = $encryption; + $this->email = $email; + } + + /** + * Send a mail + * + * @param string $subject + * @param string $content + * @return bool|string false is everything was fine, or error string + */ + public function send($subject, $content) + { try { // Test with custom SMTP connection - if ($smtp_checked) + if ($this->smtp_checked) { - $smtp = new Swift_Connection_SMTP($server, $port, ($encryption == "off") ? Swift_Connection_SMTP::ENC_OFF : (($encryption == "tls") ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL)); - $smtp->setUsername($login); - $smtp->setpassword($password); + $smtp = new Swift_Connection_SMTP($this->server, $this->port, ($this->encryption == "off") ? Swift_Connection_SMTP::ENC_OFF : (($this->encryption == "tls") ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL)); + $smtp->setUsername($this->login); + $smtp->setpassword($this->password); $smtp->setTimeout(5); $swift = new Swift($smtp); } @@ -52,22 +78,20 @@ class InstallModelMail extends InstallAbstractModel // Test with normal PHP mail() call $swift = new Swift(new Swift_Connection_NativeMail()); - $subject = $this->language->l('Test message from PrestaShop'); - $content = $this->language->l('This is a test message, your server is now available to send email'); $message = new Swift_Message($subject, $content, 'text/html'); - - if (@$swift->send($message, $email, 'no-reply@'.Tools::getHttpHost())) - $result = true; + if (@$swift->send($message, $this->email, 'no-reply@'.Tools::getHttpHost())) + $result = false; else - $result = 999; + $result = 'Could not send message'; $swift->disconnect(); } catch (Swift_Exception $e) { - $result = $e->getCode(); + $result = $e->getMessage(); } return $result; } + }