9 replies
Recently I got a working script to rss processing and sending email.But unfortunately it is sending the plain text version , which makes the email to read very difficult.Below is the screen shot and any one help me to trace this problem..

#email #php #sending
  • Profile picture of the author michael_gourlay
    You need to make sure you are sending the right headers to the php mail() function call. Here's an example:

    $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "CC: example@example.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    {{ DiscussionBoard.errors[6535231].message }}
  • Profile picture of the author vrtechnologies
    This will help you

    <?php
    $to = 'yourmail';
    $from = 'Fromemail';
    $subject = 'the subject';
    $message = 'Test Messgae';
    $headers = 'From:' .$from. "\r\n" .
    'Reply-To: replymail' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);
    ?>
    {{ DiscussionBoard.errors[6566368].message }}
  • Profile picture of the author jaasmit
    This is a great solution to code in php such that it will send email to various persons and also will have the ability to send email to more than 100 people.
    {{ DiscussionBoard.errors[6612675].message }}
  • Profile picture of the author michael clay
    hi it is a good solution to send emails via php and nicely work
    {{ DiscussionBoard.errors[6615292].message }}
  • Profile picture of the author narcispap
    Hello!
    Another thing to keep in mind:
    On most dedicated or VPN server, there isn't installed the required email seding function which PHP relies on to complete the actual email transfer.

    For ubuntu, install using
    apt-get install sendmail

    On CentOS use
    yum install sendmail

    Mos of the times this is why PHP fails to deliver a message.
    {{ DiscussionBoard.errors[6618556].message }}
    • Profile picture of the author lmutafov
      I'm not sure you've solved your issue already, but in case you haven't..

      Assuming you are on shared hosting, which you probably are, you have to combine the two replies, from michael_gourlay and vrtechnologies. But I'm going to share my code anyway, because it's easier for me.

      The headers are responsible for your problem - if it will either be sent in plain text, or HTML formatted. The default is plain text (obviously).

      So, here's the code:
      -------------------
      // Main variables
      $from = 'Optional Name <your@mail.com>';
      $to = 'Optional Name <send@to.com>';
      $subject = 'Message subject';
      $message = 'Your message.';

      // Make the headers
      $headers = "MIME-Version: 1.0\r\n" .
      "Content-type: text/html; charset=utf-8\r\n"
      "From: " . $from . "\r\n" .
      "Reply-To: " . $from . "\r\n" .
      "X-Mailer: PHP/" . phpversion();

      // Send the mail
      $success = @mail($to, $subject, $message, $headers);
      -------------------

      The $success variable will be true if the mail is sent, and false if it has failed. Use that for validation purposes, if you need to.

      In case you want the subject to be in different language than English, I can give you the solution with that too. But if you don't to - the code above is good enough.

      Also, you can go a step further and wrap that code in a function. I extracted the code you see from mine - MailHtml($from, $to, $subject, $message);
      It's the right way to go, if you need to send HTML mails in multiple places in your code.

      I hope this has been helpful.
      {{ DiscussionBoard.errors[6619061].message }}
      • Profile picture of the author cutegirl36
        You need read in php manual <-- All in one.









        -----
        friv
        Signature

        Source: friv

        {{ DiscussionBoard.errors[6629065].message }}
  • Profile picture of the author adrenalinfeed
    Wordpress also have some nice emailing features built-in (if you use wordpress). Check out Function Reference/wp mail « WordPress Codex
    {{ DiscussionBoard.errors[6629939].message }}
    • Profile picture of the author annife polak
      Hi, do you have any experience with coding UTF-8 in subject of the email?

      I've tried many time to show chars like ěÅ¡čřžýáíé, but with no good responce

      Thanks
      {{ DiscussionBoard.errors[6635972].message }}

Trending Topics