Jump to content

PHP Mailing


gsmith

Recommended Posts

I've been sending e-mail within PHP scripts using the following basic commands:

$to="someemailaddress";$message="message";$subject="subject";mail($to, $subject, $message);

However, now I have an array with several e-mail addresses in it. Using that same format won't send my mail. How can I send an e-mail using multiple e-mail addresses inside an array instead of one defined variable?

Link to comment
Share on other sites

If you want to send the exact same message to all of them, then according to RFC #WTF-123, you can use a semicolon-delimited list of addresses. You can join the array on semicolons, and voila:

$email_list = "";if (count($to_addresses) > 1)  $email_list = implode(";", $to_addresses);elseif (count($to_addresses) > 0)  $email_list = $to_addresses[0];if ($email_list != "")  mail($email_list, $subject, $message);

Link to comment
Share on other sites

haha. Thanks.It actually isn't spam though - I promise. :)It's for a website that has a user log-in system and the e-mails are being sent from a user to a selected user(s), hence the potential for an array of several e-mail addresses.

Link to comment
Share on other sites

I've heard a lot about PEAR, but I've never actually met anyone that uses it. I have seen some good code made with it though, I forgot which application I was looking at though. But it was definately easy to make changes to it, the package does a good job of abstracting out a lot of the little details.

Link to comment
Share on other sites

  • 1 month later...

Also, when writing FormMail scripts, make sure to remember about theMail Injection Volnerabilitymost of the time, you can fix this problem by having your host install mod_security for you,but that doesn't always work. so I tend to use the eregi example for checking for a valid emailaddress. That way, a spammer cannot use your form for its lame advertising and mass mailing.This will also prevent your web hosting provider from suspending your accountwhich in my view is really stupid since all the hosting provder really has to do is install mod_security to prevent this from happening,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...