want my email sent using SMTP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • speedmaster
    New Member
    • Oct 2007
    • 3

    want my email sent using SMTP

    hi,
    my problem is that i have created contact form in this i filled all my fields sends it to the others email address, the mail is recieved by the person but the senders name is not displaying in the reciptent's mail so here is code i have used it plz have a look an give the possible solution.
    code is:
    [php]
    <?php
    $name = trim($_POST['name']);
    $email = trim($_POST['email']);
    $friendname = trim($_POST['friendname']);
    $friendemail = trim($_POST['friendemail']);
    $message = trim($_POST['msg']);

    $mail_to= $friendemail;
    $mail_from= $email;
    $mail_sub= "Paul Taylor Dance Company";
    $mail_mesg = $message;

    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "/r/n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "/r/n";

    // Additional headers
    //$headers .= 'To: '.$friendname.' '.$friendemail . "\r\n";
    $headers .= 'From: '.$name.' '.$email . "/r/n";
    $headers .= 'Reply-To: '.$name.' '.$email . "/r/n";

    mail($mail_to,$ mail_sub,$mail_ mesg,$headers);
    ?>
    [/php]
    Last edited by ronverdonk; Oct 10 '07, 08:07 AM. Reason: code tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Welcome to TSDN!

    Next time, read the Posting Guidelines before you show code in a post. Especially the part about enclosing code with in code tags.

    It could be possible that the newline/carriage return definitions cause this problem. You specify them with backward slashes, as in "\r\n".

    Ronald

    Comment

    • speedmaster
      New Member
      • Oct 2007
      • 3

      #3
      hi ,
      thaks for ur rply, i tried that but that doesnt work but again i changed my code using SMTP with phpmailer which is as:


      [CODE=php] <?php
      $name = trim($_POST['name']);
      $email = trim($_POST['email']);
      $friendname = trim($_POST['friendname']);
      $friendemail = trim($_POST['friendemail']);
      $message = trim($_POST['msg']);
      if(!class_exist s('PHPMailer'))
      {
      require("ptdc/phpmailer-1.73/phpmailer" . '/class.phpmailer .php');
      }

      $mail = new PHPMailer();

      $mail->From = $email;
      $mail->FromName = $name;
      $mail->AddAddress($fr iendemail, $friendname);
      // Fill in Username and Password for servers requiring authentication
      //$mail->Username = $smtp_username;
      //$mail->Password = $smtp_password;

      // SMTP server name
      $mail->Host = "<removed>" ;
      $mail->Mailer = "smtp";

      $mail->Subject = "Paul Taylor Dance Company"; ;
      $mail->Body = $message ;

      if(!$mail->Send()) $results = 'Error message';
      else $results = 'Success message';
      You can read the documentation, advanced


      ?>[/CODE]
      Last edited by Atli; Oct 10 '07, 03:36 PM. Reason: Removed host name.

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        try like this.

        [PHP]$headers .= 'From: '.$name.' <'.$email.'>' . "\r\n";[/PHP]

        Second reminder: Do not miss the code tags when posting source codes.

        Comment

        Working...