Jump to content

Sending HTML E-Mails generated in PHP through Thunderbird/Evolution


rohitbanerjee

Recommended Posts

Hello,

 

New to this forum so appreciate the patience and apologize for any breaking of etiquette.

 

I currently have a PHP script which generates the appropriate HTML headers and body packet and would like to place it in either a Thunderbird outbox so that Thunderbird will handle sending it or put it in the Evolution outbox so Evolution will handle the actual sending of the e-mail. I've scoured the internet looking for an answer and I know it is possible because I wrote a bash script to do it a few years back that I can't find.

 

Would appreciate any insight.

 

Thanks,

 

Link to comment
Share on other sites

You'd need to create some sort of command-line program to do this for you, and call it through PHP. This will probably be OS-specific.

 

This is a VERY odd way to handle this sort of thing. Why are you approaching it this way?

Link to comment
Share on other sites

I have to be honest, this is a very noobish problem but my generic PHP mail function does not seem to be working. I just cut and paste some example code and the mail() function seems to stall for about 60 seconds and then returns true but the mail does not get delivered.

 

I figured a quick and easy hack would be to construct the html email, drop it in a mail client's (like Thunderbird or Evolution) outbox and let the commercial app send the email.

 

Link to comment
Share on other sites

Is this for your own development/testing server, or something in full production?

 

What operating system is the server running on?

 

I'd very strongly suggest against fixing this issue the way you planned.

Link to comment
Share on other sites

The fundamental problem is that I have a godaddy hosted email account, let's call it example@mydomain.com.

 

I would like to write a script which sends emails as example@mydomain.com. To accomplish this, I modified my php.ini file to the following:

SMTP = smtpout.secureserver.net

sendmail_path = "/usr/sbin/sendmail -t"

 

When I call the mail() function, it returns True but does not deliver the email.

 

I was able to link example@mydomain.com with Thunderbird and Evolution and I figured that if I could find an easy way to drop the constructed email messages into the outboxes, every time the app refreshed internally, my mails would get sent out.

 

I am running Linux Ubuntu 10.04.

Link to comment
Share on other sites

You likely need to authenticate with the SMTP server in order to send the mails, unless you are using linux then php mail() and sendmail() won't pass SMTP authentication information.  you would need to use something else (or set up a linux VM) that said your hosted site should be linux and as such if you set the authentication settings in that it should work.

Link to comment
Share on other sites

If your developing on Linux just install the ssmtp package. It is a sendmail drop in replacement that is simple to configure and allows you to use a remote smtp server 9such as Gmail) to send mail. This is awesome for testing purposes.

Link to comment
Share on other sites

So ssmpt works beautifully -- thanks for the suggestion. I am curious, I read the man page and it seems as though you have to enter messages via stdin. Is it possible to pass in the From, To, Subject, Body in a file or by printing it to stdin?

 

I am also trying the PEAR-Mail package and running into a pretty basic error -- can't find Mail.php. The standard include paths are /usr/share/php and /usr/share/php/PEAR. I looked and Mail.php is not located there. I ran pear install Mail-1.2.0 successfully so not sure what the issue is. Anything simple I forgot?

Link to comment
Share on other sites

<?php
require_once 'Mail/Mail.php';

$from = "example@domain.com";
$to = "recipient@domain.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "smtpout.secureserver.net:80";
$username = "example@domain.com";
$password = "password";

$headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
$smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => true,
     'username' => $username,
     'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
?>

 

I ran pear install Net_SMTP and it is up to date (v1.6.1).

 

I get the following error:

 

Warning:  require_once(Mail/Mail.php): failed to open stream: No such file or directory in /script_location/mail_test.php on line 2

PHP Fatal error:  require_once(): Failed opening required 'Mail/Mail.php' (include_path='.:/usr/share/php:/usr/share/php/PEAR') in /script_location/mail_test.php on line 2

 

I have actually checked the include paths and there is no Mail.php or Mail directory. I uninstalled and re-installed Mail-1.2.0 as well as Net_SMTP and got the following output:

 

downloading Mail-1.2.0.tgz ...

Starting to download Mail-1.2.0.tgz (23,214 bytes)

........done: 23,214 bytes

install ok: channel://pear.php.net/Mail-1.2.0

 

downloading Net_SMTP-1.6.1.tgz ...

Starting to download Net_SMTP-1.6.1.tgz (13,164 bytes)

.....done: 13,164 bytes

install ok: channel://pear.php.net/Net_SMTP-1.6.1

 

Do I have to do anything else to "install" Mail? Thanks for any help

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.