I want to send some information on mail body. When I try its works but Google shows trimmed content(...).
My code is like this:
$name = $e->name;
$code=$request->code;
$mes2="loretmtext,";
$mes3="loremtext";
$mes4="Code:".$code;
$mes5="e:".$name;
$mes6="text"
//and i send mail function
$msg= $mes2."<br />".$mes3."<br />".$mes4."<br />".$mes5."<br />".$mes6."<br />";
How can i solve?
Need to add "Content-Type: text/html; in header mail request to use html tag <br /> in you massage
look this:
Send HTML in email via PHP
Related
I am trying to send email using SMTP in Laravel everything is good but the html elements is coming along in the email body.
i.e.,
I am getting the below as mail
<h2>Welcome</h2><br><p>Hello user</p><br><p>Thanks</p>
Instead of
WelcomeHello userThanks
Here is my Code :
What is the thing i am missing to make it applied on the content of the email
$msg = "<h2>Welcome</h2><br><p>Hello user</p><br><p>Thanks</p>"
$message->setBody($msg);
$message->to('user#gmail.com');
$message->subject('Welcome Mail');
Try this...
$msg = "Welcome
Hello user
Thanks"
$message->setBody($msg);
$message->to('user#gmail.com');
$message->subject('Welcome Mail');
One possible solution is to wrap your HTML code in body tag.
Take a look at Laravel mail api too.
Seems like you want to send an email as HTML format:
mail($to, $subject, $message, $headers);
You will have to use the $headers parameter.
The last parameter, the headers, are optional for the function but required for sending HTML email, as this is where we are able to pass along the Content-Type declaration telling email clients to parse the email as HTML.
Source
Or, if you just want to add breaking lines and you leave HTML elements:
$msg = "Welcome \n Hello user \n Thanks"
I have a form that will dynamically send emailers . This form takes the email id of the recipient ,the subject and the body content.
I am using PHPMailer class to go about this. When it comes to plain text ,the emailers work just fine. But I want to add a functionality where the users can paste html into the body part so that the emailer can parse/read them and send the html'ized version of the emails.
I tried this , but it didn't work as the the entire HTML was mailed as text.
$email_msg = htmlentities($_POST['mail_msg'], ENT_QUOTES, "UTF-8");
Any advice would be helpful .
Thanks in advance.
Did you set the PHPMailer default to HTML:
$mail->IsHTML(true);
Modify your mail headers :
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";
I am trying to fetch emails from Gmail by PHP using imap. I'm getting emails perfectly but my problem is that some of the messages are in a multipart format, and I would like to remove the multipart format.
For example, one Gmail message is "Hi, how are you? I am fine", but the message has text like this:
"Hi, how are you? I am fine
------=_NextPart_000_000B_01CE5613.4A5D9F20 // multipart format
Content-Type: text/html; // multipart format
charset="us-ascii" // multipart format
Content-Transfer-Encoding: quoted-printable". // multipart format
Hi Try this,
$mailNumber = '11796';
$result = $mailbox->getMessageContent($mailNumber);
if ($result->textHtml)
echo '<br>'.$result->textHtml;
else
echo '<br>'.$result->textPlain;
Can you try
imap_fetchbody($imap,$result,"1.2");
to
imap_fetchbody($imap,$result,"1.1");
1.2 is TEXT/HTML email part, which is used for html email body.
1.1 is TEXT/PLAIN - plain text email body - for plain text messages you'll need to use this one.
I wrote a PHP script for sending email. I am using a CMS which is based on PHP MySQL. I am able to send emails, and people can receive the eamils as well, but the problem is they get HTML tags in their email.
As I am writing the mail by using that CMS and for which i have to write some HTML tags there like </br>, <p> etc. The code for sending mail is below. What should I change so that people can get nice email without HTML tags, but formatted HTML mail. Thanks for helping me out.
$sentemail = mail($email_user, $subject, $message,"From: ABC<xyz#.com>\nX-Mailer: PHP/".phpversion());
you have to set the header to send html email, like that: $headers = 'Content-type: text/html; charset=utf-8' . "\r\n";, and then use the header in mail() function instead the From.. statement. Check documentation for more info http://php.net/manual/en/function.mail.php (example #4)
I am creating a web application for a client that has the ability to send out emails. I am using TinyMCE for my text editor, which works quite nicely. I am using sendmail() with PHP Swiftmailer to handle the actual sending of the email. Swiftmailer works nicely, as well.
The only problem that I am running into is that when I receive the email (in Gmail), the formatting is not rendered correctly. I am receiving the following in the body of my email:
<p>Oh Hello! This is a test <strong>message</strong>. Here is a link: Google.</p>\r\n<p> </p>\r\n<p> </p>\r\n<p> </p>\r\n<p>Line breaks!<br /> <br /> Shift breaks!</p>\r\n<p> </p>\r\n<p>Bye!</p>
The links render, and that's about it. What am I missing?
Thanks!
Check out the second and third code blocks in the documentation for how to set the HTML Content-Type...
http://swiftmailer.org/docs/header-parameterized
You need to send your e-mail in an actual HTML format. You are instead sending the plain text of the HTML. The links render because Google is nice and automatically links what it believes to be a valid URL.
I strongly recommend the Pear mail class. There are convenient functions for setting HTML and plain text message bodies.
What I would do in your case is something like this:
<?php
$headers = "From: Me <me#myemail.com>\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; //States it is HTML Content
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$subject = "This is my subject";
$message = <<<MESS
<p>Oh Hello! This is a test <strong>message</strong>. Here is a link: Google.</p>
<p> </p>
<p> </p>
<p> </p>
<p>Line breaks!<br /> <br /> Shift breaks!</p>
<p> </p>
<p>Bye!</p>
MESS;
if(mail("", $subject, $message, $headers) == True){
echo "Message Sent";
} else {
echo "Message NOT Sent"
}
?>
NOTE: GMAIL is REALLY picky about how it displays emails. Best to create a gmail account and test for yourself how it looks. Hotmail is similar