Mail going to inbox but cannot display sender name - php

I want to send to mail to user for any update.
My first tried as below, here all mail goes to spam folder but here sender name display well.
This code is
$headers = "From: Sender Name <info#senderweb.com >\r\n" .
"Reply-To: info# senderweb.com\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n";
After prevent goes to spam folder, my below code make all mail goes well at inbox but here sender name display server name something like senderwe#server1.server.com.
I found this report at track delivary of cpanel : ECDHE-RSA-AES128-GCM-SHA256:128 CV=yes: SMTP error from remote mail server after MAIL FROM:< senderwe#server1.server.com > SIZE=3829: 553 5.7.1 [BL21] Connections will not be accepted from ###.72.###.129, because the ip is in Spamhaus's list; s
$headers = "From: Sender Name <info#senderweb.com >";
$headers = "Reply-To: info# senderweb.com \r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n";
I also look at Spamhaus's list by this ip, where I found my ip is listed in the XBL.
Please where is my problem here to display sender name at inbox?
Full Code:
$subject = "My subject";
$message .= "<html>";
$message .= "<head>";
$message .= "<style type=\"text/css\" media=\"screen\">";
$message .= "a:link, a:visited {color:#A0C804; text-decoration:none;}";
$message .= "a:hover {color:#339933; text-decoration:none;}";
$message .= "body {background-color:#FFFFFF;";
$message .= "font-family:Arial, Helvetica, sans-serif;";
$message .= "color:#000000;";
$message .= "font-size:12px;}";
$message .= "p.general {font-size: 14px;";
$message .= "line-height: 16px;";
$message .= "font-weight: normal;";
$message .= "padding-right:20px;";
$message .= "padding-left:17px;";
$message .= "margin-bottom:3px;}";
$message .= ".page {background-color:#ff0000;";
$message .= "padding:0px;";
$message .= "width:100%;}";
$message .= ".content {width:100%;";
$message .= "height:auto;";
$message .= "background-color:#FFFFFF;";
$message .= "padding:10px;";
$message .= "border:#ECEBEB;}";
$message .= "span.prospan {font-size: 14px;";
$message .= "line-height: 16px;";
$message .= "padding-left:20px;";
$message .= "margin-bottom:10px;}";
$message .= "p.proitem {font-size: 14px;";
$message .= "margin-bottom:10px;";
$message .= "padding-left:17px;}";
$message .= "p.tota {color: #ff0000;";
$message .= "padding-left:17px;";
$message .= "font-size: 14px;";
$message .= "margin-bottom:20px;";
$message .= "font-weight: bold;}";
$message .= "p.soong {color: #000000;";
$message .= "padding-left:17px;";
$message .= "margin-bottom:10px;";
$message .= "font-size: 14px;";
$message .= "font-weight: bold;}";
$message .= "p.foot {color: #000000;";
$message .= "margin-bottom:10px;";
$message .= "padding-left:17px;";
$message .= "font-size: 14px;}";
$message .= "</style>";
$message .= "<body>";
$message .= "<div class=\"page\">";
$message .= "<div class=\"content\">";
$message .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#ECEBEB\">";
$message .= "<tr>";
$message .= "<td style=\"text-align:left;\" bgcolor=\"#FF6699\"><img src=\"http://www.myweb.com.au/images/logo.png\" width=\"99\" height=\"83\" style=\"padding:15px;\" /></td>";
$message .= "<td style=\"text-align:right;\" bgcolor=\"#FF6699\"><h2 style=\"color:#ffffff;padding:20px;\" >Web name</h2></td>";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
$message .= "</tr>";
$message .= "<tr>";
$message .= "<td width=\"100%\" cellpadding=\"20\" align=\"left\"><br>";
$message .= "<p class=\"general\"><b>Congratulation ! </b></p><br>";
$message .= "<p class=\"general\">Dear <b>".$my_name."</b> ,</p><br>";
$message .= "<p class=\"general\">Massage to clint.</p><br>";
$message .= "</td>";
$message .= "</tr>";
$message .= "</table>";
$message .= "</div>";
$message .= "</div>";
$message .= "</body>";
$message .= "</html>";
$headers = "From: Sender Name <info#senderweb.com >";
$headers = "Reply-To: info#senderweb.com \r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n";
mail($email,$subject,$message,$headers);

