dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: mail() not sending emails thru Yahoo Small Biz Hosting

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    mail() not sending emails thru Yahoo Small Biz Hosting

    Hello Everyone! I'm new here.

    I don't know specifically where to post this concern. My problem is either
    my PHP code mail() or Yahoo Small Biz Hosting.

    I have a form that when you click Submit, it calls a php file and will send it
    to email. I uploaded the files in Yahoo Small Biz Hosting, and when I use the
    form, I am not able to receive any email from the form even the spam folder,
    nothing's there.

    BUT when I upload the files to another hosting I am able to receive the email
    it goes to my spam folder.

    Here's my code:

    Code:
    $emailSubject = 'Subject';
    $webMaster = 'myemail@www.com';
    
    
    $NameField = $_POST['Name'];
    $EmailField = $_POST['Email'];
    $UnitField = $_POST['Unit'];
    $PVCField = $_POST['pvc'];
    $ExtSAField = $_POST['extsa'];
    $RailingsField = $_POST['railings'];
    $GlassField = $_POST['glass'];
    $ExtPField = $_POST['extp'];
    $ExtBTField = $_POST['extbt'];
    $GraniteCTField = $_POST['gct'];
    $InteriorC1Field = $_POST['ic1'];
    $KitchenCLField = $_POST['kcl'];
    $InteriorC2Field = $_POST['ic2'];
    $GeneralFField = $_POST['gf'];
    $StairsField = $_POST['stairs'];
    $WoodBField = $_POST['wb'];
    $TNBField = $_POST['tnb'];
    
    
    $DateTime= date("F j, Y, g:i a");
    
    
    $body = <<<EOD
    <b>Name:</b> $NameField<br>
    <b>Unit:</b> $UnitField<br>
    <b>Date:</b> $DateTime<br><hr><br>
    <b>&bull; EXTERIOR</b><br><br>
    <b>PVC Frame:</b>&nbsp;$PVCField<br>
    <b>Exterior Stone Accent:</b>&nbsp;$ExtSAField<br>
    <b>Railings:</b>&nbsp;$RailingsField<br>
    <b>Glass:</b>&nbsp;$GlassField<br>
    <b>Exterior Paint:</b>&nbsp;$ExtPField<br>
    <b>Exterior Balcony Tiles60x60:</b>&nbsp;$ExtBTField<br>
    <br><br>
    <b>&bull; INTERIOR</b><br><br>
    <b>Granite Counter Tops:</b>&nbsp;$GraniteCTField<br>
    <b>Interior Colors:</b>&nbsp;$InteriorC1Field<br>
    <b>Kitchen Cabinet Laminate:</b>&nbsp;$KitchenCLField<br>
    <b>Interior Colors:</b>&nbsp;$InteriorC2Field<br>
    <b>General Flooring:</b>&nbsp;$GeneralFField<br>
    <b>Stairs:</b>&nbsp;$StairsField<br>
    <b>Wood Baseboards:</b>&nbsp;$WoodBField<br>
    <b>Toilet and Bath:</b>&nbsp;$TNBField<br>
    
    
    EOD;
    
    
    $headers = "From: $EmailField\r\n";
    $headers .= "Content-type:text/html\r\n";
    
    
    if(mail($webMaster,$emailSubject,$body,$headers));
    {
    header("Location: index.html");
    }
    ------
    It worked when I omitted the variable $headers. But
    it sent me the output on my email with the HTML tags...

    How to resolve the $headers issue?

    THIS ONE WORKS BUT ON EMAIL IT HAS HTML tags:
    Code:
    mail('myemail@www.com','Subject',$body);
    THIS DOESN'T WORK:
    Code:
    mail('myemail@www.com','Subject',$body, $headers);
    Hope someone will help me with this.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: mail() not sending emails thru Yahoo Small Biz Hosting

    If you want HTML content then your header is incomplete. Use the following.

    Code:
    $headers = 'MIME-Version: 1.0' . "\n";
    $headers .= 'From: ' . $from . "\n";
    $headers .= 'Reply-To: ' . $from . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Oct 2009
    Posts
    2

    Resolved Re: mail() not sending emails thru Yahoo Small Biz Hosting

    Thanks PeejAvery!

    But I've already tried combinations of the header, and I found out that it's the problem
    on the Hosting that rejects the 'From' field. Yahoo Host checks if the address belongs to
    the website domain (passing a variable on 'From' will reject it,so you must specify a fix email
    address) and you can just display the USER's/VISITOR's Email as Reply-To.

    Here is the code that resolves the issue:

    Code:
    $headers = 'Content-type: text/html; charset=iso-8859-1' . "\n\n" .
    'From: YourEmail@YourSite.com' . "\n\n" . 'Reply-To: $EmailField' . "\n\n";
    Hope this will be a help to others. =)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)