GMail doesn't mark up email html (sending via PHP) - gmail

I am trying to send a html email via mail(), however gmail just displays the email as plain text, no mark up, eg:
mail("blah#blah.com", "<i>Italic Text</i>");
just appears as
<i>Italic Text</i>
Any ideas?

Have you set your email headers?
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
If yes, do any other email clients have the same problem? Or is it just Gmail?

Try it with css, the i tag is deprecated, not sure if that is causing it...
<span style='font-style:italic;'>Italic Text</span>
Or you could try using the em tag:
<em>Italic Text</em>.

Related

how to send email template html page?

Im using PHPMAILER 5.2.7 !
$to=$row['email'];
$at=$row['updated_at'];
$subject = "Your Password has been changed";
$body = "<body background='red' style='bgcolore:red;'><p>Hello < ".$u." > your password has been
changed at ".$at." ! </p>";
$SITEEMAIL='support#test.tn';
$mail = new Mail();
$mail->setFrom($SITEEMAIL);
$mail->addAddress($to);
$mail->subject($subject);
$mail->body($body);
$mail->send();
how can i switch the $body content with a html page (template) ?? tried to directly past the code inside $body but i dosen't work !
I see several strange things in your $body text, try using more simple contents from this sample first. github.com/PHPMailer/PHPMailer#a-simple-example
In any case, you should also call $mail->isHTML(true); before sending.

Send hyperlinks in email body using AWS SES in Node.js

I am using the AWS.SES (simple email service) kit in my Node.js Lambda function.
I can send emails just fine, but if I try to include a simple hyperlink in the email, it displays just plain text instead of a clickable hyperlink.
This is the code I'm using to send the email.
function sendVerificationEmail(userinfo, vKey, after) {
var params = {
Destination: {
ToAddresses: [userinfo.email]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "<html><body>Hey " + userinfo.name + ", <a href='https://s3.amazonaws.com/xxxx/xxxx.html?v=" + vKey + "'>Click here to validate this email address.</a></body></html>"
},
Text: {
Charset: "UTF-8",
Data: "Hey " + userinfo.name + ",\n\nOpen this link in your web browser to validate this email address:\nhttps://s3.amazonaws.com/xxxx/xxxx.html?v=" + vKey
}
},
Subject: { Data: "Scheduler - Verify Your Email Address" }
},
Source: "xxxx#gmail.com"
};
ses.sendEmail(params, function(err, data) {
after(err, data);
});
}
As you can see in the HTML, I have included an <a> tag. However, The link is displayed as unclickable plaintext in the email.
Edit: Gmail's "Show Original" feature displays the following:
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Hey TestName,
Open this link in your web browser to validate this email address:
https://s3.amazonaws.com/xxxx/xxxx.html?v=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
---------------------------------------------------
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<html><body>Hey TestName, <a href='https://s3.amazonaws.com/xxxx/xxxx.html?v=xxxxxxxxxxxxx'>Click here to validate this email address.</a></body></html>
If you observe the raw email contents you will observe that it misses the = sign between in href=<link>. This is because the '=' symbol is used as a line break in the smtp protocol messages(I think).
Anyways, the way to fix this is to add the unicode for the '=' symbol which is U+003D
Try this:-
${text}
The =3D is interpreted as the = symbol and the content encoding is done correctly.

Mail as plain text in Netsuite

Whenever I send a mail from netsuite, It goes in Rich text format (HTML format).
Instead, I want to send it in Plain text format.
I tried many ways but not working. even when I send it with just as a string it goes in HTML format.
E.g.:
var email_subj = "Mail Subject";
var mail_content = "This goes in Body";
nlapiSendEmail(1234,'abc#gmail.com',email_subj,mail_content ,null,null,rec_MailID);
The above mail too goes to the recipient in Rich Text Format.
Is there a way so that it goes in Plain text format.
To know whether the mail is in rich text or plain text you can inspect the body element in browser of the recipient and you will see that there are HTML contents in the mail body.
Or if you are using Outlook: you can right click the body content and there will be option called "View Source" if you click it you will see the HTML code.
Note: in outlook if the mail is in Plain text format then "View Source" option is disabled you cannot click on it, that is what i want.
SuiteScript 1.0 appears to wrap all email bodies in HTML tags.
SuiteScript 2.0 N/email module(ie: email.send() ) will format as plain text unless you include markup in the body. Mock code:
require(['N/email'],
function(email) {
function sendEmail() {
email.send({
author: 1234,
recipients: 'abc#gmail.com',
subject: 'Mail Subject',
body: 'This goes in Body',
});
}
sendEmail();
});

phpmailer for php variables

I am running phpmailer and very much new to it.
Problem definition: Not able to see php variables data in the received email while html content can seen properly.
Below is some of the code:
require 'PHPMailer/class.phpmailer.php';
$mail = new PHPMailer;
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Message';
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong> <?php echo "$name";?> <?php echo "$place";?>
</body>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
Not able to see data defined under php.
Also $name and $place is the dynamic data for the every mail.
Please help.
You cannot put php statements in single quotes. use the following instead:
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>' . $name . ' ' . $place . '
</body>';
You need to put the text between " instead of '.
PHP only replaces variables in double quoted strings.
Also you shouldn't use php code in the strings.
$mail->Body = "
<body>
<div align=\"center\"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong> $name $place
</body>
";
try instead :
$mail->Body = "<body>
<div align=\"center\"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>$name $place
</body>";
You don't have to put php tags in your string since you are already in a php context !
Replace Body with :
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>'.$name.' '.$place.'</body>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message .= "Phone: 0181-4606260.<br>";
$message .="Mobile :09417608422.<br>";
Send_Mail('abc#example.com','Welcome',$message,$headers);
try this...

How to send HTML email in drupal 6 using drupal_mail?

How to send HTML email in drupal 6 using drupal_mail ? How can I change HTML header to show email contents in HTML.
You can to set the header in hook_mail_alter()
<?php
hook_mail_alter(&$message) {
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
}
?>
i know this may be late, but it may help others. Its better to use drupal_mail and then set the headers in hook_mail instead of hook_mail alter. an example would be like:
/*drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE)
Lets say we call drupal_mail from somewhere in our code*/
$params = array(
'subject' => t('Client Requests Quote'),
'body' => t("Body of the email goes here"),
);
drupal_mail("samplemail", "samplemail_html_mail", "admin#mysite.com", language_default(), $params, "admin#mysite.com");
/*We now setup our mail format, etc in hook mail*/
function hook_mail($key, &$message, $params)
{
case 'samplemail_html_mail':
/*
* Emails with this key will be HTML emails,
* we therefore cannot use drupal default headers, but set our own headers
*/
/*
* $vars required even if not used to get $language in there since t takes in: t($string, $args = array(), $langcode = NULL) */
$message['subject'] = t($params['subject'], $var, $language->language);
/* the email body is here, inside the $message array */
$body = "<html><body>
<h2>HTML Email Sample with Drupal</h2>
<hr /><br /><br />
{$params['body']}
</body></html>";
$message['body'][] = $body;
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
break;
}
If this is unclear to you, a complete tutorial on this can be found on My Blog
Hope this helps
JK

Resources