/    Sign up×
Community /Pin to ProfileBookmark

php email :

tutorial

[url]http://www.w3schools.com/PHP/php_mail.asp[/url]

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

is this correct ? see they have $headers = “From: $from” in the above ….i think this is wrong because the whole thing is under quote.

whereas i was thinking something like this ….$headers = “From:”. $from;
// used concat operator

what say ?
Edit/Delete Message

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarSep 16.2009 — Double quotes parse variables included in them, there is no need to concat them.
Copy linkTweet thisAlerts:
@jimr451Sep 16.2009 — Yep, either way should be fine.
Copy linkTweet thisAlerts:
@thewebhostingdiSep 16.2009 — Hi,

Yes, both the ways it can be work. But you have to check that your hosting company supports PHP Mail function as due server security reasons hosting companies does not support it.
Copy linkTweet thisAlerts:
@cofactorauthorSep 17.2009 — thanks .... glad to know this concept ..... this was very much helpful.
×

Success!

Help @cofactor 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.7,
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,
)...