www.webdeveloper.com
Results 1 to 9 of 9

Thread: email from remote hosting server

Hybrid View

  1. #1

    email from remote hosting server

    Dear all this is my first post in a forum. So I don't know if I am post at the right place or not.
    Anyway my problem is regarding email. I send the form fields through the mail() function. But the email reaches from someone named
    ipg.abhisekasahucom@boscgi3402.eigbox.net

    I want to change this address to something my personal, like , me@mydomain.com

    I am sure it can be done but dont know how to do this. Please reply soon.

  2. #2
    Join Date
    Sep 2009
    Posts
    159

    This might work for you.

    Code:
    <?php
         $to = "someone@example.com";
         $subject = "Test mail";
         $message = "Hello! This is a simple email message.";
         $from = "someonelse@example.com";
         $headers = "From:" . $from;
    
         mail($to,$subject,$message,$headers);
         echo "Mail Sent.";
    ?>

  3. #3

    The main problem resolved

    Thanks a lot Pactor21 for your solution. My main problem resolved. Now the 2nd problem is the mail which I get is little deformed. The special characters like ', '' are followed by an \ .
    Why am I not getting the mail as it is? Another thing is the new line i.e when I press enter button in the text area it is not shown in the mail.

  4. #4
    Join Date
    Sep 2009
    Posts
    159
    In order to determine what's causing the problem, I need to see your PHP file sending emails.

    You might be encoding the message body variable with some function.

  5. #5
    Below is the form processing file.
    PHP Code:
    <?php
    $name 
    $_POST[name];
    $email $_POST[email];
    $subject $_POST[subject];
    $company $_POST[company];
    $message $_POST[message];
    $from "email id from which the email would be sent";

    $mail_header 'MIME-Version: 1.0'."\r\n";
    $mail_header .= 'Content-Type: text/html; charset = iso-8859-1'."\r\n";
    $mail_header .= 'From:'.$from;
    $to 'email id to be sent';
    $email_subject $subject;
    $email_message $message;

    mail($to,$email_subject,$email_message,$mail_header);

    header('Location:services.php');
    ?>
    After processing below content
    form message: My website's requirement is...

    after email i get: My website\'s requirement is...

  6. #6
    Join Date
    Sep 2009
    Posts
    159
    Try this for $message.
    Code:
    $message=stripslashes($message);

  7. #7
    Thanks pactor for your help. the stripslashes() worked very well. But the problem is when someone presses the "enter" key then in the mail a new line should start, but in my case it's not creating a new line.

  8. #8
    Join Date
    Sep 2009
    Posts
    159
    Try this then.
    Code:
    $message=nl2br(stripslashes($message));

  9. #9
    yes. the nl2br() worked. But why such type of problems occur with mail() ? Till now following problems have been encountered.
    1. The quotes are not escaped rather a backward slash "\" is encountered. This is rectified by adding stripslashes(). One thing I should mention that i am not getting the "\"s while testing on my local machine, wamp server. But in Ipage's server I am getting the "\".

    2. The new line character or the <br> is not executed. This is rectified by using nl2br(). Though nl2br() is not the perfect one. When following text is sent through the form mail
    hello,
    Praty, This's my new proj.
    Here I'll develop different web projects.


    Thanks & Regards
    P's P
    After using nl2br() I am getting following result
    Code:
    hello,
    Praty, This's my new proj.
    Here I'll develop different web projects.
    
    
    Thanks & Regards
    P's P
    You can mark I have given a white space before Praty which is not reflected in the result.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles