gmail does not receive mail from php send_mail - php

I have a register / login system where an email is sent to the registered email address with an activation code. Outlook.com receives the mail and so on, but for some reason Gmail does not receive the mail. I do not know why. If anyone can help me.
thanks in advance
<?php
function send_mail($subject, $to, $text) {
$message = '
<html><body bgcolor="#f0f0f0">
<table width="720" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><font style="font-family:Segoe UI, Arial; color:#0a0a0a;"><h1>Happitual</h1></font></td>
</tr>
<tr>
<td>
<font style="font-family:Segoe UI, Arial; color:#0a0a0a;">
<p>' . $text . '</p>
</font>
</td>
</tr>
<tr>
<td>
<font style="font-family:Segoe UI, Arial; color:#0a0a0a; font-size:12px;">
&copy All Rights Reserved. Happitual.
</font>
</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";
$headers .= 'From: Happitual <welcome#happitual.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
}
?>

I would love to help you out. But can you please provide a copy of your code? you might not be using the right syntax or maybe the mail() function is set the wrong way. Have you checked your headers? how about your MIME version? Please paste your code when you can.

Related

Send HTML links in php mail message

I am trying to send a html link in mail using php. But I am getting the full text of html in the mail. Below is the code what I have tried . But it is not working. Any help is appreciated.
$emailid = $_POST['email'];
$phoneno = $_POST['phoneno'];
$to = "demoemail#gmail.com"; // this is your Email address
$from = $emailid; // this is the sender's Email address
$subject = "Intrested in scheduling appointment.";
$message = "<a href='http://www.google.com'>Click Here</a>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From:" . $from;
$retval = mail($to,$subject,$message,$headers);
Below is what I am getting in mail with tag
http://www.google.com'> Click Here
I've checked with your code..
Seems like you are making a simple mistake..
You are not concatenating your code.. you are re assigning your header at line 3
Your Code
$emailid = $_POST['email'];
$phoneno = $_POST['phoneno'];
$to = "demoemail#gmail.com"; // this is your Email address
$from = $emailid; // this is the sender's Email address
$subject = "Intrested in scheduling appointment.";
$message = "<a href='http://www.google.com'>Click Here</a>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = "From:" . $from;
$retval = mail($to,$subject,$message,$headers);
Updated Code on headers:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:" . $from;
Update your header and try again!
Thanks! Have a nice day!
Working code with template paste and run
<?
$to = $send_to;
$subject = $mail_subject;
$message .= '<div style="margin:0;font-weight:lighter;background:#f0f4f7;">
<table class="m_6501530908114331344layout" style="font-family:Helvetica,Arial,sans-serif;background:#f0f4f7;width:100%">
<tbody><tr>
<td>
<table cellspacing="0" class="m_6501530908114331344page-container" width="505" align="middle" style="font-family:Helvetica,Arial,sans-serif;border-spacing:0;background-color:#fff;max-width:505px!important;display:block!important;margin:25px auto!important;clear:both!important">
<tbody><tr class="m_6501530908114331344header" style="background-color:rgba(218, 23, 23, 0.03);">
<td class="m_6501530908114331344row" style="border-left:1px solid #e7e7e7;border-right:1px solid #e7e7e7;border:none;padding:20px 35px">
<img alt="lasaioffice" height="80" width="300" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png" class="CToWUd">
</td>
</tr>
<tr class="m_6501530908114331344subject" style="background-color:#fff">
<td class="m_6501530908114331344primary-message" style="padding:20px 35px 0">
<p style="margin:20px 0;line-height:1.45">Hi google </p>
<h2 class="m_6501530908114331344centered" style="font-size:24px;font-weight:bold;margin:0;margin-bottom:30px;display:block;text-align:center;margin-bottom:0;color:#eb2028;">
Just one more click
</h2>
<table class="m_6501530908114331344email-btn" style="font-family:Helvetica,Arial,sans-serif;background:#eb2028;padding:10px">
<tbody><tr>
<td>
Activate Account
</td>
</tr>
</tbody>
</table>
<p style="margin:20px 0;line-height:1.45">
<strong style="font-weight:bold">
Kind Regards, <br>
The google Team
</strong>
</p>
</td>
</tr>
<tr class="m_6501530908114331344footer" style="color:#7f8da0">
<td class="m_6501530908114331344footer-tagline" style="padding:0 35px">
<hr class="m_6501530908114331344footer-line-break" style="margin-bottom:35px;border:0;border-bottom:1px solid #d3dbe3">
<p class="m_6501530908114331344small" style="font-size:12px">
<strong style="font-weight:bold">
<a style="color:#eb2028;" href="http://google.com">google</a> -
The leading marketplace selling google.
</strong>
</p>
<p class="m_6501530908114331344small" style="font-size:12px">
This account notification was sent to you because you are a google user.
Should you have any questions, you are welcome to email us.
</p>
</td>
</tr>
<tr class="m_6501530908114331344footer" style="color:#7f8da0">
<td class="m_6501530908114331344footer-links" style="padding:20px 35px 45px">
<p class="m_6501530908114331344small" style="font-size:12px">
Copyright © 2017 | google Pty Ltd. All rights reserved.
</p>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<img src="" alt="" width="1" height="1" border="0" style="height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="CToWUd"><div class="yj6qo"></div><div class="adL">
</div></div>';
$header = "From:abc#gmail.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>

image is not embeding in email in php

