Im trying to embed an image within my message body but it ends up as an attachment
$mailer->Subject = APP_NAME . " - " . $name . " send you and Ad : " . $row['name'];
$mailer->IsHTML(true);
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDimes.png');
//footer
$footer = "Regards<br/><br/>";
$footer .= '<table style="width: 95%">';
$footer .= '<tr>';
$footer .= '<td>';
$footer .= "<strong><span style='font-size: 15px'>NamDimes Team</span></strong><br/>
NamDimes<br/>
Contact Number: " . APP_CONTACT . "<br/>
Email: " . APP_EMAIL . "<br/>
Website: " . APP_WEBSITE . "<br/>";
$footer .= '</td>';
$footer .= '<td style="text-align:right">';
$footer .= '<img src=\"cid:logoimg\" />';
$footer .= '</td>';
$footer .= '</tr>';
$footer .= '</table>';
$mailer->Body = $body . $footer;
$mailer->AltBody="This is text only alternative body.";
$mailer->AddAttachment('../' . $row['image_path'], $row['name'] . ".jpg");
i have set everything else, including the addresses, the mail gets send out, logo image that I want embed in the body gets attached as an attachment, anyone know why?
Don't use $mailer->AddEmbeddedImage, but directly add
<img src="http://.../images/namDiams.png" /> instead.
The mail length should be lighter... And it works.
EDIT
I don't know if it will help you but there is a little mistake here :
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDimes.png');
Should be
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDiames.png');//the last param the second 'a' was missing...
Another topic here
I can confirm that user2189925's answer does work. However, I use the absolute path since the location of the calling script is more likely to change than the location of the image.
e.g.
<img src="C:\folder\images\namDiames.png" />
Faced the same problem, then I decided to replace the following
<img src="img/example.jpg"
with
<img src= "https://mysitename.com/img/example.jpg">
and it worked.
just give path of your image to the mail body eg: (img src="../images/cat.jpeg) it will definately work
Related
I am sending a php email with script inside an html body. When the message is sent the echo output shown in the script below displays to the screen nicely, but it is missing from the email body received.
How can I include this section in my email?
This is the code I am using
// Put your HTML here
$message = file_get_contents('.message_update.html');
echo $message;
$Date = date('d/m/Y');
$count = 0;
$new_dir = str_replace('_', ' ', $dir);
echo "<font color='blue'>";
echo "The folder name at the website message page is: ",
$new_dir."<br /></font>";
$message .= 'The folder name at the website message page is: ",
$new_dir."<br /></font>';
$comparison = array_diff($list2, $list1);
foreach ($comparison as $line) {
echo "Date Update: ", $Date, " : To listen to the ", ++$count, "
message click the picture
here ";
echo '<a href="' . $folder_path, $line . '"><img align="top"
width="100" height="20" text-
align: center;
src="https://nerjabible.com/images/audio_player1.png" /></a>';
echo ", The ", $count, " message name is entitled: ", $line. "
<br />";
}
$message = file_get_contents('.message_update1.html');
echo $message;
// Mail it`
`
The output of the first html file .message_update.html is included in top of the email received.
Then the variables from the script are missing
The output of the second .message_update1.html is included at the bottom of the email received.
How can I wrap this section
$new_dir = str_replace('_', ' ', $dir);
echo "<font color='blue'>";
echo "The folder name at the website message page is: ",
$new_dir."<br /></font>";
$message .= 'The folder name at the website message page is: ",
$new_dir."<br /></font>';
$comparison = array_diff($list2, $list1);
foreach ($comparison as $line) {
echo "Date Update: ", $Date, " : To listen to the ", ++$count, "
message click the picture
here ";
echo '<a href="' . $folder_path, $line . '"><img align="top"
width="100" height="20" text-
align: center;
src="https://nerjabible.com/images/audio_player1.png" /></a>';
echo ", The ", $count, " message name is entitled: ", $line. "
<br />";
}
and include it in the $message variable?
I have a simple echo statement that's supposed to display a link on the web page, but all it's doing is showing exactly "<a href=website.com>Link</a>" (without the quotes). To me, this should work with no problem. I thought maybe it's because the HTML for the website is in one file while the PHP is in another file.
foreach ($output as $output)
{
echo 'DATE: ' . $output['date'] . "\n";
echo 'TO: ' . $output['to'] . "\n";
echo 'FROM: ' . $output['from'] . "\n";
echo 'SUBJECT: ' . $output['subject'] . "\n";
echo "<a href=website.com>Link</a>\n\n";
}
Your loop isn't a valid one, you have $output as $output.
I also suggest printing $output before looping through it, to see if it even contains what you think it should.
In your 'a' tag, the actual URL needs to be in quotes
<a href='http://www.website.com'>
Ho to make $price to be printed bold on the following
I have tried the <b> and <string> but they will not let the price displayed correctly
$message .= ' - ' . $price;
I am echoing the following
$attachment = array(
'access_token' => $this->config->get('fb_auto_post_access_token'),
'message' => $message,
and
$fb_request = new FacebookRequest($fb_session, 'POST', '/' . $this->config->get('fb_auto_post_page_id') . '/feed', $attachment);
Using <b> and <Strong> will not work as it will show <b>$price</b> or <strong>$price</strong>
Thank you
You can add the <b> tag to the beginning and end like so:
$message .= ' - <b>' . $price . '</b>';
https://www.w3schools.com/html/html_formatting.asp
Making an element bold cannot be done with pure PHP. You would need either to echo a <b> tag (echo "<b>" . $bold . "</b>";), or more preferably, use CSS.
First, create a CSS style that applies the bold font-weight:
.bold {
font-weight: bold;
}
Then you can either echo this styling when output your PHP variable:
echo "<div class='bold'>$bold</div>";
Or even more preferably, craft your HTML around the variable:
<div class="bold"><?php echo $bold; ?></div>
Hope this helps! :)
I use jQuery to serve a link where users can download a .txt file. jQuery just gets the content of a textarea and sets it as the href attribute. This is necessary because the content of the textarea is set with the response of an ajax call.
The download of the file works like this:
$(document).on('click', '#download', function(){
$(this).attr('href','data:text/plain;charset=utf-8,' + encodeURIComponent( $('#kundendaten').val() ) );
});
One part of the Ajax call response is the textarea:
$kundendaten = '<textarea id="kundendaten">';
$kundendaten .= 'Name: '. $_POST['nachname'] .' '. $_POST['vorname'] . PHP_EOL;
$kundendaten .= 'Email: '. $_POST['email'] . PHP_EOL;
$kundendaten .= '</textarea>';
On Mac OS I get a .txt file with line breaks and everything is fine. On Windows though the line breaks are missing in the .txt file. I also tried \n instead of PHP_EOL but there was no difference.
Any idea how I can solve this?
PHP_EOL only works to the system it is running on, so if your website is hosted on a linux box, it will do the EOL to a linux standard.
The following would be your best bet.
$kundendaten = '<textarea id="kundendaten">' . "\r\n";
$kundendaten .= 'Name: '. $_POST['nachname'] .' '. $_POST['vorname'] . "\r\n";
$kundendaten .= 'Email: '. $_POST['email'] . "\r\n";
$kundendaten .= '</textarea>' . "\r\n";
Also if you are using this a lot throughout a file I would create a constant referencing "\r\n" and use that. (If I remember the syntax correctly, as follows;
DEFINE("_EOL", "\r\n");
1st, I know mysql_ is outdated and I should use mysqli (unfortunatly, I inherited this system and its way too much work to change it over at the present time)
The problem I have is when I execute the code, I am getting random blank emails. This system loops through a list of stores in a database and lists the information in a table for the store managers. It doesnt really matter what information is being presented. Does anyone see anything right off hand that micht cause this problem?
while($store = mysql_fetch_array($result_store)){
#Updates the Report Date for each store in the Loop
$report_date = "UPDATE ActiveStores SET Report_Date = '$Today' WHERE StoreNumber = $store[StoreNumber]";
if (!mysql_query($report_date, $con)){
die('Error: ' . mysql_error());
}
#Selects data from ActiveStores for the current store in the loop
$result2 = mysql_query("SELECT * FROM ActiveStores WHERE StoreNumber = '$store[StoreNumber]' ORDER BY StoreNumber");
#Loops through the currently selected store and Creates an Array of the data
while ($row = mysql_fetch_array($result2)) {
#Sets Store Variable
$Store = $row['StoreNumber'];
echo '<table width="1110"><table width="1102"><tr>';
# To Email Address
#$emailaddress = '******#*****.com';
# Message Subject
$emailsubject= 'Testing Report - Store: ' . $Store;
#Turn on Output buffer for email
ob_start();
#Heading for Report
echo '<h2 class="blktext">Walgreens Weekly Report - ' . $Today . '<br /></h2>';
echo '<h2>Insurance Orders:</h2>';
#Cancelled Orders for the store this week
$result_cash_canceled = mysql_query("SELECT * FROM Orders WHERE StoreNumber = '$Store' AND Cancel = 'checked' AND Order_Type = 'Cash' AND Cancel_Date > '$Sevendaysback'");
$tot_ord_ins_prt = mysql_num_rows($result_cash_canceled);
if ($tot_ord_ins_prt !== 0){
echo '<h4 class="blktext">Cancelled Orders for the store this week</h4><span class="blktext">';
echo '<p><i>Fitter Action: Fitter to contact client to notify of cancelled order, if not initialed by client.</i></p>';
echo "<table border='4' class='rpttbl' frame='hsides' rules='rows' width='1400'>";
echo '<tr><th>Store #</th><th>Order #</th><th>Customer</th><th>Phone #</th><th>Cancel Date</th width="150"><th>Reason for Cancellation</th><th width = "150">Patient Notified<th></tr>';
while($row_cash_canceled = mysql_fetch_array($result_cash_canceled)){
echo "<tr>";
echo "<td align='center'>" . $row_cash_canceled['StoreNumber'] . "</td>";
echo "<td align='center'>" . $row_cash_canceled['Order_ID'] . "</td>";
echo "<td align='center'>" . $row_cash_canceled['Cust_First_Name'] . " " . $row_bo['Cust_Last_Name'] . "</td>";
echo "<td align='center'>" . $row_cash_canceled['Cust_Phone'] . "</td>";
echo "<td align='center'>" . $row_cash_canceled['Cancel_Date'] . "</td>";
echo "<td align='center'> </td>";
echo "<td align='left'>( ) Called: Patient Cancelled notified<br />( ) Called: LVM for Patient</td>";
echo "</tr>";
}
echo "</table>";
echo "Total: " . $tot_ord_ins_prt;
echo'</span>';
}
#Message at bottom of email
echo '<br /><br /><br /><br /><p>Thank you for your prompt attention to this report.</p>';
echo '<p>If this report is blank in all the above sections, this means, at this point, we are not showing any active orders within our system.<br />';
echo 'If you feel this is in error, please contact our Customer Care team at: <strong>(***) ***-8125</strong></p>';
echo '<p>Please update this form with the appropriate action taken by patient, and fax back to: (866) 8**-**** OR email to: ******#*****.com</p>';
echo '<p>Fitter Name: ________________________________________</p>';
echo '<p>Comments: _______________________________________________________________<br />';
echo '_________________________________________________________________________</p>';
echo '<p>The information contained in this email, together with any attachments, is intended only for the use of the individual or entity<br /> to which it is addressed. It may contain information that is confidential and prohibited from disclosure. If you are not the intended <br />';
echo 'recipient, you are hereby notified that any dissemination, or copying, of this message or any attachment is strictly prohibited.</br> If you have received this message<br /> in error, please notify the original sender immediately by phone or by return email, </br>';
echo 'and delete this email, along with any attachments. <br />Receipt by anyone other than the intended recipient is not</br> a waiver of any privileged information. </p>';
}
$body=ob_get_contents();
ob_end_clean();
#$body = "** It is Imperative that you respond to this email. When you receive this please print it out, sign your name and store number and fax the form to ***-***-1161**<br /><br /><br />";
#$body .= "Name: <br /><br />Store #:";
$headers = 'From: Visual Footcare Technologies *****#****.com'.$eol;
$headers .= 'Reply-To: Visual Footcare Technologies *****#*****.com'.$eol;
$headers .= 'Return-Path: Visual Footcare Technologies <mcooper#visualfootcare.com>'.$eol; // these two to set reply address
#$headers .= 'Cc: ******#*****.com'.$eol;
$headers .= "Message-ID:<".$now." TheSystem#".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
$mime_boundary=md5(time());
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";
$msg .= "Content-Type: multipart/alternative".$eol;
$msg .= "--".$mime_boundary.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= $body.$eol.$eol;
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection.
then a standard mail(......) code to send the email and then ending the loop.
hope that makes sense.
try changing this
if ($tot_ord_ins_prt !== 0)
to
if ($tot_ord_ins_prt !== false)
MIME header blocks must be terminated by a blank line, even when used in a multi-part section. I don't know what you mean by "random", but I suspect that "blank emails" could be the result of your message body being interpreted as invalid MIME headers.
Insert a blank line between the last MIME header and your message body:
$msg .= $eol.$body.$eol.$eol;
If this doesn't help, you should probably show that "standard" mail line you mentioned. Since it's the one that actually sends the email, I'm surprised you didn't include it. You included a whole lot of other code. It would be good to see what you do with the two strings, $headers and $msg.