Solved

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

Posted on 2009-04-07
7
651 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

910 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

21 Experts available now in Live!

Get 1:1 Help Now