php mail function fail to send email to the domain based emails - php

Please find the code below. This code resides in mydomainname.com
mail("mymail#gmail.com,mymail#mydomainname.com","Testing mail","This is a test mail.","From: mymail#yahoo.com\n");
and
mail("mymail#gmail.com,mymail#mydomainname.com","Testing mail","This is a test mail.","From: mymail#mydomainname.com\n");
I am getting mail to my gmail account (or any yahoo account) for both code, but I am not receiving mail to my webmail or cPanel squirrelmail etc.
I can directly send email to this domain email account
Will the mail server of this domain prevents mails from same domain?
The code worked earlier for the same domainname.
Is it a problem with hosting side? It's a shared server.

Try this
<?php
$to = "admin#gmail.com,mymail#gmail.com";
$subject = "Following Customer Signed Up";
$message = " $username,Customer is signed up with us,<br /><br />
Thanks <br />";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <mymail#mydomainname.com>' . "\r\n";
$mail=mail($to,$subject,$message,$headers);
?>

Related

Gmail not allowing to embed my website link in the email message PHP

$from = "abc#abcwebsite.jp";
$subject="車を売る 問い合わせ";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$vdetails="";
$to="abcmail#gmail.com";
$vdetails.="<table><tr><td>車名: 小林様</td></tr>";
$vdetails.="<tr><td>年:1990 </td></tr>";
$vdetails.="<tr><td>車検:トヨタ</td></tr>";
$vdetails.="<tr><td>KM:1225</td></tr>";
$vdetails.="<tr><td>希望価格:東京蒲田</td></tr>";
$vdetails.="<tr><td>状態コメント:いい</td></tr><tr><td><a href='www.abcwebsite.jp'>www.abcwebsite.jp</a></td></tr></table>";
$body.=$vdetails;
$res=mail($to,$subject,$body,$headers);
if($res){
echo "done...===48776====>";
}
Email code works fine and mail shows in gmail inbox without Anchor tag Link.
But When i try to add a anchor tag link pointing to my domain website url it does not go in Gmail inbox and even not show in spam.
I am using php simple mail not smtp.
Email example:
Please visit the page pointing to abcexample.com

HTML Email - Server Username visible as the sender

I have a website where whenever a order is placed, an email is sent to the customer as well as the admin.
Now the emails are sent to both the customer and Admin, but the header where i specify the email for the addresser does not work. When the email arrives the addresser email is displayed as my username used to login to the Server.
I managed to get the addresser email to work only when the email is NOT formatted with HTML.
I used HTML to format the emails and I use 'mail()' function to send it.
eg.
I have the same code for Admin email but with different variables..
$toCustomer = "customerEmail#gmail.com";
$customerSubject = "Order Confirmation";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\b";
$headers .= 'From: automatedMesage#PleaseDoNotReply' . "\r\n";
$customerTxt =" Order has been placed!!";
mail($toCustomer,$customerSubject,$customerTxt,$headers);

Not receiving mails php mail outlook

I have a problem with the dynamic sending of emails from my site
Customers who have hotmail, live emails do not receive emails (which are in bcc receive emails) as well as some customers with gmail for example receive them but in spam and others in main. The code I use
function emailDemande($email, $nameL){
if (!preg_match("#^[a-z0-9._-]+#(hotmail|live|msn).[a-z]{2,4}$#", $email))
{
$passage_ligne = "\r\n";
}
else
{
$passage_ligne = "\n";
}
$subject = 'Votre demande d\'expérience mystère';
$headers = "From: site <contact#site.com>".$passage_ligne;
$headers .= "Bcc: compte#gmail.com".$passage_ligne;
$headers .= "MIME-Version: 1.0".$passage_ligne;
$headers .= "Content-Type: text/html; charset=UTF-8".$passage_ligne;
$message = '<html><body><p>Cher(e) '.$nameL.',</p></body></html>';mail($email, $subject, $message, $headers);};
I assume you are using Cpanel hosting.
What you want to do is.
Go to Cpanel > MX entry > Select Domain name in question > Select Remote Mail Exchanger.
Thats it.

