#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    10
    Rep Power
    0

    Email is not working


    Hello

    it runs correctly even i recieve message "Mail send completed"

    but, I dont recieve any email(s).

    Please help me out

    regards,


    <?php


    $host = "mail.ayyooo.com";
    $username = "username";
    $password = "password";

    $strTo = test@ayyooo.com'; //$_POST["txtTo"];
    $strSubject ='CV details From ' . $_POST["email0"];
    $strMessage = 'First Name: ' . $_POST["firstName"] . "\n\n";
    $strMessage .= 'Middle Name: ' . $_POST["middleName"] . "\n\n";
    $strMessage .= 'Last Name: ' . $_POST["lastName"] . "\n\n";
    $strMessage .= 'Applying for Position: ' . $_POST["position"] . "\n\n";
    $strMessage .= 'Town: ' . $_POST["town"] . "\n\n";
    $strMessage .= 'City: ' . $_POST["City"] . "\n\n";
    $strMessage .= 'Country: ' . $_POST["Country"] . "\n\n";
    $strMessage .= 'Telephone: ' . $_POST["tel"] . "\n\n";
    $strMessage .= 'Email: ' . $_POST["email0"] . "\n\n";
    $strMessage .= 'Year of Exp.: ' . $_POST["exp"] . "\n\n";
    $strMessage .= 'Comments: ' . $_POST["comments"] . "\n\n";

    //nl2br($_POST["txtDescription"]);

    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));

    $strHeader = "";
    $strHeader .= "From: ".$_POST["firstName"]."<".$_POST["email0"].">\nReply-To: ".$_POST["email0"]."";

    $strHeader .= "MIME-Version: 1.0\n";
    $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
    $strHeader .= "This is a multi-part message in MIME format.\n";

    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-type: text/html; charset=utf-8\n";
    $strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
    $strHeader .= $strMessage."\n\n";

    //*** Attachment ***//
    if($_FILES["fileAttach"]["name"] != "")
    {
    $strFilesName = $_FILES["fileAttach"]["name"];
    $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
    $strHeader .= "Content-Transfer-Encoding: base64\n";
    $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
    $strHeader .= $strContent."\n\n";
    }

    $flgSend = @mail($strTo,$strSubject,null,$strHeader);
    // @ = No Show Error //

    if($flgSend)
    {
    echo "Mail sent completed.";
    }
    else
    {
    echo "Cannot send mail.";
    }
    ?>
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Oxford, United Kingdom
    Posts
    40
    Rep Power
    2
    You've clearly copied that code from the net. If you hadn't, you wouldn't be suppressing errors:
    PHP Code:
    $flgSend = @mail($strTo,$strSubject,null,$strHeader);
     
    // @ = No Show Error // 
    Remove the '@'. Then see if you get any errors/warnings.

    Are you testing this on a local server (XAMP, MAMP , etc)? If so, that's your problem. Try it on a remote server or use Mercury.

    You should also use a class that can make things a lot easier for this kind of task. PHPMailer perhaps?

    EDIT: Also, please wrap your PHP code in [ PHP ][ /PHP ] (ignore spaces) tags.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    10
    Rep Power
    0
    hello,

    I have already tried with that,

    but Same result, actually it doesnt attach file.

    Regards,
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Oxford, United Kingdom
    Posts
    40
    Rep Power
    2
    Okay, so with PHPMailer, you fail to attach the file correctly? But does the email actually arrive? If so, post the code using PHPMailer. I'll have a look xD

IMN logo majestic logo threadwatch logo seochat tools logo