Programmer's Reference Guide

Using Different Transports

HTML E-Mail

To send an e-mail in HTML format, set the body using the method setBodyHTML() instead of setBodyText(). The MIME content type will automatically be set to text/html then. If you use both HTML and Text bodies, a multipart/alternative MIME message will automatically be generated:

Example #1 Sending HTML E-Mail

  1. $mail = new Zend_Mail();
  2. $mail->setBodyText('My Nice Test Text');
  3. $mail->setBodyHtml('My Nice <b>Test</b> Text');
  4. $mail->setFrom('somebody@example.com', 'Some Sender');
  5. $mail->addTo('somebody_else@example.com', 'Some Recipient');
  6. $mail->setSubject('TestSubject');
  7. $mail->send();

Using Different Transports

Comments

I have problems with HTML mails on some server.

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?
Hi,

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 ^^
Как отправить письмо c картинками

>>пример как отправлять письмо с изображением?

Отправка письма с вложением
и отправка 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/


gg

Может кто-нибудь показать пример как отправлять письмо с изображением?
Причем так чтобы изображения можно было просматривать офлайн.


Так вообще можно? Кроме как прикрепить к письму я не вижу выхода.
Если пользоваться почтовиком, то письмо сохраняется на винт и его всегда можно прочитать оффлайн.

+ 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.

  • BBCode is allowed in the comment markup

  • Select a Version

    Languages Available

    Components

    Search the Manual