Programmer's Reference Guide
| Utiliser différents transports |
Courriel HTML
Pour envoyer un courriel au format HTML, définissez le corps du message en utilisant la
méthode setBodyHTML() à la place de setBodyText(). Le type de
contenu MIME sera automatiquement définit à text/html. Si vous utilisez les
formats textes et HTML, un message MIME de type multipart/alternative sera automatiquement
généré :
Exemple #1 Envoyer des courriels HTML
- $mail = new Zend_Mail();
- $mail->setBodyText('Mon texte de test');
- $mail->setBodyHtml('Mon texte de test');
- $mail->setFrom('somebody@exemple.com', 'Un expéditeur');
- $mail->addTo('somebody_else@exemple.com', 'Un destinataire');
- $mail->setSubject('Sujet de test');
- $mail->send();
| Utiliser différents transports |
Add A Comment
Please do not report issues via comments; use the ZF Issue Tracker.
If you have a JIRA/Crowd account, we suggest you login first before commenting.
Select a Version
Languages Available
Components
Search the Manual
Navigation
- Guide de référence du programmeur
- Guide de référence du programmeur
- Guide de référence Zend Framework
- Zend_Mail
- Introduction
- Envoyer des courriels en utilisant SMTP
- Envoyer plusieurs courriels par connexion SMTP
- Utiliser différents transports
- Courriel HTML
- Fichiers joints
- Ajouter des destinataires
- Contrôler les limites MIME
- En-têtes additionnels
- Jeux de caractères
- Encodage
- Authentification SMTP
- Sécuriser les transports SMTP
- Lire des courriels

Comments
On the testing server using a local stmp server everything seems to be fine. All mails arrive without any problems.
However, the same mails sent by the production server won't get decoded correctly on some mail servers. I mean, the same email sent to a gmail user works fine, while other mail servers link 'index.hu', or 'citromail.hu' decode the mails incorrectly. The body gets truncated after the first not English character.
The problem is, that I cannot debug those mail servers, and cannot see the raw versions of the arriving content. I guess that I am missing some settings. As other mail servers work fine, perhaps they use some different settings as default not set by me.
Does anyone have any idea?
$mail = new Zend_Mail('UTF-8');
//$mail->setHeaderEncoding(Zend_Mime::ENCODING_QUOTEDPRINTABLE);
$mail->setFrom( EMAIL_FROM_ADDRESS , EMAIL_FROM_NAME);
$mail->addTo( $email , $username );
$mail->setSubject( EMAIL_SUBJECT );
$body = "1234->ő";
$mail->setBodyHtml($body, "utf-8","utf-8" );
Причем так чтобы изображения можно было просматривать офлайн.
Can someone show example, how to send mail with images?
You need to encode/decode your code.
Exist two functions native php to do this:
utf8_encode && utf8_decode
I use grotesque form, because i don't know the beautiful form to do:
...
$mail->setBodyText(utf8_decode('São Paulo'));
$mail->setBodyHtml(utf8_decode('Minha mensagem é essa'));
...
$mail->send();
I think it will ok in russian.
Post your result for we see too.
=D
PS: sorry to mine english, i no have pratice in to write ^^
>>пример как отправлять письмо с изображением?
Отправка письма с вложением
и отправка HTML-письма с вложением существенно отличаются по своей природе.
Конечно же, и те и те находятся в теле письма, закодированы в base64, но используемые в обоих случаях заголовки различаются.
В данном разделе описывается, как отправить HTML-файл с внедренными (в отличие от прикрепленных) изображениями, используя класс Mime_mail. Подразумевается, что предыдущий раздел Вы уже прочитали.
<?php
include('Mail.php');
include('Mail/mime.php');
$text = 'Text version of email';
$html = '<html><body>HTML version of email<img src="image.jpg"></body></html>';
$file = '/tmp/image.jpg';
$crlf = "\r\n";
$hdrs = array(
'From' => 'you@yourdomain.com',
'Subject' => 'Test mime message'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->addHTMLImage ($file, 'image/jpeg');
$mime->setHTMLBody($html);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send('postmaster@localhost', $hdrs, $body);
?>
источник: http://www.hostmake.ru/articles/php_perl/648/
Так вообще можно? Кроме как прикрепить к письму я не вижу выхода.
Если пользоваться почтовиком, то письмо сохраняется на винт и его всегда можно прочитать оффлайн.