Jaya Posted May 18, 2022 Share Posted May 18, 2022 I am try o send PHP mail through forms mail is getting in inbox in Gmail and yahoo except outlook and Hotmail. In outlook and Hotmail mail is received in junk but i need to got in inbox. Code part is below. <?php if(isset($_POST['submit'])) { //post function is used to get html form data $to=$_POST['to']; $subject = $_POST['subject']; $text_editor=$_POST['text_editor']; $from = 'abc@gmail.com'; $sign=$_REQUEST['sign']; $sname='<div><b>'.$sign.'</b><br>Resource Manager, SHIRO Technologies Llc<br>IT, ITeS & Automation Services - Resource Management<br><b>P:</b> 469-941-9530<br><a href="https://www.chandru@shirotechnologies.com"><b>E:</b> chandru@shirotechnologies.com</a><br><b>a:</b> 5080 Specutrum Drive Addison TX 75001<br><a href="https://www.shirotechnologies.com"><b>w:</b> shirotechnologies.com</a></div>'; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; $headers[] .= "Organization: Sender Organization"; $headers[] .= "X-Priority: 3"; $headers[] .= "X-Mailer: PHP". phpversion(); // Additional headers //$headers[] = 'To:'.$to; $headers[] = 'From:'.$from; $headers[] = 'Cc: abc@gmail.com'; // Mail it $message ='<b>'.$text_editor.'<b><br> <p>'.$sname.'</p>'; if(mail($to, $subject, $message, implode("\r\n", $headers),"-f$from")){ echo 'Your mail has been sent successfully.'; echo "\n\n".$message; } else{ echo 'Unable to send email. Please try again.'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/ Share on other sites More sharing options...
JacoSwanepoel Posted May 18, 2022 Share Posted May 18, 2022 (edited) // SEND EMAIL TO CUSTOMER $to = $CustomerEmail; $subject = 'Subject Here'; $message .= 'Text Here"<br>'; $message .= 'Text Here<br>'; $message .= 'Have a fantastic day.'; $headers = "From: Company Sales Portal <no-reply@yourdomain.com>\r\n"; $headers .= "Reply-To: Company SA Sales Portal Administrator <admin@yourdomain.com>\r\n"; $headers .= "Content-type: text/html\r\n"; mail($to, $subject, $message, $headers); Ive been using this and never gad any problems with outlook or gmail. Maybe itll help Edited May 18, 2022 by JacoSwanepoel Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596415 Share on other sites More sharing options...
Jaya Posted May 18, 2022 Author Share Posted May 18, 2022 I try our code, i get mail in inbox in Gmail but not in outlook i got in junk folder. Is any restriction in outlook that sends PHP mail() to junk? Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596416 Share on other sites More sharing options...
mac_gyver Posted May 18, 2022 Share Posted May 18, 2022 (edited) you are listing the From: email address @gmal.com. is your web hosting actually using a gmail mail server to send these emails? edit: if you are not sending the emails from a mail server that can be related back to the From: mail domain, different receiving mail servers will mark the mail as junk and may not even process it. for the code that @JacoSwanepoel posted, the from email address is probably related to the mail server that is being used to send the emails. Edited May 18, 2022 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596419 Share on other sites More sharing options...
Jaya Posted May 19, 2022 Author Share Posted May 19, 2022 mac_gyver-I am using web hosting server to send mail there also facing same issue. But it happens only in outlook and Hotmail. Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596437 Share on other sites More sharing options...
mac_gyver Posted May 19, 2022 Share Posted May 19, 2022 15 hours ago, mac_gyver said: different receiving mail servers ^^^ this means that some receiving mail servers will and some won't consider a bad From: domain enough to categorize any particular email as junk. based on the only information you have given us, it's likely that for the emails you are sending, gmail and yahoo didn't flag them as junk, whereas outlook/hotmail does. 38 minutes ago, Jaya said: web hosting server my question was are you sending the emails using a gmail mail server? can you directly answer this question? Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596439 Share on other sites More sharing options...
Jaya Posted May 19, 2022 Author Share Posted May 19, 2022 32 minutes ago, mac_gyver said: gmail and yahoo didn't flag them as junk, whereas outlook/hotmail does. yes 32 minutes ago, mac_gyver said: gmail mail server No i am using PHP mail function only not gmail mail server Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596441 Share on other sites More sharing options...
mac_gyver Posted May 19, 2022 Share Posted May 19, 2022 25 minutes ago, Jaya said: PHP mail function only the php mail function is NOT a mail server. it provides a way for php to interface with the sending mail server at your web hosting, typically though a sendmail binary program on the host system. on your web hosting, there is a mail server that is being used as the sending mail server. since it is unlikely that you are using google cloud web hosting (you probably would have mentioned this) and/or a gmail mail server (this requires smtp authentication, which the php mail() function does not support), the From: mail domain MUST correspond to the domain of your web hosting. you cannot just makeup and put in an @gmail.com email address. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596444 Share on other sites More sharing options...
Jaya Posted May 19, 2022 Author Share Posted May 19, 2022 Thank you so much for help now i got to know about where problem is Quote Link to comment https://forums.phpfreaks.com/topic/314809-php-sent-mail-is-in-junk-in-outlook/#findComment-1596446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.