Jump to content

alternative to mail() ?


jasonc

Recommended Posts

i desperately need an alternative to the PHP mail() command, my host keeps on disabling the nobody@ feature on the servers and this means no one gets emails with signup details or lost passwords reset requests!!

 

is there another way surely there must be another way that does not require the mail() command?

 

please advise

 

thanks in advance for your help

Link to comment
Share on other sites

Have you tried the -f option? I've had this work for me in the past. This is straight from php.net:

 

additional_parameters  (optional)

 

    The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

 

    The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

 

Link to comment
Share on other sites

<?php

$smtp = fsockopen( 'smtp.mail.com', 25, $no, $str, 5 );
fwrite( $smtp, "MAIL FROM: <email@domain.com>\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "RCPT TO: <email@domain.com>\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "DATA\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "Subject: Hello\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "Subject: email@domain.com\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "MIME-Version: 1.0\r\n\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "Body Text Here\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, ".\r\n" ) or die( fread( $smtp, 10000 ) );
fwrite( $smtp, "QUIT\r\n" ) or die( fread( $smtp, 10000 ) );

?>

 

Screw PHPMailer...

Link to comment
Share on other sites

The PEAR extension libray offers solutions

 

A very painful alternative is the IMAP library which is not very will documented.  I have used it with limited success in the past, but you are really on your own for most of it since php.net and the web have very few and weak tutorials.

Link to comment
Share on other sites

All methods (including mail(), phpmailer class, fsockopen()) at some point connect to the sending mail server and the information they provide must satisfy what the sending mail server is configured to accept and for a receiving mail server to accept any email, the email must satisfy what the receiving mail server is configured to accept.

 

If you are attempting to leave off a From: address or use a nonexistent address nobody@yourdomain.com, then you are going to need to setup an actual mail box on the sending mail server to use in the From: address.

Link to comment
Share on other sites

i desperately need an alternative to the PHP mail() command, my host keeps on disabling the nobody@ feature on the servers and this means no one gets emails with signup details or lost passwords reset requests!!

 

Finding a good host is not easy, because every one of them seems to have issues, but if this is a big issue to you, I'd think it might be easier to just move to another host. Also, if you call the host and tell them you are thinking about leaving because of this issue, they may be able to move you to a server that is managed differently. I did this with the host I use. When I signed up for an account, they said that sendmail wasn't available, but I had a choice to move to a different server that had sendmail enabled if I really needed to. I don't really need sendmail, but it's just so easy that I made sure they put me on the sendmail enabled server.

Link to comment
Share on other sites

All methods (including mail(), phpmailer class, fsockopen()) at some point connect to the sending mail server and the information they provide must satisfy what the sending mail server is configured to accept and for a receiving mail server to accept any email, the email must satisfy what the receiving mail server is configured to accept.

 

If you are attempting to leave off a From: address or use a nonexistent address nobody@yourdomain.com, then you are going to need to setup an actual mail box on the sending mail server to use in the From: address.

 

oh i use the from field?

 

and the email address in the from exists.

i have been told i should also check out

'Zend_Mail'

 

any views on this ?

Link to comment
Share on other sites

All the various mailer classes and frameworks do the same thing, but with different features and functions built in. If you are doing something fundamentally wrong for your mail server, you can try them all and they are not going to solve anything. Until you describe what the problem is and provide details about what you are doing that does not work, you are not going to get a solution.

Link to comment
Share on other sites

All methods (including mail(), phpmailer class, fsockopen()) at some point connect to the sending mail server and the information they provide must satisfy what the sending mail server is configured to accept and for a receiving mail server to accept any email, the email must satisfy what the receiving mail server is configured to accept.

 

If you are attempting to leave off a From: address or use a nonexistent address nobody@yourdomain.com, then you are going to need to setup an actual mail box on the sending mail server to use in the From: address.

 

The host has no control of a remote mail server...don't exactly know what you're saying.

 

I still think fsockopen is the way to go, had to do something similar to this with another guy's server that didn't have the mail function or imap_ library and fsockopen worked.

Link to comment
Share on other sites

Since the OP has not bothered to explain what exactly the problem is or show what he is doing, the problem could be at any point, including the receiving mail server discarding the email because of something like the From: email address containing a domain that does not match the sending mail server or some other misuse or malformed aspect to the email.

 

The various mailer classes use fsockopen() and exchange SMTP commands directly with the mail server when they are configured to use an smtp mail server.

Link to comment
Share on other sites

Since the OP has not bothered to explain what exactly the problem is or show what he is doing, the problem could be at any point, including the receiving mail server discarding the email because of something like the From: email address containing a domain that does not match the sending mail server or some other misuse or malformed aspect to the email.

 

The various mailer classes use fsockopen() and exchange SMTP commands directly with the mail server when they are configured to use an smtp mail server.

 

Fair enough.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.