PHP Mail

mail("anyuserid@example.on.ca","My Subject","Line 1\n Line 2\n");
PHPMailer Return True on success and False on failure
By using PHP Mail can be posted from a web page. This is a very common requirement. We can use PHP mail function to send mail to different address. This function is required for sending newsletters, designing feedback forms, signup welcome messages and in many more uses. PHP mail function can be managed from php.ini file.
Here it is how it works.
If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra \n will add extra header with a new line.

If the fifth parameter is supplied, PHP will add this data to the call to the mailer. This is useful when setting the correct Return-Path header when sending mail.

extra heade

mail("nobody@example.com", "the subject", $message,
"From: webmaster@sitename\nReply-To: webmaster@sitename\nXMailer:
PHP/" . phpversion());
With the fifth parameter you can set additional command line parameters to the actual mailer. In the example below we set the correct Return-Path header for sendmail. Normally sendmail will add the X-Authentication-Warning header when using the -f parameter, because the webserver user is probably not a member of the trusted users. To suppress this warning, you should add the web server user to the trusted users in your sendmail config file.

Sending mail with extra headers and setting an additional command line parameter

mail("nobody@aol.com", "the subject", $message,
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVERNAME");
You can also use fairly simple string building techniques to build complex email messages. Sending complex email.

/* recipients */
$recipient .= "friend_name <mary@sitename.com>" . ", " ; //note the comma 
$recipient .= "next_friend <second@anothersite.com>" . ", ";
$recipient .= "onemore@greatsite.net";
/* subject */
$subject = "Checking PHP mail";
/* message */
$message .= "This is a test mail \n";
/* you can add a stock signature */
$message .= "-\r\n"; //Signature delimiter
/* additional header pieces for errors, From cc's, bcc's, etc */
$headers .= "From: The great webmaster \n";
$headers .= "To-Sender: <birthday@sitename.net>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: <name@site.net> \n"; // Return path for errors

/* If you want to send html mail, uncomment the following line */ // $headers .= "Content-Type: text/html; charset=iso-8859-1 \n"; // Mime type $headers .= "cc:userid_someone@sitename.net \n"; // CC to $headers .= "bcc:userid_onemore@sitename.net, someone@example.com \n"; // BCCs to /* and now mail it */ mail($recipient, $subject, $message, $headers);
PHP Mailer class PHPMailer class using SMTP Sending Multiple Mails
Feedback form to post visitor details to site admin by email PHP Ajax feedback form
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    albert gerio

    28-04-2015

    hi friend can i get source code of this mail projects,
    thanks hugs :)
    smo1234

    29-04-2015

    It is already there, copy it.

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer