Email not working which contains sub domain url - php

I am getting a strange issue in a website.
I have a domain (e.g. http://exaple.com.PQR.co.uk) on which I have built a website using PHP.
Website working fine but issue is in sending email.
I trying to send HTML email as below example ::
<html lang="en"><head><meta charset="utf-8"></head>
<body>
<table style="width: 100%; border: none; border-collapse: collapse;">
<tbody>
<tr>
<td style="border: none; background-color: #000; padding: 15px; color:#fff; width: 70px;">
<a href="#" style="border:none;">
<img src="**http://www.example.com.PQR.co.uk/**webservices/icon-70.png" width="70" height="70">
</a>
</td>
<td style="border: none; background-color: #000; padding: 15px; color:#fff; font-size: 40px;">
ABC
</td>
</tr>
<tr>
<td colspan="2" style="background-color: #EEEEEE; color: #000; padding: 10px;">
Hello User, <br><br>
Your account details are as below:<br/><br/>
Email ID : test.example#gmail.com<br/>
Password : Click here to change password.<br/>
</td>
</tr>
<tr>
<td colspan="2" style="background-color: #EEEEEE; color: #000; padding: 10px;">
Thanks,<br/>
ABC Team
</td>
</tr>
<tr>
<td colspan="2" style="background-color: #EC008C; padding:5px;">
</td>
</tr>
</tbody>
</table>
</body>
</html>
This email does not send successfully but mail() returns TRUE.
When I tries to send same email by changing domain to "example.com" instead of "www.example.com.PQR.co.uk" then it works but with "www.example.com.PQR.co.uk" its not working.
Please guide me for this issue. I am not getting where issue is.
Thanks in advance

Related

Loops, what and how to use? (for, while, and foreach)

What's up guys!
I have a problem and I can not think of a solution.
I need to make a report using DOMPDF.
In this report, i need to print some employee information. In each page it is necessary to have header for the signature of the person in charge.
I have a group of employees. They are divided by departments.
I need a "break the page" loop when I change the employee's department or when I print 15 employees. After that, the loop should print the rest of the employees and execute the same rules if you change the employee's department again or have already been printed 15 employees.
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Relatório Geral</title>
<style>
body {
margin-top: -20px;
margin-left: -20px;
margin-right: -5px;
padding:0
}
.borda3 {
border:1px solid #999;
padding: 5px;
}
#borda2 td {
border: 1px solid #999;
border-collapse: collapse;
width: auto;
}
.centro {
text-align: center;
}
.tabela {
width: 100%;
}
span {
font-size: 100px;
}
td {
font-size: 11px;
}
html {
font-family: sans-serif;
}
#customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers td, #customers th {
border: 1px solid #ddd;
}
#customers tr:nth-child(even){background-color: #f2f2f2;}
#customers tr:hover {background-color: #ddd;}
#customers th {
text-align: center;
font-size: 9px;
}
#customers td {
text-align: left;
font-size: 10px;
}
#customers a {
font-size: 10px;
}
.nome{
width: 180px;
}
.matricula{
width: 15px;
}
.numeros{
width: 15px;
}
.logo{
padding-left: 50px;
}
.logo a strong{
font-size: 15px;
text-align: center;
}
.logo a{
font-size: 12px;
}
.assinatura{
font-size: 9px;
margin-left: 60px;
}
</style>
</head>
{{--beginning of the loop--}}
<body>
<table class="tabela borda3">
<tr>
<td width="40%" class="centro">
<table class="logo">
<tr>
<td>
<img style="margin-left:20px; margin-top: -20px;width:220px; height: 65px;" src="img/logo_sarh.jpg">
</td>
</tr>
<tr>
<td>
<label for=""><a><strong> </strong></a></label><br>
</td>
</tr>
<tr>
<td><a>Referência:</a></td>
</tr>
<tr>
<td><a>Período:</a></td>
</tr>
</table>
</td>
<td width="40%" class="centro">
<table class="assinatura">
<tr>
<td style="height: 30px; text-align: left"><label for="">Em: _____/ _____/___________</label></td>
</tr>
<tr>
<td style="padding-bottom: -20px; height: 50px; text-align: center">
<label for="">____________________________________________</label><br>
<label style="font-size: 10px" for=""> SUPERVISOR</label>
</td>
</tr>
<tr>
<td style="height: 30px; text-align: left"><label for="">VISTO</label></td>
</tr>
<tr>
<td style="padding-bottom: -10px; height: 50px; text-align: center">
<label for="">____________________________________________</label><br>
<label style="font-size: 10px" for=""> SECRETÁRIO(A)</label>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table id="customers">
<tr>
<th class="nome">Nome</th>
<th class="matricula">Matrícula</th>
<th class="numeros">Dias</th>
<th class="numeros">Faltas</th>
<th class="numeros">Vac</th>
<th class="numeros">LSV</th>
<th class="numeros">L M</th>
<th class="numeros">Aci. Trab</th>
<th class="numeros">Adi. Not</th>
<th class="numeros">H.E Normal D</th>
<th class="numeros">H.E Normal N</th>
<th class="numeros">H.E Dom/Fer. D</th>
<th class="numeros">H.E Dom/Fer. N</th>
<th class="numeros">Ins.</th>
</tr>
{{--beginning of the loop--}}
<tr>
<td style="height: 20px;"><a>Augusto Damasceno Pedrozo</a></td>
<td style="height: 20px;"><a>12345678</a></td>
<td style="height: 20px;"><a>30</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>2</a></td>
<td style="height: 20px;"><a>20,02</a></td>
<td style="height: 20px;"><a>20,02</a></td>
<td style="height: 20px;"><a>20,02</a></td>
<td style="height: 20px;"><a>20,02</a></td>
<td style="height: 20px;"><a>20</a></td>
</tr>
<tr>
<td style="height: 20px;" colspan="14">Observação:</td>
</tr>
{{--end of the loop--}}
</table>
</body>
{{--end of the loop--}}
</html>
Could anyone give me some direction to solve this?
I think you want something like this:
#foreach($customers as $customer)
#while ($loop->index <= 15)
<!-- build table row here -->
#endwhile
<!-- page break -->
#endforeach
in laravel there is a loop variable
this variable tracks the current index and some other things
you can check if the current index is smaller or equal to 15, perform page break, grab next, check if department is same as before, repeat
for the department changes you can set a variable which holds the current department and compare it in the loop like:
#if($current_dep !== $cust->department)
<!-- page break -->
#endif
don't forget to check for last record
#while(!$loop->last)
#endwhile
further information on the $loop variable: https://laravel.com/docs/5.7/blade#the-loop-variable

