Skip to content Skip to sidebar Skip to footer

Send Email Regardless Php.ini Settings

I have some real problems with my host, as they didn't set up the php.ini for email sending and now my app would need to send emails with token code and etc. I work with only few u

Solution 1:

You could try using something like PHPMailer. According to their github:

Used by many open-source projects: Drupal, SugarCRM, Yii, Joomla! and many more

This is a mailer class which you can use instead of mail() - allowing you to configure it without changing your php.ini.

If sendmail is available to you, you can do something like the following:

<?phprequire'../PHPMailerAutoload.php';

//Create a new PHPMailer instance$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport$mail->isSendmail();
//Set who the message is to be sent from$mail->setFrom('from@example.com', 'First Last');
//Set an alternative reply-to address$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to$mail->addAddress('whoto@example.com', 'John Doe');
//Set the subject line$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,//convert HTML into a basic plain-text alternative body$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually$mail->AltBody = 'This is a plain-text message body';
//Attach an image file$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errorsif (!$mail->send()) {
    echo"Mailer Error: " . $mail->ErrorInfo;
} else {
    echo"Message sent!";
}

Otherwise you will require an SMTP server which you can use it with.

Solution 2:

PHPmailer now on github https://github.com/Synchro/PHPMailer it is used by many apps that need to be installed on systems but don't have the email libs installed. It makes a connection using tcp/ip sockets and takes care of the low level protocols for you.

Solution 3:

It seems there is a problem in your mailer server. So instead of researching too much. why should not jump on using gmail smtp, as your application is in development mode you can use gmail smtp for now without stopping your work.

http://lifehacker.com/111166/how-to-use-gmail-as-your-smtp-server

I prefer to do so :)

Post a Comment for "Send Email Regardless Php.ini Settings"