If I set the multi format messages like this one:
$message = new Swift_Message('Mail\'s subject', "<p>this is paragrapah</p>", 'text/html');
$message->attach( new Swift_Message_Part( "This is a pure text msg" , 'text/plain'));
I just found pure text format is always in my gmail or outlook client.
are there any way to set priority of email to HTML, and text email is only used when html is turned off.
Thanks
Can we set email format priority?
Moderators: Chris Corbyn, General Moderators
-
machinehead933
- Forum Newbie
- Posts: 7
- Joined: Tue Jan 20, 2009 10:48 pm
Re: Can we set email format priority?
You cannot set the priority per se. If you include both an HTML and plain text version of the email to your recipient, it will be up to the mail client settings to choose how the mail will be displayed. There is no way to let one format take precedence over the other.
Re: Can we set email format priority?
if I only send html format, will that email be received if client set the plain text?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Can we set email format priority?
You're actually doing this wrong. Plain text will always be in your inbox and there will be no way to change it. It will work correctly if you do this:
Basically both alternatives must be attached as a "part". The standard body is ignored once you've added any parts. This behavior has been changed in version 4 (beta available at the top of this forum).
Code: Select all
$message = new Swift_Message('Mail\'s subject');
$message->attach(new Swift_Message_Part("<p>this is paragrapah</p>", 'text/html'));
$message->attach( new Swift_Message_Part( "This is a pure text msg" , 'text/plain'));Re: Can we set email format priority?
Thank you for your reply.
I am using symfony 1.2, and want to use swiftMailer in it, the error is if I use this one:
$message = new Swift_Message('Account Activation', $this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true)), 'text/html');
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>false))), 'text/plain');
I will only have text email, but if I use this one only
$message = new Swift_Message('Account Activation', $this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true)), 'text/html');
I will have html email.
Based on your introduciton, if I use:
$message = new Swift_Message("Account Activation");
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true))), 'text/html');
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>false))), 'text/plain');
Then the email I sent is this kind:
<p>Dear frank,</p>
<p>Thank you for registration on line to use our <b>free love matching service</b>.</p>
<p>Please click the following link to activate your account:</p>
You see, all the html tags are preserved!
I know your guys aer not symfony guy, but if you can point out reason, that will be great.
Thanks.
I am using symfony 1.2, and want to use swiftMailer in it, the error is if I use this one:
$message = new Swift_Message('Account Activation', $this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true)), 'text/html');
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>false))), 'text/plain');
I will only have text email, but if I use this one only
$message = new Swift_Message('Account Activation', $this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true)), 'text/html');
I will have html email.
Based on your introduciton, if I use:
$message = new Swift_Message("Account Activation");
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true))), 'text/html');
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>false))), 'text/plain');
Then the email I sent is this kind:
<p>Dear frank,</p>
<p>Thank you for registration on line to use our <b>free love matching service</b>.</p>
<p>Please click the following link to activate your account:</p>
You see, all the html tags are preserved!
I know your guys aer not symfony guy, but if you can point out reason, that will be great.
Thanks.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Can we set email format priority?
You seem to have your closing parentheses in the wrong place 
The "text/html" argument must be passed to Swift_Message_Part
Same goes for the "text/plain" argument.
The "text/html" argument must be passed to Swift_Message_Part
Code: Select all
$message = new Swift_Message("Account Activation");
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>true)), 'text/html'));
$message->attach( new Swift_Message_Part($this->getPartial('sendActivationBody', array("user"=>$users,"html"=>false)), 'text/plain'));Re: Can we set email format priority?
Definitely correct!
Thanks for your pointing out, this has wasted me two days!
What a stupid error.
Thanks again for your help.
Thanks for your pointing out, this has wasted me two days!
What a stupid error.
Thanks again for your help.