$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "test.php#gmail.com";
$mail->Password = "****";
$mail->setFrom('test#email.com','duy tran');
in received email it shows From: duytran gmail .
it means that it use username as From email.must be From: duytran gmail
Any suggest to fix it ?
You can Refer this code it will help you to use php Mailer class
$mail = new PHPMailer();
$to = "admin#gmail.com";
$mail->IsSendmail(); // telling the class to use SendMail transport
$from = $email;
$headers = "From: <".$from.">\n";
$headers .= "X-Sender: yourname<".$from.">\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: ".$from."\n"; // Return path for errors
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
$mailBody = "";
$mailBody = '<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td valign="top" width="90px;">
<span>Listing For:</span>
</td>
<td valign="top">
'.$businessDetail['companyName'].'
</td>
</tr>
<tr>
<td valign="top" width="90px;">
<span>Listing Url:</span>
</td>
<td valign="top">
</td>
</tr>
<tr>
<td valign="top" width="90px;">
<span>Email:</span>
</td>
<td valign="top">
'.$email.'
</td>
</tr>
<tr>
<td valign="top" width="90px;">
<span>userName:</span>
</td>
<td valign="top">
'.$businessDetail['userName'].'
</td>
</tr>
<tr>
<td valign="top" width="90px;">
<span>Comment:</span>
</td>
<td valign="top">
'.$commentDesc.'
</td>
</tr>
</table>';
$mail->Subject = $mailSub;
$mail->IsHTML(true);
$mail->MsgHTML($mailBody);
$mail->SetFrom($email,'yourname');
$mail->AddAddress($to);
if($mail->Send()){
$variables['success'] = "posted successfully and email is send.";
}
Related
[enter image description here][1]I am sending a password recovery mail and i used table html tag for cross-platform support. I put the image in the right position in the mail, which is at the top. But the image was placed below the message as attachment without the css style and not within the table row on top of the page. How do ensure the image is placed at the top not bottoom inside gmail?
I used phpmailer AddEmbeddedImage('../../img/kokwo_full.png', '{$site}', '{$site}.png').
$subject="Password Reset Request - {$site}";
$message="
<table width='100%' style=' background:#f2f2f2; margin:0px; margin:0px 0px; color:#fff; font-family: Arial, sans-serif; font-size:12px; font-weight:bold; padding:0% 2%'>
<tr style='background:#fff;'>
<td colspan='2'><img src='{$http}://{$website}/img/kokwo.png' style='background:#4885ed; height:60px'/></td>
</tr>
<tr style='height:140px;'>
<td colspan='2' style='color:#000;text-align:center; font-size:32px'> </td>
</tr>
<tr>
<td colspan='2' style='color:#000;text-align:center; font-size:32px; border-bottom:1px solid #000'> Hi {$user_name},</td>
</tr>
<tr style=' height:90px;'>
<td colspan='2' style='color:#000; font-size:18px'>Instant password change
<p style='color:#000; font-size:10px'>{$email}</p></td>
</tr>
<tr style=' color:#808080; '>
<td colspan='2' style='color:#808080; font-size:18px'>Click on this button</td>
</tr>
<tr style=' height:30px;'>
<td colspan='2' style='text-align:center;'>
<form action='{$http}://{$website}reset' method='post' class='regi' enctype='multipart/form-data'>
<input type='text' name='user_id' value='{$user_id}' style='display:none;'/>
<button type='submit' style='background:#00A9E0; color:#fff; padding: 10px;
font-size: 18px;
border: none;
border-radius: 5px;
width: 89%;
margin:25px 3%' name='reg_user' >Change your password on ".ucwords($site)." </button>
</form>
</td>
</tr>
<tr style='height:80px;'>
<td colspan='2'> </td>
</tr>
<tr style='height:30px; background:#4885ed;'>
<td colspan='2'></td>
</tr>
</table>
";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
if (isset($_POST['reset-password'])) {
require '../../PHPMailer/src/Exception.php';
require '../../PHPMailer/src/PHPMailer.php';
require '../../PHPMailer/src/SMTP.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.{$site}.com"; // "ssl://smtp.gmail.com" didn't worked
$mail->SMTPAuth = true;
$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->Username = $my_mail;
$mail->Password = $my_password;
$mail->From = $my_mail;
$mail->FromName = $fromname;
$mail->addAddress($email, $user_name);
$mail->addReplyTo($my_mail, $fromname);
$mail->Sender=$my_mail;
//Provide file path and name of the attachments
$mail->Subject = $subject;
$mail->AddEmbeddedImage('../../img/kokwo_full.png', '{$site}', '{$site}.png');
$mail->Body = $message;
$mail->AltBody=$subject;
$mail->Send();
if (!$mail) {
array_push($errors, "<div class='error'><p>
Could not be delivered to {$email},please try again
.</p></div>");
} else {
array_push($errors, "<div class='success'><p>
Check inbox or spam folder at {$email}.</p></div>");
}
}
```what i want to achieve[What I got][2]
[1]: https://kokwo.com/img/stack/real.jpg
[2]: https://kokwo.com/img/stack/fake.jpg
You have attached it as an embedded image, but you're not actually using it in your template.
The second parameter to addEmbeddedImage is cid, a content identifier. A separate problem is that you have single-quoted your strings, so no variable interpolation will be done - that's probably not what you intended.
So if your call looks like this:
$mail->addEmbeddedImage('../../img/kokwo_full.png', 'kokwo', 'kokwo.png').
you would use that image in your HTML like this:
<img src="cid:kokwo" style="background:#4885ed; height:60px">
Note that the string after the cid: part of the URL exactly matches the cid value you passed to addEmbeddedImage.
I had search reference and the reference say to try like this :
<?php
...
class ReportExport implements ShouldAutoSize, FromView, WithColumnFormatting, WithEvents
{
...
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
...
$event->sheet->getDelegate()->getRowDimension(37)->setRowHeight(-1);
$event->sheet->getDelegate()->getStyle('R37:Z37')->getAlignment()->setWrapText(true);
},
];
}
}
I try like that, but the result like this :
Should the height of row automatic added based content/text. But it does not added
How can I solve this problem?
Update :
Seems this script : $event->sheet->getDelegate()->getRowDimension(37)->setRowHeight(-1); is not working in the table
I tried the script outside the table, it worked. So the script only work outside table tag
My table like this :
<table>
....
#php ($group = 'A')
#php ($number = 0)
#foreach($values as $item)
#if($number==0 || $group!=$item['group'])
<tr>
<td colspan="9">Kelompok {{$item['group']}}</td>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="3"></td>
<td colspan="9"></td>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="3"></td>
<td colspan="9"></td>
</tr>
#php ($number = 0)
#endif
<tr>
<td style="text-align:center;" colspan="2">{{++$number}}</td>
<td colspan="7">{{$item['lesson_name']}}</td>
<td style="text-align:center;" colspan="2">{{$item['kb_pengetahuan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['nilai_pengetahuan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['predikat_pengetahuan']}}</td>
<td colspan="9">{{$item['deskripsi_pengetahuan']}}</td>
<td style="text-align:center;" colspan="2">{{$item['kb_keterampilan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['nilai_keterampilan']}}</td>
<td style="text-align:center;" colspan="3">{{$item['predikat_keterampilan']}}</td>
<td colspan="9">{{$item['deskripsi_keterampilan']}}</td>
</tr>
#php ($group = $item['group'])
#endforeach
</table>
Please help me. I need support for PhpSpreadsheet functionality
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
...
$event->sheet->getDelegate()
->getStyle('R37:Z37')
->applyFromArray([ 'alignment' => ['wrapText' => true]])
},
];
}
I'm in a bit of a quinch here:
its an ASP site which is really messy that I am trying to get data from:
I'm trying to use a for loop to get an href and the text of all the rows of the 4th table that is on the site, so I first did:
table = soup.findAll('table')[3]
Then from this table I need to get all text inside the <tr> tags and the href's of the <a> inside.
i tried something like this:
for product in table.findAll('tbody'):
product_title = product.find('tr').text
product_link = product.find('a')['href']
print (product_title, product_link)
But I get nothing in return
The table Im working on:
<tr bgcolor="#EFEFEF">
<td>
<a href="free.asp?detail=hide&c_id=4342141">
<img align="absmiddle" border="0" hspace="0" src="pic/bullet.gif" vspace="0"/>
</a>
</td>
<td>
4342141
</td>
<td width="10">
</td>
<td>
25.07.2018 09:00
</td>
<td width="10">
</td>
<td>
Ankara
</td>
<td width="10">
-
</td>
<td>
Konya
</td>
<td colspan="2">
</td>
</tr>
<tr bgcolor="#EFEFEF" height="3">
<td colspan="10">
</td>
</tr>
<tr bgcolor="#FFFFFF" height="1">
<td colspan="10">
</td>
</tr>
<tr bgcolor="#DDDDDD" height="6">
<td colspan="10">
</td>
</tr>
<tr bgcolor="#FFFFFF" height="1">
<td colspan="10">
</td>
</tr>
<tr bgcolor="#DEE3E7" height="3">
<td colspan="10">
</td>
</tr>
<tr bgcolor="#DEE3E7">
<td>
<a href="free.asp?detail=hide&c_id=4134123">
<img align="absmiddle" border="0" hspace="0" src="pic/bullet.gif" vspace="0"/>
</a>
</td>
<td>
4134123
</td>
<td width="10">
</td>
<td>
26.07.2018 09:00
</td>
<td width="10">
</td>
<td>
Van
</td>
<td width="10">
-
</td>
<td>
Istanbul
</td>
<td colspan="2">
</td>
</tr>
Instead of extracting text from tbody from table, you can directly get all tr tags.
Based on your snippet you can refer to this code snippet for data extraction from table.
soup = BeautifulSoup(text, 'html.parser')
all_products = []
for tr in soup.find_all('tr'):
text = tr.get_text(separator=' ', strip=True)
if text:
a_tag = tr.find('a')
if a_tag:
product_link = a_tag.attrs['href']
all_text = text + ' ' + product_link
all_products.append(all_text.split(' '))
print(all_products)
Output is:
[['4342141', '25.07.2018', '09:00', 'Ankara', '-', 'Konya', 'free.asp?detail=hide&c_id=4342141'], ['4134123', '26.07.2018', '09:00', 'Van', '-', 'Istanbul', 'free.asp?detail=hide&c_id=4134123']]
I need some TVs (weight, dimensions, etc) I've associated with my products to appear in the Cart page of my SimpleCart site.
Problem is I have no idea how to do this. I don't understand how the SimpleCart cart is built and there isn't documentation for this.
Would anyone know how I can show TVs associated with each product in the cart output chunk?
The cart snippet has the following code which gets data from the cart and puts it into Chunks:
$sc = $modx->getService('simplecart','SimpleCart',$modx->getOption('simplecart.core_path',null,$modx->getOption('core_path').'components/simplecart/').'model/simplecart/',$scriptProperties);
if (!($sc instanceof SimpleCart)) return '';
$controller = $sc->loadController('Cart');
$output = $controller->run($scriptProperties);
The output Chunk looks like:
<div id="simplecart">
<form action="[[~[[*id]]]]" method="post" id="form_cartoverview">
<input type="hidden" name="updatecart" value="true" />
<table>
<tr>
<th class="desc">[[%simplecart.cart.description]]</th>
<th class="price">[[%simplecart.cart.price]]</th>
<th class="quantity">[[%simplecart.cart.quantity]]</th>
[[+cart.total.vat_total:notempty=`<th class="quantity">[[%simplecart.cart.vat]]</th>`:isempty=``]]
<th class="subtotal">[[%simplecart.cart.subtotal]]</th>
<th> </th>
</tr>
[[+cart.wrapper]]
[[+cart.total.discount:notempty=`<tr class="total first discount">
<td colspan="[[+cart.total.vat_total:notempty=`3`:isempty=`2`]]"> </td>
<td class="label">[[%simplecart.cart.discount]]</td>
<td class="value">- [[+cart.total.discount_formatted]]</td>
<td class="extra">[[+cart.total.discount_percent:notempty=`([[+cart.total.discount_percent]]%)`:isempty=` `]]</td>
</tr>`:isempty=``]]
[[+cart.total.vat_total:notempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_ex_vat]]</td>
<td class="value">[[+cart.total.price_ex_vat_formatted]]</td>
<td class="extra"> </td>
</tr>
[[+cart.vat_rates]]
<tr class="total [[+cart.total.discount:notempty=`third`:isempty=`second`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_vat]]</td>
<td class="value">[[+cart.total.vat_total_formatted]]</td>
<td class="extra"> </td>
</tr>
<tr class="total [[+cart.total.discount:notempty=`fourth`:isempty=`third`]]">
<td colspan="3"> </td>
<td class="label">[[%simplecart.cart.total_in_vat]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`:isempty=`
<tr class="total [[+cart.total.discount:notempty=`second`:isempty=`first`]]">
<td colspan="2"> </td>
<td class="label">[[%simplecart.cart.total]]</td>
<td class="value">[[+cart.total.price_formatted]]</td>
<td class="extra"> </td>
</tr>
`]]
</table>
<div class="submit">
<input type="submit" value="[[%simplecart.cart.update]]" />
</div>
</form>
This does appear to be documented:
Product Options (TVs)
and to output them:
Modifying the Product Template
It appears that you would just output them normally [[*myProductOptions]]
Though, it appears that your template is using a placeholder, I would try
[[+cart.myProductOptions] as well. If all else fails you might try debugging the simplecart class and dump the array of product data before it populates the chunk, there might be a clue in there.
Found (through trial and error) you must use:
[[+product.tv.name_of_tv]]
How do I change the bgcolor of 'colorId'. I tried the code below and I want the bgcolor to change in the value 'val'. But from then on I m doing something wrong.
<script type="text/javascript">
function updatevariable(elm) {
val = elm;
var divElement = document.getElementById(colorId);
divElement.bgcolor = val;
}
</script>
<table width="150" border="0" cellspacing="1" cellpading="0" align="center">
<tr>
<td bgcolor="#190707" onclick="updatevariable(this.bgColor)"> </td>
<td bgcolor="#fa5858" onclick="updatevariable(this.bgColor)"> </td>
<td bgcolor="#F4FA58" onclick="updatevariable(this.bgColor)"> </td>
<td bgcolor="#00FF00" onclick="updatevariable(this.bgColor)"> </td>
<td bgcolor="#fbefef" onclick="updatevariable(this.bgColor)"> </td>
</tr>
<tr>
<td id='colorId' bgcolor="#F4FA58"> </td>
</tr>
</table>
If you switch to jQuery you can do this in stead:
function updatevariable(elm){
var val = elm;
$('#colorId').css('background-color', val);
}
Just found your bugs. Use code below and it would work.
function updatevariable(elm) {
var val = elm;
var divElement = document.getElementById("colorId");
divElement.setAttribute("bgcolor", val);
}