Jump to content

mail() function

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
17 replies to this topic

#1
Guest_Jaan_*

Guest_Jaan_*
  • Guests
You can send emails with this function.
It's syntax is very simple

mail(to,subject,message,headers,parameters)

example:

mail("myemail@host.xxx", "Hello!", "Here will be my message", "From: Jaan");

parameters is optional, it specifies an additional parameter to the sendmail program.

Here's little script with what you can send emails:

form.html

<form action="send.php" method="post">
Your name: <input type="text" name="name" size="30"><br>
Email:<input type="text" name="email" size="30"><br>
Subject: <input type="text" name="subject" size="30"><br>
<textarea cols="60" rows="10" name="message"></textarea><br>
<input type="submit" value="Send">
</form>

send.php

<?php

$email = $_REQUEST['email'];
$name = $_REQUEST['name'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];

if(empty($email) or empty($name) or empty($subject) or empty($message)){
die("Please fill your form correctly!"); 
}else{
mail($email, $subject, $message, "From: $name");
echo "Thank you!";
}

?>

Have fun!

Attached Files



#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
So this is something like to send email anonymously?

#3
Guest_Jaan_*

Guest_Jaan_*
  • Guests
yup i guess.. but it still shows where this email came.. so

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Nice, it's nice to see people take advantage of the empty() function, 99% of the cases i see, people use !isset()

#5
Guest_Jaan_*

Guest_Jaan_*
  • Guests
lol i use empty() because i remember when i learned php then this function was very simple to remember.. because empty is much simple word than isset ;)

#6
xtraze

xtraze

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
I know of a Mobile service provider which let's users to recieve SMS/MMS via E-mail.
It goes like this, when the phone number (local) is 999999999 the e-mail will be 99999999@sms.mobitel.lk
9999999@mms.mobitel.lk

Now for the Q.s

#Can I add a attachment feature for this.

#Can I only ask the users for the phone number and Add "@xxx.mobitel.lk" at the end automatically

#Can I let users to choose whether SMS/MMS via a combo menu

This can lead to a free SMS service dudes, I made one for SMS myself, but still cannot do the combobox, and attachment. Have No Idea of how to use it, Really complicated.

#7
sunnetmedia

sunnetmedia

    Newbie

  • Members
  • Pip
  • 1 posts
....

#8
chathucj

chathucj

    Newbie

  • Members
  • Pip
  • 1 posts
how can i customize this one to sen SMS to Srilanka's MOBITEL network?

#9
DoubleN

DoubleN

    Newbie

  • Members
  • Pip
  • 1 posts

xtraze said:

I know of a Mobile service provider which let's users to recieve SMS/MMS via E-mail.
It goes like this, when the phone number (local) is 999999999 the e-mail will be 99999999@sms.mobitel.lk
9999999@mms.mobitel.lk

Now for the Q.s

#Can I add a attachment feature for this.

#Can I only ask the users for the phone number and Add "@xxx.mobitel.lk" at the end automatically

#Can I let users to choose whether SMS/MMS via a combo menu

This can lead to a free SMS service dudes, I made one for SMS myself, but still cannot do the combobox, and attachment. Have No Idea of how to use it, Really complicated.

yep u can do it
try to send 9471*******@sms.mobitel.lk
but....u'll be able to send only 120 character in Message

#10
Guest_Jaan_*

Guest_Jaan_*
  • Guests
umm.. maybe 160?

#11
djfree

djfree

    Newbie

  • Members
  • Pip
  • 1 posts
thx

#12
mittalmak

mittalmak

    Newbie

  • Members
  • PipPip
  • 10 posts
is there any way if the mail() functionj is not active...... in a website....