close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Add custom email headers

Thread begun 6/27/2022 5:46 am by mlowe4 | Last modified 6/29/2022 8:34 pm by Ray Borduin | 469 views | 8 replies |

mlowe4

Add custom email headers

Hi is there any way to add custom email headers, my hosting provider has changed it’s email service and now the message returns in plain text rather than a styled HTML email, I need to add MIME format and content type headers for the email to display HTML, it’s returning a Content-Type: text/plain; charset=us-ascii
at the moment and I need to add $headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Thanks

Sign in to reply to this post

Ray BorduinWebAssist

I believe those headers should be set properly by default if you are using the latest version of the extension. If you provide a url and FTP access then I could test and see what is going on.

Sign in to reply to this post
Did this help? Tips are appreciated...

mlowe4

I’ve provided details privately

Sign in to reply to this post

Ray BorduinWebAssist

The headers currently are:

Date: Tue, 28 Jun 2022 19:48:02 +0000
From: support@nexuscst.com
Message-ID: <bMqtcX8e6zZFHMTiU30zVCoUen89ztQyi9jHzEFamQ@sentrydemo.nexuscst.com>
X-Mailer: PHPMailer 6.1.7 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_bMqtcX8e6zZFHMTiU30zVCoUen89ztQyi9jHzEFamQ"
Content-Transfer-Encoding: 8bit



The MIME-Version is already there. The Content-Type is set to: multipart/alternative

This is the necessary type to allow both html and plain text versions to be sent. The code automatically produces plain text versions of the code for html clients that don't support viewing html, but it should deliver the html version for any email client that supports it.

Email clients that support html will get the header:
Content-Type: text/html; charset=us-ascii

If you want to change the charset, you can do that in the email settings UI from our extension. I've added it for you and you can see the result on line 53:
$Email->CharSet = "ISO-8859-1";

That should create the correct headers for you.

Sign in to reply to this post
Did this help? Tips are appreciated...

mlowe4

Hi thanks for that but it's still sending in plain text, I've attached a screenshot of what I get

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

Is this an issue with the email or the client reading it? If you sent the email to me from the server would I see the same problem? What email client are they using?

Sign in to reply to this post
Did this help? Tips are appreciated...

mlowe4

I’m pretty sure it’s a problem with the email, I use yahoo web mail and tested it using gmail too and it’s the same if you change the email to yours you would get the same email

The script they provided me works, it’s just universal email doesn’t this is the script they gave me

<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "support@nexuscst.com";
$to = "psychic_lowe@yahoo.co.uk";
$subject = "Checking PHP mail";

// 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";

// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();

// Compose a simple HTML email message
$message = '<html><body>';
$message .= '<h1 style="color:#f40;">PHP mail test!</h1>';
$message .= '<p style="color:#080;font-size:18px;">Just a HTML test</p>';
$message .= '</body></html>';

if(mail($to,$subject,$message, $headers)) {
echo "Message was sent.";
} else {
echo "Message was not sent.";
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

I was able to reproduce the issue sending to my email address and I discovered you were using an older version of the phpMailer code. I updated to the latest version from Data Bridge and that appears to have fixed the problem.

Sign in to reply to this post
Did this help? Tips are appreciated...

mlowe4

Thanks for your help it works now tipped $10
Thanks again for resolving the issue

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...