Solved

Using mail fuction, getting occasional exclamation marks? base64-encoding the solution? How?

Posted on 2009-04-07
7
648 Views
Last Modified: 2012-06-21
I've got a script sending email like this:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To:' . $mem_email . "\r\n";
$headers .= 'From: "Chris, Mysite" <admin@mysite.com>' . "\r\n";
mail("$mem_email","Newsletter","
Hi $screen_name,<br /><br />
$news
","$headers");

And I am sending them an html mail.  I find it works best if I don't have any line breaks (other than <br>'s, so I don't get unexpected line spacing.

But when I send it, I get an occasional exclamation mark  ! and then a space afterwords. Then the text resumes ok.

Reading through the php site, under 'bugs', is says this is a sendmail issue and that the solution is  "to use base64-encoding".

How do I use base64-encoding? and will that work with MS outlook ok (I use eudora myself).

Thanks,

Chris
0
Comment
Question by:St_Aug_Beach_Bum
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:EMB01
ID: 24092200
About your code, try removing some unnecessary quotes and such... Also escaped some quotes...
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";

$headers .= "To:" . $mem_email . "\r\n";

$headers .= "From: \"Chris, Mysite\" <admin@mysite.com>" . "\r\n";

mail($mem_email,"Newsletter","Hi $screen_name,<br /><br />$news",$headers);

Open in new window

0
 
LVL 14

Expert Comment

by:EMB01
ID: 24092233
For the record, I don't think you need to base64 as you already have the content type set as HTML.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24093648
Thank you both, but I am still getting the exclamation point thrown into the text.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Accepted Solution

by:
St_Aug_Beach_Bum earned 0 total points
ID: 24093699
Ok, managed to redo my email so I can put some line breaks in it, and it still format ok, and that resolves this problem.
0
 
LVL 14

Expert Comment

by:EMB01
ID: 24096076
I'm sorry, what did you do to resolve the issue? Could you post your code?
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24096593
Hi EMB01,

I ended up changing the text of the email so that it would linclude line breaks, rather than making a code change.  It seems that the issue was related to how long a line could be when sending an email through sendmail.

I tried the suggestion you made here and it did not make a difference, so I ended up tackling this from another direction, ie, finding a way to make an eol ok in the email without messing up the layout.
0
 
LVL 14

Expert Comment

by:EMB01
ID: 24098442
Oh, sorry I couldn't help. I always use a local variable when sending mail, like:
$message = "Hi " . $screen_name . ",<br /><br />" . $news;

Then:
mail ($mem_email, $message, $headers);
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now