'how to center link between two others with phpmailer
I'm using phpmailer 6.6.0 with php 8.0. This is how the email looks in outlook:
and this is how the email looks on a iphone 11 with ios 15.4.1:
Notice how the SwB Link is centered on outlook but it gets moved a little to the right on the iphone. Does anybody have suggestion for how to fix that or improve on the code below?
Here's my phpmailer function:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
function mailerExpressBlueHostUpdated(array $mailInputs){
require_once '../includes/phpmailer6.6/src/PHPMailer.php';
require_once '../includes/phpmailer6.6/src/SMTP.php';
$mail = new PHPMailer();
$mail->IsMail();
$mail->SetFrom('[email protected]');
$mail->IsHTML(true);
$mail->addAddress($mailInputs['addAddress']); // use this for production
/*$mail->AddBCC("[email protected]"); // set BCC: counts as part of the 500 limit; */
$mail->AddEmbeddedImage("../public/img/swb.jpg", "swb-image");
$mail->AddEmbeddedImage("../public/img/email-32.png", "swb-email");
$mail->AddEmbeddedImage("../public/img/phone-32.png", "swb-phone");
$body = $mailInputs['body'] ;
$mail->isHTML(true);
$mail->Subject = $mailInputs['subject'] ;
$mail->Body = $body;
if(!$mail->send()) {
echo "MAIL NOT SENT";
return 'Message could not be sent.' . 'Mailer Error: ' . $mail->ErrorInfo;
}else{
echo "sent mail";
return 'Message has been sent';
}
$mail->ClearAddresses();
}
here's my php controller:
<?php
require ("../includes/constants.php");
require ("../includes/functions.php");
$body = file_get_contents('../views/html/STANDARD_EMAIL.html');
$body = str_replace('firstname' ,"BOB" ,$body);
$body = str_replace('boat' ,"Windy" ,$body);
$body = str_replace('start' ,"09:00am" ,$body);
$body = str_replace('end' ,"12:30pm",$body);
$body = str_replace('ressailxcl' ,'RES TIME' ,$body);
$body = str_replace('datex' ,"May 3, 2019" ,$body);
$body = str_replace('colorx' ,"red" ,$body);
$body = str_replace('status' ,"OUT" ,$body);
$body = str_replace('skipemail' ,"[email protected]" ,$body);
$body = str_replace('skipphone' ,"617-123-4567" ,$body);
$body = str_replace('msg1' ,'Upcoming Reservation' ,$body);
$body = str_replace('msg2' ,"(wouldn't you rather be sailing?)" ,$body);
$body = str_replace('skipperx' ,"Capt Bob",$body);
$body = str_replace('<!--skipmsg-->','<b>Skipper Update: </b>' . "testing" ,$body);
$mailInputs = array("addAddress" => "[email protected]",
"subject" => "SwB:Sail Cancelled",
"body" => $body,
"usr" => 142);
$msg = mailerExpressBlueHostUpdated($mailInputs);
?>
and here is my STANDARD_EMAIL.html file
<!DOCTYPE html>
<html>
<head>
<style>
div{
font-size:5vw!important;
}
#img1{
width:100%!important;
}
</style>
</head>
<body lang=EN-US>
<div style="text-align:center;margin:0 auto;font-size:16px">
<img id="img1" style="width:70%;" src="cid:swb-image">
<h3 style='padding-left:10px;margin-bottom:0;margin-top:0%;padding-top:0;text-align:left'> Hi firstname, </h3>
<table style='text-align:left;margin:0 auto;'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<col style='width:8.33%'>
<tr>
<td colspan='12' style='text-align:center'>
<h3 style='margin-top:8px;margin-bottom:0'> msg1</h3>
<h4 style='margin-bottom:8px;margin-top:0'>msg2 </h4>
</td>
</tr>
<tr>
<td colspan='3'>DATE:</td>
<td colspan='9'>datex</td>
</tr>
<tr>
<td colspan='3'>SKIPPER:</td>
<td colspan='9'>skipperx</td>
</tr>
<tr>
<td colspan='3'>BOAT:</td>
<td colspan='9'>boat</td>
</tr>
<tr>
<td colspan='3'>STATUS:</td>
<td colspan='9' style='color:colorx'>status</td>
</tr>
<!--<tr><td> </td></tr> -->
<tr>
<td colspan='4'> </td>
<td colspan='4' style='text-align:center;'>Start</td>
<td colspan='4' style='text-align:center;'>END</td>
</tr>
<tr>
<td colspan='4'>ressailxcl:</td>
<td colspan='4' style='font-weight:bold;text-align:center'>start</td>
<td colspan='4' style='font-weight:bold;text-align:center'>end</td>
</tr>
<tr>
<td colspan='12' style='text-align:center'>
<h5 style='margin-bottom:1%;'>Click on link to update your availability</h5>
</td>
</tr>
<tr>
<td colspan='4' style='text-align:left;'>
<a style='text-decoration:none;' href='mailto:skipemail'>
<img src="cid:swb-email" style="width:32px;height:32px;border:0;"/>
</a>
</td>
<td colspan='4' style='text-align:center;'>
<h5><a href='https://www.sailwbob.com/skipper'>SwB link</a></h5>
</td>
<td colspan='4' style='text-align:right;'>
<a style='text-decoration:none' href='tel:skipphone'>
<img src="cid:swb-phone" style="width:32px;height:32px;border:0;"/>
</a>
</td>
</tr>
</table>
</div>
<div>
<!--skipmsg-->
</div> </body> </html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|