SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2003
    Location
    Brisbane, Australia
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP mail Function and Gmail

    Hi All

    I am using the php mail function and have this header:

    $headers = "From: My Business Name \r\n";
    $headers .= "Reply-To: website@$domainname\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

    It all seems to work fine in Outlook and it says the they email is from me however with the same email in Gmail (Unkown Sender)

    Any ideas on how to get around this?

    Thanks

    mrmbarnes

  2. #2
    SitePoint Enthusiast jakub_polak's Avatar
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    this code should do the job, just change the value of $to variable to your actual gmail address so you can test it.

    PHP Code:
    $domainname 'example.com';

    $to      'your.gmail.account@gmail.com';
    $subject 'the subject';
    $message 'hello';
    $headers 'From: "My Business Name" <my.business@email.com>' "\r\n" .
        
    'Reply-To: website@$domainname' "\r\n" .
        
    'X-Mailer: PHP/' phpversion(). "\r\n".
        
    'Content-type: text/html; charset=iso-8859-1' "\r\n";

    mail($to$subject$message$headers); 

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2003
    Location
    Brisbane, Australia
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey

    Thanks for that but I'm not actually using a gmail.com account. We are using Google Apps so we log into gmail with our company domain... I have 3 totally separate Google Apps accounts. All with different domain logins & none with gmail.com.

    Any other ideas?

    Thanks

    mrmbarnes

  4. #4
    SitePoint Enthusiast jakub_polak's Avatar
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I beleive that it should work with the Google Apps account as well. Have you tried to code?

  5. #5
    SitePoint Addict
    Join Date
    May 2005
    Location
    Tauranga, New Zealand
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried to add the email as an approved sender in Google apps?
    http://www.automatem.co.nz
    Websites, On-line Software and everything Internet
    Follow on Twitter | Connect on LinkedIn | Read on Posterous


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
  •