Jump to content


can i not use mail() function to send emails to addresses online?

  • Please log in to reply
3 replies to this topic

#1 raza.shahzad

  • Members
  • PipPip
  • Member
  • 23 posts

Posted 13 August 2006 - 01:43 AM

Hello every one,

// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('caffinated@example.com', 'My Subject', $message);

is there any problem in the above code? i used it to try n send email to my account from my windows PC. i have apache 1.3x, PHP 5 n mysql installed with some PHP extensions too. i don't have additional/extra knowledge of sending emails using php scripts. i can do it using smtp using tutorial in the book that i follow but i don't want to get stuck with smtp and other things. i want the send mail to be simple. few lines of codes.

#2 akitchin

  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 13 August 2006 - 03:18 AM

mail() in fact uses the local SMTP server.  are you getting any errors, or is it simply not sending?  if it simply isn't sending, it likely means that a spam filter is blocking it.


$mail_result = mail(stuff here);
echo ($mail_result === FALSE) ? 'mailing worked.' : 'mailing failed.';

#3 Chetan

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 13 August 2006 - 04:15 AM

If you dont get errors and someone else hosts you, put this line in the top to see if you get errors
ini_set('display_errors', '1');
and then use If and else statement to check if there were problems. This is basically with your SMTP
I am a PHP Guru, ask me questions if you want to

#4 redarrow

  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 04:29 AM

the correct way you use \n in the wordwrap ok.

I told you before to look into wordwrap and to use it correctly instead of using copy and past.

Tested and working.
$subject="hi there it's me";
$message="hi there i am redaarow and i like php";

echo " sorry message not sent";
echo "message sent thank you";

Wish i new all about php DAM i will have to learn

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users