Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    95
    Thanks
    7
    Thanked 0 Times in 0 Posts

    $headers .= 'From: '.$name.'<'.$from.'>'."\n";

    Trying to send email to all users in db all works fine but it wont use my name or email. when i check inbox they are all from ****@cpanel42.uk2.net, i need it to look like,

    From: My Name - my@email.co.uk

    PHP Code:
    <?php

    $dbhost 
    '';
    $dbuser '';
    $dbpass '';

    $conn mysql_connect($dbhost$dbuser$dbpass) or die                      ('Error connecting to mysql');

    mysql_select_db(""$conn);

    $name "My Name";
    $from "my@email.co.uk";
    $headers "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1rn";
    $headers .= 'From: '.$name.'<'.$from.'>'."\n";
    $subject "Subject";
    $body $message;

    $query mysql_query("SELECT email FROM users") or die(mysql_error());

    while(list(
    $email) = mysql_fetch_row($query)) {
     
    mail($email$subject$body$headers);
    }

    ?>
    I can get it to use just my email if i add "-f my@email.co.uk" but i really want to add my name

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    \r\n isn't correct in either from or content-type. Correct those first and try again.
    i seem to recall seeing a similar issue to this in the past, but I can't recall what the cause or solution was. I think that one was pegged directly on the host.

  • Users who have thanked Fou-Lu for this post:

    Nealec (01-10-2012)

  • #3
    New Coder
    Join Date
    Feb 2011
    Posts
    95
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    \r\n isn't correct in either from or content-type. Correct those first and try again.
    i seem to recall seeing a similar issue to this in the past, but I can't recall what the cause or solution was. I think that one was pegged directly on the host.
    Worked great after fixing them, thankyou very much. Though there is one small thing, it says the email is From: My Name - my@email.co.uk which is perfect but straight after that it says via cpanel42.uk2.net. is there any way to get rid of that? Its no big deal if there isnt i just thought it would look tidier without it.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    If you delimited the from with the \r\n and it still appends that, then no aside from adding an alternate configuration to the mailer in the additional parameters or writing your own smtp. Check with your host as well, some of them like using custom forms instead of direct mailers (which IMO is a company I would never deal with).

  • #5
    New Coder
    Join Date
    Feb 2011
    Posts
    95
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Ok ill try that or i can deal with it for now, thanks for all the help.


  •  

    Posting Permissions

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