Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:05:27+00:00 2026-06-05T20:05:27+00:00

I am having some serious problem with some e-mail issue. in short: loading a

  • 0

I am having some serious problem with some e-mail issue.

in short:

  1. loading a html template file fopen
  2. replacing some values, marked like this %password with real values str_replace
  3. sending mail via the following function, where $content is the loaded html template file:

public function send($receiver, $subject, $content){

    $header = "From:".sender. "\n";
    $header .= "MIME-Version:1.0" . "\n";
    $header .= "Content-type:text/html;charset=utf-8" . "\n";

    $mailText = $content;
    mail($receiver, $subject, stripslashes(iconv('utf-8', 'iso-8859-1', $mailText)) , $header);

}

the server is debian with postfix.

The Mail template starts with

<html> <body style="background-color: #fff;"> <table border="0"...

The thing is, and I cannot reproduce it, that in some cases I can find several spaces in the mail, which I didn’t put there. Most problematical are those in the user and password string.

Evering else seems correct! The encoding is ok, the html is accepted, all mails can be delivered …

password generation:

public static function create_password($length = 12) {
        $characters = array("a", "b", "c", "d", "e", "f", "g", "h", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_");
        $password = "";
        for($i=0; $i<$length; $i++) {
            $index = rand(1, count($characters)) -1;
            $password .= $characters[$index];
        }
        $password = str_replace("__","_", $password);
        return $password;
    }

Any Ideas, where to start my search?

Is it the template, str_replace, the postifix, the client, … ?

Thanks so far

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:05:28+00:00Added an answer on June 5, 2026 at 8:05 pm

    I would start by saving the HTML into a separate file and open that with a browser.

    If you see spaces, it’s the HTML.

    If it looks fine, the mail gets mangled.

    Mangling

    This is often caused because your lines are simply too long and mail servers do funky stuff with lines longer than 80 columns (ancient standards).

    To prevent mangling I would suggest the following:

    1. Add header Content-Transfer-Encoding: base64.

    2. Apply chunk_split(base64_encode(...)) over the whole e-mail content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some serious issue while loading Staging Table from Data Store. My
I am having some serious trouble with getView in a ListView. The problem is,
I am having some serious problem here. When do we need a class exactly?
I've some pocket pc app and i'm having a serious problem with it described
For some reason I'm having some serious difficulty wrapping my mind around this problem.
We are having some serious issues migrating Visual FoxPro to SQL Sever.. I don't
I am having some serious issues trying to tweak my layout in a table.
I'm having some serious trouble understanding the view matrix in XNA. I've come pretty
I am having some serious trouble creating a WPF TreeView with an Object databinding.
I'm having some serious issues with the jQuery UI icons and I can't see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.