Solved

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

Posted on 2009-04-07
7
658 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

840 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