Send a delist request for sender address. Any local cPanel user can use the 127.0.0.1 IP address to send mail without authentication. This can make it difficult for system administrators to determine which cPanel account sent the mail, especially when a malicious user spoofs an email address to disguise the origin of the email.
To require cPanel & WHM to put the actual sender in the header, enable the Experimental: Rewrite From: header to match actual sender option in WHM's Exim Configuration Manager interface (Home >> Exim Service Configuration >> Exim Configuration Manager). Check here https://documentation.cpanel.net/display/CKB/How+to+Prevent+Email+Abuse

Related

Send Mail when SQL value is True

So, I'm kind of in a rut for over a day now because of this issue. I have a PHP wherein it gets called by Cron on a set amount. It gets called and executes just fine without much problems except for the styling. What it does is query the database on a set time for a value and if it's true then it proceeds to email that to the designated email that I put in the script. It's doing it's job but the problem is the format when the email gets delivered. The email looks like this when I open it:
The issue, as you can see is that only the first line or row gets formatted on the table and the rest of the results doesn't follow it.
Here's the current script I'm using with some omitted/changed details.
#!/path/to/php
<?php
//DB
$dbconnect=new mysqli('localhost', 'user', 'pass', 'db');
$result=$dbconnect->query("SELECT `uid`,`pid`,`pdesc`,`umail`,`name` FROM `db_table` WHERE `pid`<='6'");
//if there are any records matching this query send an email listing each one using 'uid' as the identifier
if($result->num_rows>=1) {
$to = 'test#test.com';
$subject = "TEST FOR PRIZES NOTIFICATION";
$headers = 'From: sender#test.com' . "\r\n" .
$headers = "MIME-Version: 1.0" . "\r\n" .
$headers = "Content-type:text/html;charset=iso-8859-1" . "\r\n" .
'Reply-To: rep#test.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = '<html><body>';
$message .= 'THIS IS A TEST!';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= '<tr>
<td>User ID</td>
<td>Display Name</td>
<td>Email</td>
<td>Price</td>
<td>Price Description</td></tr>';
while($row=$result->fetch_assoc()) {
$message .= "<tr><td>".$row['uid']."</td>";
$message .= "<td>".$row['name']."</td>";
$message .= "<td>".$row['umail']."</td>";
$message .= "<td>".$row['pid']."</td>";
$message .= "<td>".$row['pdesc']."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
}
if(mail($to, $subject, $message, $headers)) {
//mail successfully sent
} else {
//mail unsuccessful
}
}
?>
Thank you for your time!
You're closing the table inside of your loop, so it's closed after the first entry. Change your code from this:
while($row=$result->fetch_assoc()) {
$message .= "<tr><td>".$row['uid']."</td>";
$message .= "<td>".$row['name']."</td>";
$message .= "<td>".$row['umail']."</td>";
$message .= "<td>".$row['pid']."</td>";
$message .= "<td>".$row['pdesc']."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
}
to this:
while($row=$result->fetch_assoc()) {
$message .= "<tr><td>".$row['uid']."</td>";
$message .= "<td>".$row['name']."</td>";
$message .= "<td>".$row['umail']."</td>";
$message .= "<td>".$row['pid']."</td>";
$message .= "<td>".$row['pdesc']."</td></tr>";
}
$message .= "</table>";
$message .= "</body></html>";
to close the table at the end.

Include Variables in PHP mail command

