How can I send email with PHP?
Before you can send email with Perl or PHP, you'll need to complete the PHP/Perl Mail Setup.
To begin setting up PHP/Perl mail, click the PHP/Perl Mail link on the Create & Update or Index tabs of your Web Hosting Control Panel.
Create & Update Tab: PHP/Perl Mail Link
- You can customize the email address that users will see when you send them a message (for example, "From: firstname.lastname@example.org").
- You will need to indicate the path to the Yahoo mail program, Sendmail, in the Perl or PHP script. The path to Sendmail is /usr/sbin/sendmail.
- There is a limit of 250 emails per day sent to recipients outside your domain.
- The "From:" address used in your script must contain your domain name.
- If the "From:" field is omitted, your default account email address will be used.
Here is a sample Perl script you can use to send email. You will need to specify the "to" and "from" address.
Notice that the subject line in the sample script ends with two \n characters. These characters are required to separate the email header from the email body with a blank line. If you're not seeing the body of your email, double-check to make sure these characters are present.
print "Content-type: text/html\n\n";
$to='MAIL ADDRESS TO SEND TO';
open(MAIL, "|/usr/sbin/sendmail -t");
## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Yahoo \n";
## START HTML content
A message has been sent from $from to $to";
## END HTML CONTENT