Jump to content

mail() format being rejected by linux server


jonsamwell

Recommended Posts

The below code works fine to windows mail server but is being rejected by linux servers because of the mail format (so tech support says)

 

The error returned is that the remote server (mail.zippymail.co.uk) drops the connection because the server does not accept the mail in the format i am sending it in.

 

I don't really have a clue what this means or how to change the format of the email. Tech support have just fobbed me off really.

 

Please help

 

Thanks

 

Jon

 

function newCompanyMail($clientName, $username, $password, $recipient, $companyKey, $moduleCost)
{//sends a email to the company admin user containing company details
    $senderemail = 'blah@mydomain.co.uk';
    $sendername = 'Company Name\r\n';
    $mailheader = "From: $senderemail\r\n";
    $mailheader .= "Reply-To: No-Reply\r\n";
    $moduleCost = number_format($moduleCost, 2);

    //email variables
    $subject = 'blah blah :: blah blah:: blah blah - blah blah\r\n';

    //Message
    $message = "blah blah.\r\n\r\n";
    $message .= "blah blah ";
    $message .= "blah blah.\r\n\r\n";
    $message .= "You can login to your account at http://www.mydomain.co.uk/blah/\r\n\r\n";
    $message .= "blah blah.\r\n\r\n";
    $message .= "Your Compnay Account Details:\r\n\r\n";
    $message .= "   Company Name:   $clientName\r\n";
    $message .= "   Admin Username: $username\r\n";
    $message .= "   Admin Password: $password\r\n";
    $message .= "   Company Key:    $companyKey\r\n";
    $message .= "   Module Cost:    £$moduleCost\r\n\r\n";
    $message .= "NOTE: blah blah.\r\n\r\n";
    $message .= "For technical support please email xyz@mydomain.com.\r\n\r\n";
    $message .= "Best regards,\r\n\r\n\r\n";
    $message .= "Company Name\r\n";

    ini_set('sendmail_from', $senderemail);

    mail($recipient, $subject, $message, $mailheader) or die ("Failure");
}

Link to comment
Share on other sites

on a linux server you want to use \n instead of \r\n for your email headers.

 

You also want to comment out     ini_set('sendmail_from', $senderemail); because it does not get used on linux.

 

 

 

Thanks for you help, this is still not working, but works to every other email i have tried bar my web host internal mail servers??

 

Does anyone think this is less of a problem with the code and some internal error my host has??

 

Jon

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.