Laravel email template URLs not working in Gmail

I am using Laravel 4 smtp mail to send mail to users. When I send mails to Gmail, the logo and URLs didn't show up as intended. When I checked the urls, it showed localhost instead of my domain name. I don't know why it's happening.
My email template:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<link href='https://fonts.googleapis.com/css?family=Dosis:400,500,600,700' rel='stylesheet' type='text/css'>
<style>
body {
font-family: 'Dosis', sans-serif;
font-size:14px;
color: #333;
}
#table-wrap {
background:#fafafa;
border-bottom: 5px solid #eee;
border-top: 5px solid #EC4F48;
}
#site_logo{
background: #EC4F48;
border-bottom: 2px solid #EC4F48;
-webkit-border-bottom-right-radius: 2px;
-webkit-border-bottom-left-radius: 2px;
-moz-border-radius-bottomright: 2px;
-moz-border-radius-bottomleft: 2px;
border-bottom-right-radius: 2px;
border-bottom-left-radius: 2px;
}
</style>
</head>
<body>
<table id="table-wrap" width="100%" cellpadding="0" cellspacing="0" style="border-radius:3px; -webkit-border-radius:3px; -moz-border-radius:3px;">
<tbody>
<tr>
<td align="left" style="padding:3px; border-bottom: 2px solid #fadc65;" width="60%">
<h3 style="margin-left: 15px;">Hi, {{{ $username }}}!</h3>
</td>
<td align="center" id="site_logo">
<img src="{{ asset('dist/img/logo.png') }}" width="200" style="margin-left: 10px;" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<br />
<h2>Welcome to mydomain.com !</h2>
<h2>Thanks for registering to Mysite.</h2>
<h4>Click here to confirm your email...</h4>
<br />
</td>
</tr>
<tr>
<td align="left">
<p style="margin-left: 20px; color: #666;">
www.mydomain.com | Email : feedback#mydomain.com
</p>
</td>
</tr>
</tbody>
</table>
</body>
</html>
When you use CLI to generate any view Laravel uses url parameter to set domain. By default its value is set to http://localhost so you need to change this parameter to your domain.
The parameter is located in app.php in config folder.
Laravel comment for Application URL:
This URL is used by the console to properly generate URLs when using the Artisan command line tool. You should set this to the root of your application so that it is used when running Artisan tasks.

