Mail() problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
f1nutter
Forum Contributor
Posts: 125
Joined: Wed Jun 05, 2002 12:08 pm
Location: London

Mail() problems

Post by f1nutter »

Folks,

I am setting up a form to add links to my web-site. When the user has submitted their details I want to send an automatic e-mail, thanking them, or something.

This is what I have so far, and it works hunky-dory.

Code: Select all

<?php
$contact = "f1nutter2000@yahoo.co.uk";
$to = "<$contact>";
$subject = "Thank-you";
$message = "Thanks for adding your link";
$from = "From: Links <links@f1nutter.com>";

mail($to, $subject, $message, $from);
?>
I can't sent e-mails more than one at a time ($to = "<$contact1>, <$contact2>") as I would like to send myself one when the link is added, and also for future applications. Although not important, why does the friendly "to" name not work.

My php.ini settings are:

STMP= mail.btinternet.com
sendmail_from=

I am using PHP 4.2.0 with Win98 and PWS 4.0

Thanks.
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

$to = "<$contact>";
Change that to: $to = "$contact";
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post by sam »

To expand on what fatal said. You do not need to include the <>'s in the address when sending mail from php. It is only used to attach an email to a know name in e-mail client programs... If you are going to use it, add a username in front to it and inclose the whole thing with "s...

Code: Select all

$to = ""Sam McKone <sam@evilwalrus.com>"";
Cheers Sam
f1nutter
Forum Contributor
Posts: 125
Joined: Wed Jun 05, 2002 12:08 pm
Location: London

Post by f1nutter »

Thanks Sam and Fatal,

Thats cleared up a lot. The PHP manual still needs a little working on!

F1 Nutter.
Post Reply