Jump to content


Photo

How to specify SMTP server/host in script, not .ini


  • Please log in to reply
5 replies to this topic

#1 AndyMatts

AndyMatts
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 March 2006 - 03:57 PM

Greetings, I have a script that sends out an confirmation email. I've been having a problem with "relaying" errors, and was going to go and send user and password authentication to get around this.

Tech support at my hosting service tells me that if I just specify the specific IP address as the SMTP server, I won't have to authenticate.

I don't want to change the php.ini file, however, because I think that would open up our site to use by spammers.

So... I want to write the line that specifies the smtp server when the script runs.

What is the exact syntax for that? I haven't been able to find it in any examples or in the tutorials.

I tried inserting

SMTP='ip#.ip#.ip#.ip#';

near the beginning but that crashes the script.

is it something like $_SMTP or some other structure to that?

#2 kanikilu

kanikilu
  • Members
  • PipPip
  • Member
  • 29 posts
  • LocationDallas, TX

Posted 02 March 2006 - 05:21 PM

Have you tried
ini_set('SMTP', 'ipaddress');
?

#3 AndyMatts

AndyMatts
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 March 2006 - 08:51 PM

[!--quoteo(post=351024:date=Mar 2 2006, 11:21 AM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Mar 2 2006, 11:21 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Have you tried
ini_set('SMTP', 'ipaddress');
?
[/quote]

Nope, not yet. That may be the ticket I'm looking for.

Now, does that just pass the value for use with this email, or does that alter the actual "php.ini" file?

If my concern is someone using my program as a spam hub, would I be advised to change it back to

ini_set('SMTP','localhost');

when I'm done?


#4 AndyMatts

AndyMatts
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 02 March 2006 - 09:09 PM

In any case, I did try it with re-setting the value, and it works great.

Thanks very much for your help, that was exactly what I was looking for.

#5 kanikilu

kanikilu
  • Members
  • PipPip
  • Member
  • 29 posts
  • LocationDallas, TX

Posted 02 March 2006 - 09:26 PM

BTW, it should only set it for that page and not change anything in the php.ini file.

#6 AndyMatts

AndyMatts
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 March 2006 - 09:16 PM

[!--quoteo(post=351115:date=Mar 2 2006, 03:26 PM:name=kanikilu)--][div class=\'quotetop\']QUOTE(kanikilu @ Mar 2 2006, 03:26 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
BTW, it should only set it for that page and not change anything in the php.ini file.
[/quote]

That's good to know. Thanks very much for your help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users