Quantcast

Sending html mail with Zend\Mail\Message

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Sending html mail with Zend\Mail\Message

Oscar Fanelli
I want to send an html mail.
I tried with this:

$mail = new \Zend\Mail\Message();

        

        $html = new \Zend\Mime\Part($myHtmlBody);
        $html->type = "text/html";

        

        $body = new \Zend\Mime\Message();
        $body->setParts(array($html));

        

        $mail->setEncoding('UTF-8')
        ->setBody($body)
         ->setSubject($mySubject);


but it puts the mail body as an attachment.
Is it a bug?

---


Oscar Fanelli
Fondatore Gamempire.it
Email secondaria: [hidden email]
Skype: gamempire
Tel: 3388696167

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Sending html mail with Zend\Mail\Message

Jurian Sluiman-3
2012/8/13 Oscar Fanelli <[hidden email]>
I want to send an html mail.
I tried with this:

$mail = new \Zend\Mail\Message();

        

        $html = new \Zend\Mime\Part($myHtmlBody);
        $html->type = "text/html";

        

        $body = new \Zend\Mime\Message();
        $body->setParts(array($html));

        

        $mail->setEncoding('UTF-8')
        ->setBody($body)
         ->setSubject($mySubject);


but it puts the mail body as an attachment.
Is it a bug?

There are a few bugs in Zend\Mail in conjunction with Zend\Mime. One is what you describe above. It will only work if you add an empty Zend\Mime\Part first with a type of text/plain. Then you'll have a correct html message.

Similarly I have problems with attachments as Zend\Mime\Parts which are also displayed incorrectly (described in another thread at this ML). I hope these things will be addressed soon (meanwhile I am using Swift Mailer from the Symfony project).
--
Jurian Sluiman
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Sending html mail with Zend\Mail\Message

Oscar Fanelli
Thanks a lot for the workaround.
I will wait for something stable.

---


Oscar Fanelli
Fondatore Gamempire.it
Email secondaria: [hidden email]
Skype: gamempire
Tel: 3388696167

Il giorno 13/ago/2012, alle ore 14:56, Jurian Sluiman <[hidden email]> ha scritto:

2012/8/13 Oscar Fanelli <[hidden email]>
I want to send an html mail.
I tried with this:

$mail = new \Zend\Mail\Message();

        

        $html = new \Zend\Mime\Part($myHtmlBody);
        $html->type = "text/html";
        
        $body = new \Zend\Mime\Message();
        $body->setParts(array($html));
        
        $mail->setEncoding('UTF-8')
        ->setBody($body)
         ->setSubject($mySubject);


but it puts the mail body as an attachment.
Is it a bug?

There are a few bugs in Zend\Mail in conjunction with Zend\Mime. One is what you describe above. It will only work if you add an empty Zend\Mime\Part first with a type of text/plain. Then you'll have a correct html message.

Similarly I have problems with attachments as Zend\Mime\Parts which are also displayed incorrectly (described in another thread at this ML). I hope these things will be addressed soon (meanwhile I am using Swift Mailer from the Symfony project).
--
Jurian Sluiman

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Sending html mail with Zend\Mail\Message

ThaDafinser

A little bit off topic maybe, but:

You should always send a text/plain version in addition to the html version as best practice. (If i remind correct)

Am 13.08.2012 15:05 schrieb "Oscar Fanelli" <[hidden email]>:
>
> Thanks a lot for the workaround.
> I will wait for something stable.
>
> ---
>
>
> Oscar Fanelli
> Fondatore Gamempire.it
> Email: [hidden email]
> Email secondaria: [hidden email]
> Skype: gamempire
> Tel: 3388696167
>
> Il giorno 13/ago/2012, alle ore 14:56, Jurian Sluiman <[hidden email]> ha scritto:
>
>> 2012/8/13 Oscar Fanelli <[hidden email]>
>>>
>>> I want to send an html mail.
>>> I tried with this:
>>>
>>> $mail = new \Zend\Mail\Message();
>>>
>>>         
>>>
>>>         $html = new \Zend\Mime\Part($myHtmlBody);
>>>         $html->type = "text/html";
>>>         
>>>         $body = new \Zend\Mime\Message();
>>>         $body->setParts(array($html));
>>>         
>>>         $mail->setEncoding('UTF-8')
>>>         ->setBody($body)
>>>          ->setSubject($mySubject);
>>>
>>>
>>> but it puts the mail body as an attachment.
>>> Is it a bug?
>>
>>
>> There are a few bugs in Zend\Mail in conjunction with Zend\Mime. One is what you describe above. It will only work if you add an empty Zend\Mime\Part first with a type of text/plain. Then you'll have a correct html message.
>>
>> Similarly I have problems with attachments as Zend\Mime\Parts which are also displayed incorrectly (described in another thread at this ML). I hope these things will be addressed soon (meanwhile I am using Swift Mailer from the Symfony project).
>> --
>> Jurian Sluiman
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Sending html mail with Zend\Mail\Message