I'm sure I'm wrong about something basic, but can not find where the error is. I will appreciate your help.
I have a php page with a single 4 fields contact form.
I need send the name and email as variable, so i can see it properly when email is received.
IT WORKS - BUT DONT SEND NAME AND EMAIL AS VARIABLE:
All messages arrives as "no-reply#luchodomain.com" and doesnt look professional (and can't do reply from my outlook)
if ($_POST) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: no-reply#luchodomain.com" . "\r\n" ;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body>";
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
mail($to,$subject,$message,$headers);
}
IT DOENST WORKS (but have the format and variables as i need)
I would like receive the messages like is normal Name, so i can do a quick reply. -This code don't send email, doesn't work-
if ($_POST) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "<html><body>";
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
mail($to,$subject,$message,$headers);
}
I will appreciate your help with this "headers" issue!
Thank you.
Make sure that you are receiving data in your post array. Make sure your form action. You have declared $message variable to blank after assigning the post value in it before. That's not a good trick enough. Please check updated code and let me know.
if ($_POST) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$subject = strip_tags($_POST['subject']);
$message = strip_tags($_POST['message']);
$to = "lucho#hotmail.com";
$subject = "Website CONTACT";
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//$message = "";
//$message .= '';
$message .= "\r\nName: " . $name . "";
$message .= "Email: " . $email . "\r\n";
$message .= "Subject: " . $subject . "\r\n";
$message .= "Message: " . $message . "";
//$message .= "";
//$message .= "";
mail($to,$subject,$message,$headers);
}
$to = 'pawanvikasitha2001#gmail.com, aravindasamapath87#gmail.com'; $subject = 'NEW ORDER HAS PLACED'; $message = "$name"; mail ($to,$subject,$message);
When you use the double quotes, You can simply add variables to it. Look at the $message

PHP email message not working with HTML

Trying to get my form to email working, but when I add this part of the code
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
the email won't send. When I remove it, the email sends, but all the tags show up. Any idea what the problem is?
My php code is below:
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$injury = $_POST['injury'];
$message = $_POST['message'];
$myemail = 'example#gmail.com';
$subject = 'Brain Damage Info Free Evaluation Form';
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$email_message = '<html><body>';
$email_message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$email_message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$email_message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$email_message .= "<tr><td><strong>Phone:</strong> </td><td>" . strip_tags($_POST['phone']) . "</td></tr>";
$email_message .= "<tr><td><strong>Injury:</strong> </td><td>" . strip_tags($_POST['injury']) . "</td></tr>";
$email_message .= "<tr><td><strong>Description of Injury:</strong> </td><td>" . $_POST['message'] . "</td></tr>";
$email_message .= "</table>";
$email_message .= "</body></html>";
$sent = mail($myemail,$subject,$email_message,$headers);
I use
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
with this i do not get such errors. I think the charset is the problem.

Sending HTML email in PHP

I am working on an HTML page where i need to send confirmation by HTML email using PHP.
I don't have much experience in PHP as i occasionally work on PHP.
I am able to send the HTML email using PHP and it comes up nice except the IMAGE part.
I have checked about 30 example and implement different ways of but non works.
When i check the source code of email it shows image part as
<img src="http://www.xyz.com/images/emailheader.jpg\"">
<img src="http://www.xyz.com/images/emailheader.jpg\";" alt="mage"">
Code for HTML
$subject = 'Confirmation';
$message = '<table ><tr><td><img src=\"http://www.xyz.com/images/emailheader.jpg\" /></td></tr><tr><td >'. "\r\n";
$message .= '<img src=\"http://www.xyz.com/images/emailheader.jpg\"; alt="Image" />';
$message .= 'Title <br/><br/>'. "\r\n";
$message .= 'Dear '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/><br/>'. "\r\n";
$message .= ' <br/><br/>'. "\r\n";
$message .= 'Name: '. $_SESSION['FN'] . ' '.$_SESSION['LN'].'<br/>'. "\r\n";
$message .= 'Email: '. $_SESSION['Email'].'<br/>'. "\r\n";
$message .= '<br/><br/>.'. "\r\n";
$message .= '<br/><br/>Best Regards,'. "\r\n";
$message .= '</td></tr></table>';
//Headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n";
$headers .= 'From: booking#xyz.com' . "\r\n";
$headers .= 'Reply-To: abc#xyz.com' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
ini_set ( "SMTP", "smtp.abc.com" );
I would appreciate if some can correct my code or at-least tell me what i am doing wrong
problem is in this line:
'<img src=\"http://www.alfarooqcentre.com/images/emailheader.jpg\"; alt="Image" />';
remove "\" and ";"
or check this tutorial, there is what you want.
http://phpform.net/html_mail.php

