DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   SMTP mail without php.ini (http://www.daniweb.com/forums/thread120664.html)

ryy705 Apr 23rd, 2008 4:41 pm
SMTP mail without php.ini
 
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.

phper Apr 23rd, 2008 4:52 pm
Re: SMTP mail without php.ini
 
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

digital-ether Apr 24th, 2008 9:38 am
Re: SMTP mail without php.ini
 
Quote:

Originally Posted by ryy705 (Post 591719)
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);
}

ryy705 Apr 24th, 2008 11:17 am
Re: SMTP mail without php.ini
 
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.

digital-ether Apr 24th, 2008 12:37 pm
Re: SMTP mail without php.ini
 
Quote:

Originally Posted by ryy705 (Post 592286)
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.


All times are GMT -4. The time now is 4:02 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC