config
This commit is contained in:
parent
ce53ab4128
commit
f4c1243d6f
@ -11,17 +11,18 @@ class Mail
|
||||
{
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->config = $c->profil->mail;
|
||||
|
||||
$cnfg = array('auth' => 'login',
|
||||
'username' => $this->config->username,
|
||||
'password' => $this->config->password);
|
||||
|
||||
|
||||
$this->mail = new Zend_Mail();
|
||||
|
||||
|
||||
if ($this->config->method == 'smtp') {
|
||||
$tr = new Zend_Mail_Transport_Smtp($this->config->smtp_host);
|
||||
$this->mail->setDefaultTransport($tr);
|
||||
} elseif ($this->config->method == 'smtpauth') {
|
||||
$cnfg = array(
|
||||
'auth' => 'login',
|
||||
'username' => $this->config->username,
|
||||
'password' => $this->config->password
|
||||
);
|
||||
$tr = new Zend_Mail_Transport_Smtp($this->config->smtp_host, $cnfg);
|
||||
$this->mail->setDefaultTransport($tr);
|
||||
} else {
|
||||
@ -29,7 +30,7 @@ class Mail
|
||||
$this->mail->setDefaultTransport($tr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Champ From en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
@ -39,7 +40,7 @@ class Mail
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->mail->setFrom($email, ucfirst($configKey));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Reply-To address
|
||||
* @param string $email
|
||||
@ -48,7 +49,7 @@ class Mail
|
||||
{
|
||||
$this->mail->setReplyTo($email);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Champ To en fonction de la clé de configuration
|
||||
* @param string $configKey
|
||||
@ -58,7 +59,7 @@ class Mail
|
||||
$email = $this->config->email->$configKey;
|
||||
$this->mail->addTo($email, ucfirst($configKey));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajout d'un champ To en spécifiant l'email et le nom qui doit apparaitre
|
||||
* @param string $email
|
||||
@ -68,7 +69,7 @@ class Mail
|
||||
{
|
||||
$this->mail->addTo($email, $this->txtConvert($nom));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Définit le sujet de l'email
|
||||
* @param string $texte
|
||||
@ -77,7 +78,7 @@ class Mail
|
||||
{
|
||||
$this->mail->setSubject($this->txtConvert($texte));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Définit le corps de l'email au format texte
|
||||
* @param string $texte
|
||||
@ -86,7 +87,7 @@ class Mail
|
||||
{
|
||||
$this->mail->setBodyText($this->txtConvert($texte));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Définit le corps de l'email au format html
|
||||
* @param string $html
|
||||
@ -95,7 +96,7 @@ class Mail
|
||||
{
|
||||
$this->mail->setBodyHtml($this->txtConvert($html));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Envoi de l'emai
|
||||
*/
|
||||
@ -103,10 +104,10 @@ class Mail
|
||||
{
|
||||
return $this->mail->send();
|
||||
}
|
||||
|
||||
|
||||
//We suppose that character encoding of strings is UTF-8 on PHP script.
|
||||
protected function txtConvert($string) {
|
||||
return mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8');
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user