send mails using php

krishnandu.sarkar

Simply a DIGITian
Staff member
A simple google search would have revealed that.

Check PHP Mail for the idea.

And for more detail check PHP: mail - Manual
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Are you sure..

Code:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

this program is not working??

It's working fine for me. Are you on Linux or using XAMPP / WAMP??
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Nope, that should work fine. Don't know if there is any issue with WAMP itself.

I'd recommend to try XAMPP once if possible.

Otherwise you can use PHP Pear Mail package for SMTP Mail.
 
OP
H

hacklinux

learn more share more....
ok...ll do dat and let u knw....

in xampp it says "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\mailf.php on line 7"
and on welcome page,der is a "status" option on right.in dat it says "SMTP service deactivated".has dis got to do anythng wid my problem?
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Can you please post your code??

Looks like you are not trying to send mails through internet instead you are trying to send mails through your mail server. Else WTH mail() will try to find SMTP Server on localhost.
 
OP
H

hacklinux

learn more share more....
<?php
$to = "hackpca@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "urpcissafe@gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
 

krishnandu.sarkar

Simply a DIGITian
Staff member
Check How to use sendmail in XAMPP for Windows | i.justrealized and try to add your mail id and password there from which you'd like to send the mail.

BTW that script has worked for me before without all these. Don't know if I'm also missing something.

Ahh figured it out I never did this from desktop. The mails scripts I've developed before was tried and tested on the server itself.

So you need to do that setting in php.ini as you need a authenticating SMTP server from which the mail will be sent. So that's must.

You can do the same in WAMP too.
 
OP
H

hacklinux

learn more share more....
ok i used.but after 4-5 mails i recieved error mails.and can i send mails to any mail id's or to oly the ones which i have added in jangosmtp?
 

Liverpool_fan

Sami Hyypiä, LFC legend
What kind of error?

Read this guide if it helps.
JangoMail In Progress: Technical Notes: Using the JangoMail API with PHP
 
OP
H

hacklinux

learn more share more....
System.Exception: This From Address ("postmaster@localhost") is not
allowed to send through this account.
at JangoEmlRelay.Relay.ProcessFile(Object o)
i get d above error as a mail from jango.
 
Top Bottom