How to style a link which wrote with echo? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I would like to the links will be bold in a div, but the links are in a variable which wrote down with echo.
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
<div class="description">
<b>Short description: </b></td>
</tr>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
<br>
<?php print ($_SESSION['description']); ?><br>
<br>
<hr>
</div>
</td>
</tr>
The link is in the $_SESSION['description'].
The css:
.description a:link {
text-decoration: bold;
}
.description a:visited {
text-decoration: bold;
}
.description a:hover {
text-decoration: bold;
}
.description a:active {
text-decoration: bold;
}
I already tried some ways, but the style "can't see" the links which wrote with echo. How can I solve this?
<div class="description">
<b>Short description: </b></td> </tr> <tr> ....
is no valid html!
FIX IT TO
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
<b>Short description: </b></td>
</tr>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
<div class="description">
<br>
<?php print ($_SESSION['description']); ?><br>
<br>
<hr>
</div>
</td>
</tr>
Replace all
text-decoration: bold;
with
font-weight:bold
UPDATE
A downvote, seriously? He is putting the link in description class, which only needs to be fixed
Now style can see (after replace as I said)
<html>
<head>
<style>
.description a:link {
font-weight: bold
}
.description a:visited {
font-weight: bold
}
.description a:hover {
font-weight: bold
}
.description a:active {
font-weight: bold
}
</style>
</head>
<body>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
<div class="description">
<b>Short description: </b>
</td>
</tr>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
<br>
google
<br>
<hr>
</div>
</td>
</tr>
</body>
</head>
and what he was doing
<html>
<head>
<style>
.description a:link {
text-decoration: bold;
}
.description a:visited {
text-decoration: bold;
}
.description a:hover {
text-decoration: bold;
}
.description a:active {
text-decoration: bold;
}
</style>
</head>
<body>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
<div class="description">
<b>Short description: </b></td>
</tr>
<tr>
<td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
<br>
google
<br>
<hr>
</div>
</td>
</tr>
</body></head>
PLEASE CHECK BEFORE DOWNVOTING
<a><?php echo $_SESSION['description']; ?></a>
Now it become a link, and you can put style like
a:link{}

Magento 1.9 - style email template

