I'm trying to insert a button in an anchor tag with an href. I want the user to see a button and not a link
<a href='http://example.com/PhpProject3/reset_passwd.php?key="<?= $email; ?>"&userid="<?= $userid; ?>"' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>Click To Reset password</a>
You can use HTML in your mail like this :
<?php
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
$message = "<a href='http://example.com/PhpProject3/reset_passwd.php?key=".$email."&userid=".$userid."' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>Click To Reset password</a>";
$message .= "Other Information ";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Please try this:
$html .= '<tr><td>Reject</td></tr>';
Try this
<a href='http://example.com/PhpProject3/reset_passwd.php?key=".$email."&userid=".$userid."' style=' background-color: #4CAF50;border: none;color: white;padding: 15px 32px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;'>
<button>Click To Reset password</button>
</a>";
Related
I'm using PHP 7.4.30 and I'm totally new to PHP.
$subject ="My subject";
$message = '<html><body>';
$message .= '<div style="text-align: center; width: 100%; background-color: #fff;">';
$message .= '<div class="info"> </div>';
$message .= '<table style="text-align: justify; margin: auto; background-color: #ebebeb; border: 1px solid #e7e7e7; width: 600px;" cellspacing="0" cellpadding="0" bgcolor="#ebebeb" align="center">';
$message .= '<tbody>';
$message .= '<tr style="line-height: 0px;">';
$message .= '<td style="line-height: 0';
$from = "My website<robot#website.com>";
$replyto = "website#website.com";
$headers = 'Content-Type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
$headers .= 'Reply-To: '. $replyto . "\r\n";
$headers .= 'Bcc: xxx#xxx.com';
$message = str_replace("\n.", "\n..", $message);
mail($to, $subject, $message, $headers);
Looking at the delivery track from the server, I see the error message:
"message has lines too long for transport"
Can anyone help?
I have recently faced this issue. An easy solution to this issue is replacing this line
$message = str_replace("\n.", "\n..", $message);
with
$message = wordwrap($message, 70,"\r\n");
Following is my php code for email function which is not sending email and i am not getting where the mistake is. Form data is posting properly but mail is not going.
$imgSrc = "logo1.png";
$bg = "background.jpg";
$subjectPara1 = "Dear admin";
$subjectPara2 = $_POST["message"];
$subjectPara4 = $_POST["email"];
$subject = $_POST["subject"];
$subjectPara3 = $_POST["author"];
$message = '<!DOCTYPE HTML><html>'.
'<head>'.
'<title>Email notification</title>'.
'</head>'.
'<body style="background-image: url('.$bg.');background-size: cover;">'.
'<div id="header" style="width: 80%;height: 60px;margin: 0 auto;padding: 10px;color: #fff;text-align: left;font-family: Open Sans,Arial,sans-serif;">'.
'<img height="50" width="220" style="border-width:0" src="'.$imgSrc.'" >'.
'</div>'.
'<div id="outer" style="width: 80%;margin: 0 auto;margin-top: 10px;">'.
'<div id="inner" style="width: 78%;font-family: inherit;font-size: 15px;font-weight: normal;line-height: 1.4em;color: #fff;margin-top: 10px;">'.
'<p>'.$subjectPara1.'</p>'.
'<p>'.$subjectPara2.'</p>'.
'<p><br/>Regards,<br/>'.$subjectPara3.'</p>'.
'<p>'.$subjectPara4.'</p>'.
'</div>'.
'</div>'.
'<div id="footer" style="width: 80%;height: 40px;text-align: center; padding: 10px; font-family: inherit; font-size: 15px; color: #fff;">'.
'All rights reserved # 2016'.
'</div>'.
'</body></html>';
$to = 'test#exmple.com';
$from = $subjectPara4;
$headers = 'From: test#exmple.com\r\n';
$headers .= 'Reply-To: test#exmple.com\r\n';
$headers .= 'MIME-Version: 1.0\r\n';
$headers .= 'Content-Type: text/html; charset=ISO-8859-1\r\n';
if(mail($to, $subject, $message, $headers))
{
echo "<script>window.location='index.php';</script>";
}
Kindly help me to resolve this.
I am sending a newsletter using the following code I am going to post. I have a $to variable that is for email addresses in my database. I use a while loop to send an email for each email address in my database to preserve privacy. At the bottom of the email I have a link for unsubscribing which is linked to a simple script that has the users email in the link. The $to variable is not working in the link though. The email sends but when I look to see if it sent all the data the link looks like http://example.com/scripts/php/unsubscribe.php?email= instead of http://example.com/scripts/php/unsubscribe.php?email=example#email.com.
I'm not sure what I've done wrong here since I am getting no errors, and the script is working except for sending the email in the link.
require('/home/jollyrogerpcs/public_html/settings/globalVariables.php');
require('/home/jollyrogerpcs/public_html/settings/mysqli_connect.php');
mysqli_select_db($conn,"newsletterlist");
$query = "SELECT * FROM newsletterusers";
$result = mysqli_query($conn, $query);
$subject = str_ireplace(array("\r", "\n", '%0A', '%0D'), '', $_POST['subject']);
$message = str_ireplace(array("\r", "\n", '%0A', '%0D'), '', $_POST['body']);
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: Jesse Elser<jesse#jollyrogerpcs.com>' . "\r\n";
if (!$result) exit("The query did not succeded");
else {
while ($row = mysqli_fetch_array($result)) {
$to = $row['email'];
$date = date("m/d/Y h:i:sa");
$body ='<!DOCTYPE HTML>';
$body .='<body style="padding: 0; margin: 0; background-color: #000; color: #fff; text-align: center; font-family: verdana;">';
$body .='<div id="container" style="width: 90%; margin: 0 auto; text-align: left; background-color: #121212;">';
$body .='<div id="header" style="border-bottom: 1px solid #ff6400;">';
$body .='<img src="http://jollyrogerpcs.com/images/main/logo.png" width="100%">';
$body .='</div>';
$body .='<div id="subject" style="background-color: #121212; text-align: center;">';
$body .='<h1 style="color: #ff6400; margin: 0;">'.$subject.'</h1>';
$body .='</div>';
$body .='<div id="message" style="background-color: #232323; color: #fff; padding: 10px;">';
$body .= $message;
$body .='</div>';
$body .='<div id="footer" style="background-color: #121212; padding: 10px;">';
$body .='Visit Our Site | Thanks for subscribing to our newsletter! | Unsubscribe <br> E-mail sent: ';
$body .= $date;
$body .='</div>';
$body .='</body>';
mail($to,$subject,$body,$headers);
}
}
mysqli_close($conn);
header('Location: http://jollyrogerpcs.com/newsletter.php');
You are closing the href attribute before the email address is included so...
<a href="http://example.com/scripts/php/unsubscribe.php?email="'.$to.'"
Should be
<a href="http://example.com/scripts/php/unsubscribe.php?email='.$to.'"
As is it would render as
<a href="http://example.com/scripts/php/unsubscribe.php?email=" email#address.com"....
Which would make the link http://example.com/scripts/php/unsubscribe.php?email=.
I am new to php coding and in my project I would like to draw squares around the square-shaped php forms I made.
However, I have difficulties in doing so... As you can see the the code below, I was testing and try to draw a square with a div below but it is not showing... Can someone please suggest what have I done wrong please?
Cheers,
Karen
<?php
$to = 'sender#email.com';
$subject = 'HTML Form in HTML Email';
$headers = "From: receiver#email.com\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
$message = '<html><body>';
$message .='<div style="width:10px; height:10px; border:1px black !important;">';
$message .='</div>';
$message .= '<form action="http://mysite/process.php" method="post" name="emailCrossword" target="_blank">';
$crossword = array();
$crossword = 6;
for ($i=0; $i<=$crossword.length; $i++){
echo
$message .= '<input type="text" style="width: 13px; text-transform:capitalize;" placeholder="text-align:center;" name="commentText" maxlength="1"></input>';
}
$message .= '<br/>';
$message .= '<br/>';
$message .= '<input type="submit" name="crossword" value="Submit your crossword" /> </form>';
$message .= '</body></html>';
mail($to, $subject, $message, $headers);
?>
I'm not sure what you are trying to achieve, but your css shorthand for the border is wrong:
border:1px black !important;
Should be:
border:1px solid black !important;
For a solid line obviously...
I am attempting to send out HMTL emails with php's mail() function and notice that some things are broken in the email. I found out from reading the original in gmail, that lines in the body of the message are all the same length, and this cuts HTML tags in inconvenient places.
My headers are multipart with boundary between html and plain, with 7-bit. An example of what I'm sending is:
Unsubscribe
But because of its position, the message splits it like
<a href="site.co
m/ubsub">unsubscribe</a>
Which breaks the hyperlink. Is there something I'm missing or not getting? I've seen around about using a mail library like swiftmailer--and I can use it--but I want to actually understand this behavior.
EDIT:
How mail() is being called:
$headers = 'From: Me <me#site.com>' . "\r\n" . 'MIME-Version: 1.0'
$headers .= "\r\n" . "Content-Type: multipart/mixed; charset=ISO-8859-1; boundary=$boundary"
$subject = 'subject';
$html_message = '--' . $boundary . "\r\n";
$html_message .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$html_message .= 'Content-Transfer-Encoding: 7bit' . "\r\n" . "\r\n";
$html_message .= $message . "\r\n";
// plaintext added similarly, with different content-type. Omitted.
mail($to,$subject,$html_message, $headers);
EDIT #2:
Expanding on $message.
$message = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" /><title>"
$message .= "Page Title</title></head><body style=\"margin: 0; padding: 0; font-family: open \'Open Sans\', \'Open Sans Bold\';\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" ><tr><td><table align=\"center\" bgcolor=\"#FFFFFF\" border=\"0\"cellpadding=\"0\" cellspacing=\"0\" width=\"600\"><tr><td align=\"right\" style=\"padding: 20px 20px 20px 20px;\"> <font color=\"#EA5D0F\">[</font> Sign In <font color=\"#EA5D0F\">][</font> About <font color=\"#EA5D0F\">][</font> Search<font color=\"#EA5D0F\">]</font></td></tr><tr><td bgcolor=\"#FFFFFF\" align=\"center\" style=\"padding: 40px 0px 0px 0px;\"><img src=\"http://about.SITE.com/wp-content/uploads/2013/08/SITE.plain_.png\" alt=\"SITE Logo\" width=\"300\" style=\"display: block;\" /></td></tr><tr><td style=\"padding: 10px 20px 20px 20px;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" ><tr><td bgcolor=\"#FFFFFF\" style=\"padding: 30px 10px 10px 10px; text-align:center; font-size: 1.2em; font-weight:bold;\"> <hr color=\"#EA5D0F\"/>"
This continues for quite a while. Not sure how much to include.
I did have that problem in the past. While i don't know what the cause is, it was solved by replacing every > by >\r\n:
$message = str_replace(">", ">\r\n", $message);