Solved

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

Posted on 2009-04-07
7
662 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

710 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