Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Outgoing Email with PHP
Topic Started: Jun 24 2009, 01:21 PM (246 Views)
Will
Member Avatar


I'm starting to become a little more familar with PHP. I do have a question for you verteran coders out there though: Is there any easy way to tell a PHP script who an e-mail is being sent from? I can tell the code where the email is being sent TO, but somehow altering the outgoing address is eluding me.

Any help would be gorgeous.

:ryan:
Offline Profile Quote Post Goto Top
 
ElementalAlchemist
Member Avatar
ERROR: This title does not exist.
[ *  *  *  *  * ]
Let me dig up the old contact form I used to use for AlchemyIRC.

ElementalAlchemist digs. Please be patient during this process. It may take anywhere from one minute to a while.

It appears I have this, which sends the mail if something was sent.
Code:
 
if ($sent=="yes") {
echo "<h1>Your message was sent successfully.</h1>";
$email = filter_var($_REQUEST['email'], FILTER_SANITIZE_EMAIL);
$message = filter_var($_REQUEST['message'], FILTER_SANITIZE_STRING);
$to = filter_var($_REQUEST['dest'], FILTER_SANITIZE_EMAIL);
$subject = filter_var($_REQUEST['subject'], FILTER_SANITIZE_STRING);
mail( $to, $subject,
$message, "From: $email" );
}
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar


http://nl2.php.net/manual/en/function.mail.php

See the third and fourth example. They include a bunch of headers you'll find usefull.

There are also a bunch of usefull user notes.

If you need a more powerfull1 and flexible solution and PEAR is installed, try PEAR::Mail. (If you don't have PEAR installed, ask your hosting provider. If they won't install it, you can download all the packages and then upload them yourself, although thats a bit more work.)

1: Well, technically its not more powerfull. But its much easier to do the more advanced things, so, err, easier power.
Online Profile Quote Post Goto Top
 
Will
Member Avatar


Problem resolved. Thanks for your help dudes. ^_^
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Programming and Scripting Chat · Next Topic »
Add Reply