I am trying to apply my custom css in email template.
I already done these things.
Add inline css to my html
<table align="center" style="width:600px; background:#FFF; border:1px solid #CCC; padding:0; margin-top:0; border-collapse:collapse;">
include inline css file and add path of these css in admin->system->configuration->design {{inlinecss file="email-inline.css"}}
{{inlinecss file="email-non-inline.css"}}
I checked that they are including or not ny editing body background color to black
but no success yet.
I am editing newsletter subscription email template.
I got success in adding style tag by adding {{var non_inline_styles}} to my html file .but not able to write my css into style tag. how can I write my own css in this tag.
So can anyone tell me how can I style my email template
I tried this too
http://devdocs.magento.com/guides/m1x/ce19-ee114/RWD_responsive_emails.html#email-css
here is my template file code
<!--#subject Newsletter subscription success #-->
{{template config_path="design/email/header"}}
{{var non_inline_styles}}
{{inlinecss file="email-inline.css"}}
{{inlinecss file="email-non-inline.css"}}
<div class="newsletter-confirmation">
<table align="center" style="width:600px; background:#FFF; border:1px solid #CCC; padding:0; margin-top:0; border-collapse:collapse;">
<!--Header -->
<tr>
<td style="padding:18px; margin:0; height:40px\9;">
<p style="float:right; margin:0; padding:0; width:200px;">
<img src="{{skin url='images/hot_line.jpg'}}" style="text-align:right; vertical-align:bottom; float:right; clear:both; margin-top:21px;">
</p>
</td>
</tr>
<tr><td style="height:1px; border-bottom:1px solid #000; width:100%; margin:0; padding:0; line-height:0;"> </td></tr>
<!-- / Header -->
<!--Mid -->
<tr>
<td>
<table align="center" style="width:564px; background:#FFF; padding:18px; margin-top:0; border-collapse:collapse; margin-top:10px;">
<tr>
<td>
<p style="color:#000; font:12px/20px Arial, Helvetica, sans-serif; padding:0; margin:0;">Greetings from ...!<br>
You have been successfully subscribed to the newsletter.</p>
</td>
</tr>
<tr><td height="18"></td></tr>
<tr>
<td>
<table align="center" style="width:564px; margin:0; padding:0; border-collapse:collapse;">
<tr>
<td><a href="#" target="_blank" style="margin:0; padding:0 10px 0 0; border:none; outline:none;">
<img src="{{skin url='images/free-shipping.jpg'}}" style="text-align:left; vertical-align:bottom; border:none; outline:none; margin:0; padding:0;"></a>
</td>
<td rowspan="2"><a href="#" target="_blank" style="margin:0; padding:0; border:none; outline:none;">
<img src="{{skin url='images/return-exchange.jpg'}}" style="text-align:left; vertical-align:bottom; border:none; outline:none; margin:0; padding:0 0 0 10px;"></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p style="color:#000; font:12px/20px Arial, Helvetica, sans-serif; padding:0; margin:12px 0;">Thank you<br><strong>Team ...</strong></p>
</td>
</tr>
</table>
</td>
</tr>
<!--Mid -->
<!--Footer -->
<tr>
<td style="width:582px; padding-left:18px; background:#efefef;" >
<p style="color:#666666; font:11px/15px Arial, Helvetica, sans-serif; padding:0; margin:8px 0;">
....com All Rights Reserved.
</p>
</td>
</tr>
<!-- / Footer -->
</table>
</div>
{{template config_path="design/email/footer"}}
The styles should be written like below in your case
<!--#styles
.button {
color: white!important;
width: 19%;
padding: 8px;
border-radius: 5px;
}
.approve {
background: rgba(18, 171, 18, 0.72);
margin-right:5px;
}
.disapprove {
background: rgba(232, 73, 73, 0.91);
}
.actions {
display: inline-block;
margin-top: 32px;
}
#-->

send html as attachment via phpmailer

I have html variable,i want to send it as attachment via email.
here is my code
$html='
<table cellpadding="0" cellspacing="0" style=" margin:0 auto;" width="100%">
<tr>
<th style="background:#FC3; padding:4px 0;border:1px solid #000; border-bottom:2px solid #000; border-right:2px solid #000;" align="center" valign="middle"><h3 style="font:300 14px verdana; margin:0; text-align:left;text-align:center;">DECLARATION BY THE AGENT</h3></th>
<th style="background:#FC3; padding:4px 0;border:1px solid #000; border-bottom:2px solid #000; border-right:2px solid #000;" align="center" valign="middle"><h3 style="font:300 14px verdana; margin:0; text-align:left;text-align:center;">DECLARATION BY THE OWNER (The Seller)</h3></th>
</tr>
<tr>
<td width="49%" style="padding:5px 10px;border-right:2px solid #000;">
<ul style="margin:0; padding:0;">
<li style="list-style:none; margin:0 0 10px 0;">
<p style="font:300 12px verdana;float: left; margin:0 5px 0 0;text-align:center;">
I hereby declare, I have read and understood the Real Estate Brokers Code of Ethics,
</p>
</li>
</ul></td>
<td width="49%" style="padding:5px 10px;border-left:1px solid #000;">
<ul style="margin:0; padding:0;">
<li style="list-style:none; margin:0 0 10px 0;">
<p style="font:300 12px verdana;float: left; margin:0 5px 0 0; text-align:center;">
I/We hereby declare, we are the Owners of the property as stated below.
</p>
</li>
</ul></td>
</tr>
</table>';
$mail->AddAttachment($html); // attachment
$mail->Send();
AddAttachment() requires a file (on the filesystem)
there is the AddStringAttachment() function for what you are doing. see docs: http://docs.redaxo.com/de/4.3.1/class_p_h_p_mailer.html#a92ef5134fdce5bd5fd24a723c508bf2b
try this:
$mail->AddStringAttachment($html,"filename.htm","base64","text/html");
I think you are trying to send html instead so try like this
$mail->Body = $html;
$mail->Send();
ok, so you are trying to send it for example and it deosn't work ?
$mail->AddAttachment("/var/tmp/file.html");

Categories