Reputation: 64
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>";
}
}
}
?>
Upvotes: 1
Views: 13039
Reputation: 64
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
Upvotes: 1
Reputation: 64
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);
Upvotes: 0
Reputation: 1570
I see in my email client - <img src="\"http://www.watchbotcamera.com/newsletter/watchbot/wb-button-upgrade.png\"" alt="\"\"">
. 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
Upvotes: 2
Reputation: 9552
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.
Upvotes: 0
Reputation: 56
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.
Upvotes: 0
Reputation: 4669
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.
Upvotes: 4