Oscar Fanelli
I tried to do it, but it display simultaneously the plain text and the html text

---


Oscar Fanelli
Fondatore Gamempire.it
Email secondaria: [hidden email]
Skype: gamempire
Tel: 3388696167

Il giorno 13/ago/2012, alle ore 17:38, Martin Keckeis <[hidden email]> ha scritto:

A little bit off topic maybe, but:

You should always send a text/plain version in addition to the html version as best practice. (If i remind correct)

Am 13.08.2012 15:05 schrieb "Oscar Fanelli" <[hidden email]>:
>
> Thanks a lot for the workaround.
> I will wait for something stable.
>
> ---
>
>
> Oscar Fanelli
> Fondatore Gamempire.it
> Email: [hidden email]
> Email secondaria: [hidden email]
> Skype: gamempire
> Tel: 3388696167
>
> Il giorno 13/ago/2012, alle ore 14:56, Jurian Sluiman <[hidden email]> ha scritto:
>
>> 2012/8/13 Oscar Fanelli <[hidden email]>
>>>
>>> I want to send an html mail.
>>> I tried with this:
>>>
>>> $mail = new \Zend\Mail\Message();
>>>
>>>         
>>>
>>>         $html = new \Zend\Mime\Part($myHtmlBody);
>>>         $html->type = "text/html";
>>>         
>>>         $body = new \Zend\Mime\Message();
>>>         $body->setParts(array($html));
>>>         
>>>         $mail->setEncoding('UTF-8')
>>>         ->setBody($body)
>>>          ->setSubject($mySubject);
>>>
>>>
>>> but it puts the mail body as an attachment.
>>> Is it a bug?
>>
>>
>> There are a few bugs in Zend\Mail in conjunction with Zend\Mime. One is what you describe above. It will only work if you add an empty Zend\Mime\Part first with a type of text/plain. Then you'll have a correct html message.
>>
>> Similarly I have problems with attachments as Zend\Mime\Parts which are also displayed incorrectly (described in another thread at this ML). I hope these things will be addressed soon (meanwhile I am using Swift Mailer from the Symfony project).
>> --
>> Jurian Sluiman
>
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Sending html mail with Zend\Mail\Message

outeredge
Hi Oscar, 

You need to set the message's Content-Type header to;

$headers->get('content-type')->setType('multipart/alternative');

On 13 August 2012 19:46, Oscar Fanelli <[hidden email]> wrote:
I tried to do it, but it display simultaneously the plain text and the html text

---


Oscar Fanelli
Fondatore Gamempire.it
Email secondaria: [hidden email]
Skype: gamempire
Tel: 3388696167

Il giorno 13/ago/2012, alle ore 17:38, Martin Keckeis <[hidden email]> ha scritto:

A little bit off topic maybe, but:

You should always send a text/plain version in addition to the html version as best practice. (If i remind correct)

Am 13.08.2012 15:05 schrieb "Oscar Fanelli" <[hidden email]>:
>
> Thanks a lot for the workaround.
> I will wait for something stable.
>
> ---
>
>
> Oscar Fanelli
> Fondatore Gamempire.it
> Email: [hidden email]
> Email secondaria: [hidden email]
> Skype: gamempire
> Tel: 3388696167
>
> Il giorno 13/ago/2012, alle ore 14:56, Jurian Sluiman <[hidden email]> ha scritto:
>
>> 2012/8/13 Oscar Fanelli <[hidden email]>
>>>
>>> I want to send an html mail.
>>> I tried with this:
>>>
>>> $mail = new \Zend\Mail\Message();
>>>
>>>         
>>>
>>>         $html = new \Zend\Mime\Part($myHtmlBody);
>>>         $html->type = "text/html";
>>>         
>>>         $body = new \Zend\Mime\Message();
>>>         $body->setParts(array($html));
>>>         
>>>         $mail->setEncoding('UTF-8')
>>>         ->setBody($body)
>>>          ->setSubject($mySubject);
>>>
>>>
>>> but it puts the mail body as an attachment.
>>> Is it a bug?
>>
>>
>> There are a few bugs in Zend\Mail in conjunction with Zend\Mime. One is what you describe above. It will only work if you add an empty Zend\Mime\Part first with a type of text/plain. Then you'll have a correct html message.
>>
>> Similarly I have problems with attachments as Zend\Mime\Parts which are also displayed incorrectly (described in another thread at this ML). I hope these things will be addressed soon (meanwhile I am using Swift Mailer from the Symfony project).
>> --
>> Jurian Sluiman
>
>





--
OuterEdge UK - an interactive web development agency
www.outeredgeuk.com

Registered in England 3712531
Registered Office: 1st Floor, 48-50 North Road, LANCING, BN15 9AB

Loading...