I am trying to embed the image to the html content of email in php but whenever the email sent it show me broken link of image there. Image is not embeding to the email here is the code
<?php
$to = 'xxxx#xxxx.com';
$subject = "Beautiful HTML Email using PHP by CodexWorld";
$htmlContent = '
<html>
<head>
<title>Welcome to CodexWorld</title>
</head>
<body>
<h1>Thanks you for joining with us!</h1>
<table cellspacing="0" style="border: 2px dashed #FB4314; width: 300px; height: 200px;">
<tr>
<th>Name:</th><td>CodexWorld</td>
</tr>
<tr style="background-color: #e0e0e0;">
<th>Email:</th><td>contact#codexworld.com</td>
</tr>
<tr>
<th>Website:</th><td>www.codexworld.com</td>
</tr>
<tr>
<th>image:</th><td><img src="http://xxxxxxxxxxxxx.com/email/1.png"/></td>
</tr>
</table>
</body>
</html>';
// Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: xxxx#xxxxx.com' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
?>
Please guide me where is I am wrong

PHP email shows html source code in Apple Mail

I am sending an html email and the email shows perfectly fine everywhere except it shows the source code instead of the content in Apple mail.
Here is what I've done:
$to = "";
$subject = "";
$message = '
<html>
<head>
<title>New Inquiry From Quick Contact Form</title>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#F4F3F4">
<tbody>
<tr>
<td style="padding: 15px;">Name:</td>
</tr>
<tr>
<td style="padding: 15px;">Last Name:</td>
</tr>
</tbody>
</table>
</body>
</html>
';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: "<support#mydomain>"' . "\r\n";
mail($to,$subject,$message,$headers);
Note: The HTML in my "message" variable above is just sample. I have a valid HTML in my actual development. I think I am doing something wrong with my headers.
Any help is highly appreciated!
Thanks,
Not sure, it it will help, but I would try to use phpmailer class, as it makes headers more accurate (google for download phpmailer class).
Also you can send e-mails using g-mail smtp server (google for php send email through gmail).

Sending email in HTML [duplicate]

This question already has answers here:
Send HTML in email via PHP
(8 answers)
Closed 7 years ago.
I am setting up a confirmation email script for our customers to receive an email when they complete the online form. I uploaded my script and tested but I received an email with just the raw HTML. I have been looking at some tutorials trying to do this as well. I validated my HTML and I passed all the tests. Is there something that I have to include in my PHP for my body string to be interpreted as HTML?
Here is my script
<?php
//Script for sending a confirmation email
$body = "<!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=UTF-8\" />
<title>Demystifying Email Design</title>
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>
</head>
<body style=\"margin: 0; padding: 0; background-color: #ecf0f1;\">
<table cellpadding=\"0\" cellspacing=\"0\" width=\"60%\" align=\"center\" style=\"border: 1px solid #bdc3c7;\">
<tr bgcolor=\"#3498db\">
<td align=\"center\">
<img alt=\"Logo\" src=\"http://www.****.com/logo-lg.jpg\" style=\"width: 50%; height: auto; padding-top: 5%; padding-bottom: 5%;\" />
</td>
</tr>
<tr bgcolor=\"#ffffff\" align=\"center\">
<td>
<h3 style=\"padding-top: 5%; padding-bottom: 5%;\">Worldwide innovator in flexible liquid packaging</h3>
</td>
</tr>
<tr align=\"center\" bgcolor=\"#ffffff\">
<td>
<h4 style=\"padding-top: 5%; padding-bottom: 5%;\">Thank you for contacting customer service. We've received your sample request; one of our team members will be in contact with you in the very near future. Thanks again for your time and interest.</h4>
</td>
</tr>
</table>
</body>
</html>";
$to = "*******#****.com";
$subject = "Thanks for Reaching out";
if (mail($to,$subject,$body)){
echo "Mail was sent";
} else{
echo "Failed";
}
This is the email I received
You need to also set a header indicating this is HTML, e.g.
// 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);
Source (see Example 3).
Correct code will be:
$to = "*******#****.com";
$subject = "Thanks for Reaching out";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
if (mail($to,$subject,$body,$headers)){
echo "Mail was sent";
}

Formatting my email sent with mail() through PHP, and IIS7

First thing. My code works. I have my SMTP information set up correctly in IIS7's sendmail.ini, and i'm using gmail. What I have is a shopping cart for ordering food.
In my cart.php page, I have the print output pulling in the users choices:
$printoutput .= "<table width='500' border='0' cellspacing='0' cellpadding='0'>
<tr><td> <strong>Order Item # ". ($i+1) ."</strong></td></tr>
<tr><td> ". $product_name . "</td></tr>
<tr><td>$" . $price . ".00</td></tr>
<tr><td>". $displayoptions . "</td></tr></table>
<table height='1%' width='500' border='0' cellspacing='0' cellpadding='0'><tr><td></td></tr></table>";
$i++;
This output looks perfect in a web browser. Later in the code, I use a form to post the $printoutput and name it order. But on my email.php page, I use
session_start();
if(isset($_POST['order'])){
$order = $_POST['order'];
}
and then
mail($email_to, $email_subject, $order, $headers);
well like I said, I can just simply echo $order and it looks perfect in the web browser. But when actually sent as an email, I get an email with ALL of the html mark up with it. I've tried a few things, but nothing is formatting my information the way I want it to. Does anyone know how I can get this to basically format correctly in an email?
I'd like to have my information simply listed like this:
Order Item #
Product Name
Price
Options
But currently the output in the email has a ton of extra spaces, and shows all the HTML.
Any help would be appreciated.
http://www.w3schools.com/Php/func_mail_mail.asp
<?php
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// 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);
?>

Categories