3 Replies - 542 Views - Last Post: 25 September 2012 - 05:36 AM Rate Topic: -----

#1 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Php Mail sending from wrong server

Posted 25 September 2012 - 04:43 AM

Ok so im trying to send the user a email after they register and the script sends the mail perfectly but its showing the email which it is being sent from is mydomainname/myhosting.com I have searched all over google and have nticed i need to reset the smtp server like so

ini_set(‘sendmail_from’, 'admin@mydomainname.net');


But still shows that the email is commmingfrom mydomainname/myhosting.com

Here is the full coding

$emailSubject = 'Customer Has a Question!';
$body =  'testing ok';
$headers =  'testing ok';
ini_set(‘sendmail_from’, 'admin@mydomainname.net');

mail('totheuser@live.co.uk', $emailSubject, $body, $headers);



i am on a dedicated server so... And don;t want the emails to my users having my web hosting site in the email from....

Is This A Good Question/Topic? 0
  • +

Replies To: Php Mail sending from wrong server

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: Php Mail sending from wrong server

Posted 25 September 2012 - 04:55 AM

sendmail_from is put into the wrong quotation marks. you need the simple, not the typographical ones.
Was This Post Helpful? 0
  • +
  • -

#3 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Re: Php Mail sending from wrong server

Posted 25 September 2012 - 05:10 AM

I have edited it to what you said so like
ini_set('sendmail_from', 'admin@mydomainname.net');

but still didn't work so had another look around google and noticed this works

 $sent = mail('admin@mydomainanem.net', $emailSubject, $body, $headers, "-f webmaster@example.com"); 


when i use that it says the email is from webmaster@example.com which is what i wanted. Would of been easier to set it out of the mail but never mind.
Was This Post Helpful? 1
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: Php Mail sending from wrong server

Posted 25 September 2012 - 05:36 AM

actually, I prefer a mailing library such as SwiftMailer or PHPMailer, since they are way more comfortable to set up and use than the mail() function (think of attachments or return receipts).
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1