SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2012
    Location
    N.Ireland
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chaning output of php mail message

    Hi I'm implenting a basic php validation mail function. In the process.php file where all the magic works I'd like to change this;

    PHP Code:
    if(!$error)
    {
    $mail mail(WEBMASTER_EMAIL$subject,
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."Message: ".$message."\r\n");

    if(
    $mail)
    {
    echo 
    'OK';

    To somthing like;
    PHP Code:
    if(!$error)
    {
    $mail mail($email$subject 'Comment from website',
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."Message: ".$message."\r\n");

    if(
    $mail)
    {
    echo 
    'OK';

    So when I get the mail I want the person who enters their $email address in the 'From:' line rather than the mail server address and I want the subject: line to be static "Comments from website"....

    Any help much appriciated.

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Try this code:
    PHP Code:
    $email = isset($_POST['field_name']) ? $_POST['field_name'] : '';
    if(!
    $error) {
    $mail mail(WEBMASTER_EMAIL'Comments from website',
         
    "From: ".$name." <".$email.">\r\n"
        
    ."Reply-To: ".$email."\r\n"
        
    ."Message: ".$message."\r\n");

    if(
    $mail) { echo 'OK'; } 
    The 'field_name' is the name of the form field in which the user adds its e-mail address.
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •