Sending web based email from server - Shows return address incorrectly

Discussion in 'Programming' started by photosales.co.nz, Jul 7, 2007.

  1. #1
    Hi there people, I have a bit of an issue with sending web based email from my server.

    When it sends, it shows the return address as being

    The information that should be sent is <? echo $setting->support_email; ?> which is - it pulls that info from another area.

    Now when it sends the email, it is not showing the correct return address. Here is the part of the script that is sending the info:

    Code:
    // Pull emails
    $results = mysql_query("SELECT $row FROM $table") or die("Could not pull emails<br>".mysql_error());
    $sent = mysql_num_rows($results);

    if($row = mysql_fetch_assoc($results)) {

    do {


    $email_body = $body;

    $subject = $sub;
    $email_body = str_replace("\\","",$_POST['msg']);
    $email_header = "From: $from\n";
    $email_header .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
    $email_header .= "Return-Path: <$return>\n";
    $email_header .= "Content-type: text/html; charset=iso-8859-1\r\n";

    mail($row["email"], $subject, $email_body, $email_header);

    } while ($row = mysql_fetch_assoc($results));


    } else {
    echo "No Email Addresses to send.";
    } ?> Your message has been sent<br>


    Any thoughts?

    Could it be that the from part in the form that is being submitted looks like:

    New Zealand Photos, NZ Images & Stock Photography <steve@ccmarine.co.nz>

    Could the , be causing problems?
     
    photosales.co.nz, Jul 7, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    try changing this line
    
    $email_header = "From: $from\n";
    
    Code (markup):
    you can even set it yourself if you want instead of doing it dynamically.
    
    $email_header = "From: New Zealand Photo Sales <steve@ccmarine.co.nz>\n";
    
    Code (markup):
     
    ansi, Jul 8, 2007 IP