DIGIT-ARC read-only archive · snapshot: July 23, 2026

send mails using php

22 posts · originally from https://geek.digit.in/community/threads/send-mails-using-php.147172/

H
hacklinux Original post #1
Oct 4, 2011 at 10:12 AM
i need to send mails using php.how do i do that?
krishnandu.sarkar
Oct 4, 2011 at 12:18 PM
A simple google search would have revealed that.

Check PHP Mail for the idea.

And for more detail check PHP: mail - Manual
H
Oct 4, 2011 at 12:26 PM
i have read all those but dat doesnt seem to work.
krishnandu.sarkar
Oct 4, 2011 at 12:31 PM
Ya, those works perfectly fine, check Spam mails, as you don't have proper header it may get into spam.
H
Oct 4, 2011 at 12:39 PM
ya checked but doesnt work...any other possibilities?
krishnandu.sarkar
Oct 4, 2011 at 12:45 PM
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??
H
Oct 4, 2011 at 12:47 PM
am using wamp...and should i download any smtp server fr dat?
krishnandu.sarkar
Oct 4, 2011 at 12:51 PM
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.
H
Oct 4, 2011 at 1:04 PM
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
Oct 4, 2011 at 1:09 PM
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.
H
hacklinux #11
Oct 4, 2011 at 1:14 PM
<?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
Oct 4, 2011 at 1:23 PM
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.
H
hacklinux #13
Oct 4, 2011 at 1:46 PM
wat do i give fr smtp_server,auth_username,auth_password?
H
hacklinux #15
Oct 4, 2011 at 1:56 PM
sry m nt undrstanding dat part.wat values am i supposed to give der?
Liverpool_fan
Oct 4, 2011 at 9:34 PM
Use an SMTP relay like JangoSMTP.
H
hacklinux #17
Oct 4, 2011 at 10:05 PM
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
Oct 4, 2011 at 10:14 PM
What kind of error?

Read this guide if it helps.
JangoMail In Progress: Technical Notes: Using the JangoMail API with PHP
H
hacklinux #19
Oct 5, 2011 at 9:36 AM
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.
Liverpool_fan
Oct 5, 2011 at 9:42 AM
Yes of course. Use a proper From E-Mail address. Like your actual E-Mail address.
H
hacklinux #21
Oct 5, 2011 at 9:43 AM
but it worked fine wid frst 4-5 test mails....
skeletor
skeletor #22
Oct 7, 2011 at 3:39 PM
lol..last time when I did this, I preferred using a MTA like exim4.