Sending mail with php

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
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Sending mail with php

Post by nigma »

Hey, I checked out the manual for php at php.net and I was able to read a little on the mail() function. I got everything configed to use proper port and the smtp server. But I could not find out on that page how to actually send mail. Could anyone give me example of what sending to variables would look like?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

there are examples at http://www.php.net/manual/en/function.m ... te]Example 1. Sending mail.

mail("joecool@example.com", "My Subject", "Line 1\nLine 2\nLine 3");[/quote]
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

I use something similar to below.

Code: Select all

<?php
// email person
$recipient = $email;  // this can come from many places.  For me it comes from the persons account.  You can also just type in the email address as well.   Adding comas between the address will allow you more.  Sometimes I will have a hidden value with the email address' typed in already.
$subject = "Your subject;
$message = "Thank you for viewing my online documents for Php and Mysql.  If you would like to see something up here then please ask me.";
$extra = "From: you@yourdomain";
mail ($recipient,$subject,$message,$extra); 

?>
Post Reply