Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 04-10-2011, 10:12 AM   #1 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Exclamation send mails using php


i need to send mails using php.how do i do that?
hacklinux is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 04-10-2011, 12:18 PM   #2 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

A simple google search would have revealed that.

Check PHP Mail for the idea.

And for more detail check PHP: mail - Manual
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 12:26 PM   #3 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

i have read all those but dat doesnt seem to work.
hacklinux is offline   Reply With Quote
Old 04-10-2011, 12:31 PM   #4 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

Ya, those works perfectly fine, check Spam mails, as you don't have proper header it may get into spam.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 12:39 PM   #5 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

ya checked but doesnt work...any other possibilities?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 12:45 PM   #6 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

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??
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 12:47 PM   #7 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

am using wamp...and should i download any smtp server fr dat?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 12:51 PM   #8 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

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.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 01:04 PM   #9 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

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?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 01:09 PM   #10 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

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.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 01:14 PM   #11 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

<?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.";
?>
hacklinux is offline   Reply With Quote
Old 04-10-2011, 01:23 PM   #12 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

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.
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 01:46 PM   #13 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

wat do i give fr smtp_server,auth_username,auth_password?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 01:55 PM   #14 (permalink)
Simply a DIGITian
 
krishnandu.sarkar's Avatar
 
Join Date: Nov 2007
Location: Kolkata
Posts: 2,942
Default Re: send mails using php

Yup.

10chars
__________________
  • Read The Forum RULES First.
  • Before PM'ing Or Asking Any Questions To Any Mod Read The FAQ's
  • Before Starting A New Thread Read The STICKY THREADS First
  • Before Participating In Bazaar Section Read The BAZAAR RULES
krishnandu.sarkar is online now   Reply With Quote
Old 04-10-2011, 01:56 PM   #15 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

sry m nt undrstanding dat part.wat values am i supposed to give der?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 09:34 PM   #16 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: send mails using php

Use an SMTP relay like JangoSMTP.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 04-10-2011, 10:05 PM   #17 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

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?
hacklinux is offline   Reply With Quote
Old 04-10-2011, 10:14 PM   #18 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: send mails using php

What kind of error?

Read this guide if it helps.
JangoMail In Progress: Technical Notes: Using the JangoMail API with PHP
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 05-10-2011, 09:36 AM   #19 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

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.
hacklinux is offline   Reply With Quote
Old 05-10-2011, 09:42 AM   #20 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: send mails using php

Yes of course. Use a proper From E-Mail address. Like your actual E-Mail address.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 05-10-2011, 09:43 AM   #21 (permalink)
learn more share more....
 
hacklinux's Avatar
 
Join Date: May 2011
Posts: 36
Default Re: send mails using php

but it worked fine wid frst 4-5 test mails....
hacklinux is offline   Reply With Quote
Old 07-10-2011, 03:39 PM   #22 (permalink)
ico
.
 
ico's Avatar
 
Join Date: Jun 2007
Location: New Delhi
Posts: 8,944
Default Re: send mails using php

lol..last time when I did this, I preferred using a MTA like exim4.
__________________
.
ico is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:35 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2