/    Sign up×
Community /Pin to ProfileBookmark

Problems Sending Email

Okay, just for a bit of a preface so you know what’s going on. I’m learning PHP and am now trying to implement what I know thus far into a simple form handler. Yes, I know that there are probably millions of these in different scripts, but how would I learn other than doing it myself? The only problem is that the script here won’t send the email.

[code=php]<?PHP
$body = “Registration FormnnName: ” . $name. “nnEmail Address: ” . $from . “nnAddress: ” . $address . “n” . $zip . “nnPhone Number: ” . $phNumber . “nnBaptized Family Members: ” . $family . “nMember Status: ” . $status;
mail(“[email protected]”,”Registration Form”,$body,”From:” . $from . “n”);
?>[/code]

Now, I’ve already used echo (“”) to make sure that I’ve set $body correctly, and it works fine. However, this script won’t email anything at all. I don’t get any emails from it (no, I wasn’t stupid enough to put mydomain.com, in the script it is my website’s address, and the mailbox is fully functional). My first question is, Do I have the proper syntax? My second question is, Do I have to configure my server at all, or do I need to include the path to my sendmail program, like with the premade CGI script I currently use? Please help, I’m thoroughly confused.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryApr 09.2004 — Assuming PHP was set up correctly, it should have the path to sendmail in your php.ini file - look for the sendmail_path configuration option. Also note the requirements discussed in the [url=http://www.php.net/mail]manual[/url].

Adam
Copy linkTweet thisAlerts:
@MstrBobauthorApr 09.2004 — Thank you very much. On your advice, I asked the tech help at my service provider, and apparently I have to include a sendmail flag in my mail() fuction so that it looks like this:

[code=php]mail($sendto, $subject, $body, $header, "-f [email][email protected][/email]");[/code]

Is this normal or common?
Copy linkTweet thisAlerts:
@AdamGundryApr 11.2004 — I don't think it's particularly common or uncommon, it just depends on the ISP's server setup. I've never had to use it (but then I've only worked with about 4-5 different PHP setups).

I'm glad you got it working.

Adam

P.S. Happy Easer.
×

Success!

Help @MstrBob 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...