User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,555 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 652 | Replies: 4
Reply
Join Date: Jul 2006
Posts: 103
Reputation: ryy705 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
ryy705 ryy705 is offline Offline
Junior Poster

SMTP mail without php.ini

  #1  
Apr 23rd, 2008
Hello,
Is there a way to send smtp mail without messing with php.ini file? A lot of server don't seem to give access to that. Thanks in advance.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Location: South Wales
Posts: 159
Reputation: phper is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
phper's Avatar
phper phper is offline Offline
Junior Poster

Re: SMTP mail without php.ini

  #2  
Apr 23rd, 2008
You can use the php_flag option in a .htaccess file.

This is only if the server allows this option.

Do a google search on php_flag
If you find my post useful please add to my reputation!! Thanks!

ajtrichards web solutions
http://www.ajtrichards.co.uk
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: SMTP mail without php.ini

  #3  
Apr 24th, 2008
Originally Posted by ryy705 View Post
Hello,
Is there a way to send smtp mail without messing with php.ini file? A lot of server don't seem to give access to that. Thanks in advance.


You can use a PHP mailing library such as SwiftMailer, http://www.swiftmailer.org/.

http://www.swiftmailer.org/wikidocs/v3/smtpauth

Here is an example of sending email to SMTP server via telnet:
http://www.yuki-onna.co.uk/email/smtp.html

You can do the same with PHP using a function such as fsockopen, fopen etc.

eg:
$fp = fsockopen('mail.example.com', 25);
if ($fp) {

// send you smtp command
fputs($fp, 'SMTP command goes here... ');
// make sure it worked
fgets($fp);

// send more smtp commands... etc. 

// close the tcp connection
fclose($fp);
}
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Join Date: Jul 2006
Posts: 103
Reputation: ryy705 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
ryy705 ryy705 is offline Offline
Junior Poster

Re: SMTP mail without php.ini

  #4  
Apr 24th, 2008
Thanks for all your responses. My goal is to write websites which are portable. Unfortunately some server don't allow the flag option and few horrible servers don't allow telnet access. Swiftmail looks promising. I will check it out. Hopefully the installation will not require me change anything in the php.ini files.
Reply With Quote  
Join Date: Sep 2005
Posts: 611
Reputation: digital-ether will become famous soon enough digital-ether will become famous soon enough 
Rep Power: 5
Solved Threads: 38
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Re: SMTP mail without php.ini

  #5  
Apr 24th, 2008
Originally Posted by ryy705 View Post
Thanks for all your responses. My goal is to write websites which are portable. Unfortunately some server don't allow the flag option and few horrible servers don't allow telnet access. Swiftmail looks promising. I will check it out. Hopefully the installation will not require me change anything in the php.ini files.


I think the most support you'd get for sending mail via PHP in production environments is to connect directly to the SMTP server via TCP. This would depend solely on the allow_url_fopen configuration in PHP.ini. This is most likely enabled on any production PHP server.
If it isn't, you could resort to CURL, which would be the alternative given by the hosting if they have turned off allow_url_fopen for some reason.

If you want secure mail transfer, then you'd need to have OpenSSL installed so your TCP connection can be done over TLS or SSL. Some SMTP server may not allow plain-text transfer, which makes TLS support a requirement.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC