Jump to content

PHP sent mail is in junk in outlook


Jaya

Recommended Posts

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.';
}
}
?>
        

 

Link to comment
Share on other sites

// 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 by JacoSwanepoel
Link to comment
Share on other sites

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 by mac_gyver
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 

 

Link to comment
Share on other sites

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.

  • Thanks 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.