N/APosted on - 11/17/2012
What is the best php code for auto mail? I am planning to make a website system that will accept some emails from a chat mate or a friend. Can I possibly make a php programming code for that kind of scenario?
Waiting for your support, thank you.
What is the best php code for auto mail?
There is a PHP code for Simple E-mail (Text E-mail) and Mail Forms. You can do it and here’s how:
PHP mail has parts that are Required and Optional.
TO: It is required. Refers to the receiver or the one that will receive the e-mail.
SUBJECT: It is required. Refers to the subject or topic of the e-mail. Take note that this parameter can’t contain any newline characters.
MESSAGE: It is required. Refers to the messages that will be sent. Every line must be separated with a “LF(/n)”. Each line must not exceed 70 characters.
HEADERS: It is optional. Refers to additional headers, such as: From, CC, and Bcc. It should not be separated with CRLF (/r/n)
PARAMETERS: It is optional. Refers to any additional parameters to the send mail program.
For PHP Simple E-mail (Text E-mail), this is the simplest way to send an e-mail via PHP.
Here’s an example:
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From:" . $from;
echo "Mail Sent.";
Where the variables are $to, $subject, $message, $from, $headers. These variables are used in the mail () function to send e-mail.
Next is the PHP Mail Form.
Using PHP, you can make a feedback-form on your website.
Here’s an example:
//if "email" is filled out, send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("[email protected]", $subject,
$message, "From:" . $email);
echo "Thank you for using our mail form";
//if "email" is not filled out, display the form
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
<textarea name='message' rows='15' cols='40'>
<input type='submit' />
The above will perform the functions of:
Checking first if the e-mail input field is already filled out.
If it is not yet set; it will output the HTML form.
Otherwise, it will send the email from the form if it is set.
When you press “Submit”, the form will be filled out, the page will reload, it will see that the email input is set, and lastly, it will send the email.
For further information visit the site below. The code is also from the same site.