/    Sign up×
Community /Pin to ProfileBookmark

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
[email][email protected][/email]

I want to change this address to something my personal, like , [email][email protected][/email]

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

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@pactor21Oct 10.2011 — [CODE]<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;

mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>[/CODE]
Copy linkTweet thisAlerts:
@Praty888authorOct 10.2011 — 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.
Copy linkTweet thisAlerts:
@pactor21Oct 11.2011 — 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.
Copy linkTweet thisAlerts:
@Praty888authorOct 12.2011 — Below is the form processing file.
[code=php]<?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'."rn";
$mail_header .= 'Content-Type: text/html; charset = iso-8859-1'."rn";
$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');
?>[/code]


After processing below content

form message: My website's requirement is...

after email i get: My website[COLOR="Yellow"]'[/COLOR]s requirement is...
Copy linkTweet thisAlerts:
@pactor21Oct 12.2011 — Try this for $message.
[CODE]$message=stripslashes($message);[/CODE]
Copy linkTweet thisAlerts:
@Praty888authorOct 13.2011 — 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.
Copy linkTweet thisAlerts:
@pactor21Oct 14.2011 — Try this then.
[CODE]$message=nl2br(stripslashes($message));[/CODE]
Copy linkTweet thisAlerts:
@Praty888authorOct 14.2011 — 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[/QUOTE]

    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
    [/CODE]

    You can mark I have given a white space before Praty which is not reflected in the result.
    ×

    Success!

    Help @Praty888 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.11,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...