php email not reading html

For some reason, the html fails to render in gmail, but renders in hotmail.
Its vital that gmail reads the html, so I wonder which changes I should make to this header.
$from = "info#email.co";
$headers = "From: bob at info.co <" .($from) . ">\n";
$headers .= "Reply-To: ".($from) . "\n";
$headers .= "Return-Path: ".($from) . "\n";;
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-Mailer: PHP". phpversion() ."\n";
The message starts of as:
$message = '<html><body>';
$message .= "<p>";
$message .= "Hi $clean_fullName, <br><br>";
$message .= " Well, I've looked at what you shared with me and I'm delighted to include my personal learning suggestions that I hope will help you achieve your startup goals.";
$message .= "<br><br>";
$message .= "If they aren't quite what you're looking for, I take criticism better than most Entrepreneur Wizards
so please let me know by responding to this email and I'll take another look for you.";
$message .= "<br><br>";
$message .= "
$message .="<br><br>Otherwise, happy learning!<br><br>";
$message .= "<b>Total Learning time: </b>";
// create an array of all the duration
$counter = array();
foreach($data as $item) {
// add each duration item to the array after every iteration
array_push($counter, "{$item['duration']}");
}
//record and display the result to the user
$message .= array_sum($counter);
$message .= " hours <br><br>";
foreach($data as $item) {
$message .= "<b>
&#10139<a style='color:#FF6400; text-decoration: none' href='{$item['link']}'>{$item['title']}</a></b><br>";
$message .= "Format: {$item['format']} <br>";
$message .= "Cost: ${$item['costs']} <br>";
$message .= "Estimated Duration: {$item['duration']} hours<br>";
$message .= "<br>";
}
$message .= " If you have any questions, do not hesitate to reach out to us. <br><br>";
$message .= "</p>";
$message .= '</body></html>';
mail
mail($to,$subject,$message,$headers);
I am still learning :)
but this should work
$from = "info#email.co";
$headers .= 'From: bob at info.co <$from>' . "\r\n";
$headers .= 'Reply-To: <$from> ' . "\r\n";
$headers .= 'Return-Path: <$from>' . "\r\n";
$headers .= 'MIME-Version: 1.0 ' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= 'X-Priority: 3' . "\r\n";
$headers .= 'X-Mailer: PHP". phpversion()' . "\r\n";
Answer from comments
$message = '<html><body>';
u should do like this
$message .= '<html>'. "\r\n";
$message .= '<body>' . "\r\n";
You have too much errors in writing missing dot semi etc
as i see your html tag wasn't open at all.
there is lot options to write this template
1.
<?php
// multiple recipients
$to = 'aidan#example.com' . ', '; // note the comma
$to .= 'wez#example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck#example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
2.
$message.= 'blasldl asdas d asdas' . "\r\n";
$message.= ' sdfadasdasd dsad' . "\r\n";
U can change "\r\n"with $rn = "\r\n"; and use it fast as $rn
$message.= 'blasldl asdas d asdas' . $rn;
$message.= ' sdfadasdasd dsad' . $rn;
u can try those solutions and tell me whats happening .
and dont place all email under<p></p>

Categories