1

There is a PHP mail form. When I am trying to send the displayed HTML page in textarea to my mail, I am received mail without images and styles that I saw in the textarea.

If anyone could then tell me that how can I send this email to multiple recipients with comma separator in receiver text box I would appreciate it.

PHP mail function is used.

<?php
} else {  // the user has submitted the form
// Check if the "from" input field is filled out
if (isset($_POST["sender"])) {
// Check if "from" email address is valid
$mailcheck = spamcheck($_POST["receiver"]);
if ($mailcheck==FALSE) {
  echo "Invalid input\n <button onclick=\"goBack()\">Go Back</button>";
} else {
  $headers = 'MIME-Version: 1.0' . "\r\n";
  $headers.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
  $headers.= "From: " . strip_tags($_POST['sender']) . "\r\n";
  $headers.= "Reply-To: ". strip_tags($_POST['sender']) . "\r\n";
  $receiver = $_POST["receiver"]; 
  $sender = $_POST["sender"];// sender
  $subject = $_POST["subject"];
  $message = $_POST["message"];

  // message lines should not exceed 70 characters (PHP rule), so wrap it
  //$message = wordwrap($message, 1000);
  // send mail
  mail("$receiver",$subject,$message,$headers);
  echo "Mail(s) has been sent successfully!\n <button onclick=\"goBack()\">Go Back</button>";
  }
 }
}
?>
Laurel
  • 5,965
  • 14
  • 31
  • 57
harry_beginner
  • 64
  • 1
  • 1
  • 11
  • how about instead, you share with us a more specific problem, explain what you have tried, and perhaps post code here or set up a fiddle? – Phlume Jun 16 '14 at 14:31
  • There was a similar question to this an hour or so ago. If it was you and you deleted your question, then you need to use a full `http://` call for the images and not one that's a path to on your server. – Funk Forty Niner Jun 16 '14 at 14:32
  • Each email client has its own accepted css rules, check **[this link](http://www.campaignmonitor.com/css/)**. – kosmos Jun 16 '14 at 14:34
  • I see `\"\"`. Quote string with slashes – Nick Jun 16 '14 at 14:36
  • @fred -ii-. This is my first question related to this problem. – harry_beginner Jun 16 '14 at 14:57
  • @harry_beginner Ok. That's why I said "if it was you". I couldn't remember who posted it, but it was a similar problem wanting to show images in sent Email. – Funk Forty Niner Jun 16 '14 at 14:58
  • @Phlume look at the another post of mine. here you will get the code, http://stackoverflow.com/questions/24241635/sending-php-html-mail – harry_beginner Jun 16 '14 at 14:58
  • In regards to styles; that I don't quite understand. If you're wanting to use styles in Email, 95% of the time that doesn't work and you need to use inline styling. Gmail and many others discard ` – Funk Forty Niner Jun 16 '14 at 15:00
  • Plus, looking at your HTML source, you have 2x `` tags, with styles outside the ``. You'll need to completely rebuild that. – Funk Forty Niner Jun 16 '14 at 15:05

6 Answers6

4

Here's your problem:

src="images/widget-logo4.png"

You need to have the ENTIRE URL in there. The relative URL won't work in an email.

durbnpoisn
  • 4,666
  • 2
  • 16
  • 30
  • I see `\"\"`. – Nick Jun 16 '14 at 14:38
  • If that's the case, then you have some sort of server-side script that is adding in that path for you. But that only works when it's on the server. Once in an email, it's standing on it's own. – durbnpoisn Jun 16 '14 at 14:42
  • Is that what you see when the page is rendered, and viewing the source? Or is that what you see when you look at the raw source? Because the link you provided is a PHP page. That cannot be sent in an email. It's needs to be the rendered raw HTML. – durbnpoisn Jun 16 '14 at 14:48
  • I don't provide any link. I see `\&Quot;` in my Gmail for images and styles. I think it's a problem. – Nick Jun 16 '14 at 14:53
  • I have used the full url. – harry_beginner Jun 16 '14 at 14:54
  • The OP's asking about the email, not about his web page. – Nick Jun 16 '14 at 14:55
  • we have used the same html email template in www.watchbotcamera.com. It was working in that site. try any newsletter on that site. – harry_beginner Jun 16 '14 at 15:18
  • Another thought is that that server won't allow remote linking of images. Have you tried putting the images somewhere else? (Like PhotoBucket, or something) – durbnpoisn Jun 16 '14 at 15:20
  • @durbnpoisn The first template's images are locally saved. It is not displaying images and other two template's images are from remote location. It is also not displaying the images. What can I do now. – harry_beginner Jun 16 '14 at 15:58
  • Show us the RENDERED HTML that is generated by your template. Add that code to your answer. That may provide better clues. – durbnpoisn Jun 16 '14 at 16:04
2

I see in my email client - <img src="\&quot;http://www.watchbotcamera.com/newsletter/watchbot/wb-button-upgrade.‌​png\&quot;" alt="\&quot;\&quot;">. Same for styles.

At first check the parameters starting with "magic_quotes_" in your "php.ini".

From - http://www.tinymce.com/forum/viewtopic.php?id=10064

Try use - get_magic_quotes_gpc

Nick
  • 1,530
  • 2
  • 15
  • 22
1

I found the problem what it was. It was not display images and url links only because of magic quotes. I just added some php code to turn off the magic code at run time.

Now, I can see images and links in my email.

Here is the code:

 <?php
 if (get_magic_quotes_gpc()) {
 $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
 while (list($key, $val) = each($process)) {
    foreach ($val as $k => $v) {
        unset($process[$key][$k]);
        if (is_array($v)) {
            $process[$key][stripslashes($k)] = $v;
            $process[] = &$process[$key][stripslashes($k)];
        } else {
            $process[$key][stripslashes($k)] = stripslashes($v);
        }
    }
  }
  unset($process);
 }
 ?>

So, Normal php mail is also working. Thanks guys for the support

harry_beginner
  • 64
  • 1
  • 1
  • 11
0

Which function and headers do you use to send the email?

And is the tinymce set to absolute paths or relative paths?

The last question also depends how you try to send the email.

stefferd
  • 56
  • 4
0

You either have to use absolute URLs

<img src="http://www.mydomain.tld/images/widget-logo4.png" />

instead of a relative path

<img src="images/widget-logo4.png" />

Or you can embedd your image as base64 encoded content, see this answer on SO how to do that.

Community
  • 1
  • 1
Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
  • The question is about an email, not about the web page with Tinymce. – Nick Jun 16 '14 at 14:57
  • Both ways I described refer to email usage. I don't understand your concerns. – Gottlieb Notschnabel Jun 16 '14 at 20:30
  • "I am received mail without images and styles that I saw in the textarea.". The op asked about result, not about this page - http://electrobox.co.uk/partnersnetwork/affiliates/emailmarketing/emailmarketing.php – Nick Jun 16 '14 at 20:44
0

Instead of using php mail, I've changed to phpmailer. Using that I can easily send html page in the mail.

$body = file_get_contents('template-1.html');            
$mail->MsgHTML($body);
harry_beginner
  • 64
  • 1
  • 1
  • 11