Email code not working

I'm not sure what happen to my email code as i'm comparing with all the code i able to find online ... when i using localhost, it's work no problem.. and it having the txt file appear in mailoutput folder in xampp.
but when i request my friend to help host to web service.. it cannot work anymore for the code :(
below is my code. (modified from online source)
$subject = "Thanks for Registering." ;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From : email' . "\r\n";
$message = "<html><body>
<p> Thank you to register with Lecture Public Room Book Portal </p>
<p> </p>
<p> In order to activate your account please click the link below:</p>
<p> <a href='link'>Verify Account</a> </p>
<p></p>
<p>Or you may go to the verification page using below link and paste in the verification code. Your verification code is $ver_code.</p>
<p> <a href='link'> Verify page </a> </p>
<p> </p>
<p> Please do not reply to this email has the mailbox isn't monitored.</p>
<p> </p>
<p> </p>
<p><center> - The Webmaster () - </center> </p>
</body></html>";
if(mail($email, $subject, $message, $headers))
{
$_SESSION['type'] = "User";
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Successful register. Please check your email for activate account.')
window.location.href='index.php?user=$username#verify-slide';
</SCRIPT>");
exit();
}
else
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Please try again.')
window.location.href='index.php?signup-slide';
</SCRIPT>");
exit();
}
wish someone could please help me :(
Maybe your hoster restricted access to php mail function. Email him about it. If so you can use Mandrill app.
Please check your error log if it returns some errors.
$headers .= 'From : email' . "\r\n";
Put your email in the email field ( preferably from the same domain email address )
A few bullet points (Assuming that mail() returns true and there are no errors in the error log) :
Does the sender address ("From") belong to a domain on your server? If not, make it so.
Is your server on a blacklist (e.g. check IP on spamhaus.org)? This is a remote possibility with shared hosting.
Are mails filtered by a spam filter? Open an account with a freemailer that has a spam folder and find out. Also, try sending mail to an address without a spam filter.
Do you possibly need the fifth parameter "-f" of mail() to add a sender address? (See mail() command in the PHP manual)
If you have access to log files, check those, of course, as suggested above.
Do you check the "from:" address for possible bounce mails ("Returned to sender")? You can also set up a separate "errors-to" address.
from here
In your current page email recipient is not set like this:
$subject = "Thanks for Registering." ;
$from = "admin#abc.com";
$email = "someone#gmail.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From :' . $from. "\r\n";

sending mail with link and parameter in PHP

I have a strange issue with sending a mail with php, here is my code:
$link = "http://www.somelink/verify.php?id=".$uniqID;
$message ="<html><head></head><body><p>Full Name:".$data[0]." ".$data[1]."</p>";
$message .="<p>Flight Number: ".$data[4]."</p>";
$message .="<p>The Ride: ".$curPlace." to ".$data[5]."</p>";
$message .="<p>Number of Passengers: ".$data[3]."</p>";
$message .="<p>Date:".$data[6]." time:".$data[7]."</p>";
$message .="<p>The price: ".$data[8]."</p>";
$message .="<p>To verify the reservation press this link</p></body></html>";
$headers = 'From: my#email.com' . "\r\n" .'Reply-To: some#email.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "Sensitivity: Personal"."\r\n";
$sent=mail($data[2],"Taxi Reservation",$message, $headers);
if($sent){
echo "Message was sent to ".$data[2];
}
else{
echo "Message was not sent";
}
The problem is with Gmail.If I send it as is, I get the success message, but get nothing in my gmail, but do get in another not gmail account.
BUT!
If I delete a tag from this line:
$message .="<p>To verify the reservation press this link</p></body></html>";
I do get the message in Gmail.So I can't understand what's the problem.
What can couse this problem?
Thank you for your help.
If your email is not arriving at Gmail, but the same code sending the same email is arriving at a different account, I suspect that the problem is that Gmail are seeing your email and classifying it as spam - have you checked to see if it's gone into your spam folder instead of your inbox?
Gmail has a set of rules to identify what they think is spam - presumably, including the link is enough to push your email into the spam category.

Categories