I just got this module working on Drupal 6. I uploaded the patches here. The code definitely needs to be reviewed...I'm no expert at this stuff, and could have very easily overlooked some stuff. I was having problems with using the ssl/tls feature, as seen in some of the bug reports others have filed, but that may just be a problem with my php setup...I've never tried using the encryption before today, so I'm not sure.

Enjoy!

Comments

preventingchaos’s picture

Title: Here are some patches for updating module for Drupal 6 » Drupal 6 patches for SMTP module

changing issue title

Starbuck’s picture

I'd really like to enable Drupal v6 to send email via SMTP from a designated server with authentication. I hope this is the right module and will see if I can get it going with this patch. Thanks!!!!

lilou’s picture

subscribe

Starbuck’s picture

Installed couple days ago and it seems like the patch for v6 is working like a champ. Congrats. Didn't look at the code.

realistknight’s picture

What are the + - next to lines? Is that some sort of commenting or does your editor add those?

preventingchaos’s picture

Drupal documentation about Patches should provide a good explanation for you: http://drupal.org/patch

wildtang3nt’s picture

This patch worked fine for me, and I am also using Gmail's SMTP server without problems.

oadaeh’s picture

@gcopenhaver, I hate to do this to you, Greg, but I'm looking at including a couple of other patches [1] & [2] (and a possible code style clean up) before I do the version 6 update.

[1] http://drupal.org/node/224601 (which may end up being 2 or 3 patches)
[2] http://drupal.org/node/224849 (which may not affect the v6 upgrade too much)

preventingchaos’s picture

Not a problem...When I started seeing the other patches come up, I was expecting that the v6 upgrade would be postponed until the new fixes/changes could be taken care of.

optalgin’s picture

Fair and square :-)
I'm looking forward the D6 update so I can unite my site and my gmail account :-)
Thanks

creativepragmatic’s picture

When I attempt this with the smtp.info patch, I get the following error:

Hunk #1 FAILED at 2.

When I attempt this with the smtp.module patch, I get the following errors:

Hunk #1 FAILED at 1.
Hunk #5 FAILED at 135
Hunk #6 succeeded at 241 (offset 3 lines).
Hunk #7 succeeded at 287 (offset 3 lines).

Has anybody else had the same problem?

oadaeh’s picture

@creativepragmatic: your errors are probably because the module was updated since the patch was created. I am planning on a couple of more changes to the module before attempting to try to get this patch to work. In the mean time, you can probably apply those specific parts that failed by hand.

creativepragmatic’s picture

Thanks for responding. Since it's my first attempt at patching this way, I thought I was doing something wrong.

lilou’s picture

StatusFileSize
new17.95 KB

I create a new patch from the HEAD, based from gcopenhaver work.

intropedro’s picture

The patch don't work me:

>> cvs -d ":pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib" checkout -r HEAD contributions/modules/smtp
  cvs checkout: Updating contributions/modules/smtp
  U contributions/modules/smtp/INSTALL.txt
  U contributions/modules/smtp/README.txt
  U contributions/modules/smtp/smtp.info
  U contributions/modules/smtp/smtp.module
>> cp smtp-d5-to-d6.patch contributions/modules/smtp/
>> cd contributions/modules/smtp/
>> patch < smtp-d5-to-d6.patch
  (Stripping trailing CRs from patch.)
  patching file INSTALL.txt
  (Stripping trailing CRs from patch.)
  patching file README.txt
  (Stripping trailing CRs from patch.)
  patching file smtp.info
  (Stripping trailing CRs from patch.)
  patching file smtp.module

I have upload the module by ftp and I have enable the module, but then I get this:

Parse error: syntax error, unexpected T_ELSE in /home3/intropedro/modules/smtp/smtp.module on line 211
sammorgan’s picture

Does anyone have the patched files here, im having a nightmare doing this?

THanks in advance

Sam

deadmalc’s picture

I need this working for drupal 6 finish, I've tried the patch by lilou and it is completely stuffed for the current HEAD.
I'll take a look at this tomorrow and see if I can roll a tar ball and place it somewhere for you all

deadmalc’s picture

StatusFileSize
new19.75 KB

I've managed to get the patch working for 6, but I managed to find a problem.
The module causes my saslauthd to segfault, kind of bizarre - but this seems to be a problem with the current module for 5.x
so I've worked around the problem and don't need the smtp module.

Also TLS didn't seem to work too well, but that may be my test server setup

Cheers

Malcolm

mbull’s picture

Hi

Can anyone tell me how to apply the patch?

deadmalc’s picture

You can use the tar ball I uploaded....
otherwise, using the patch command, and applying it to cvs head - looking for errors and correcting them....

Cheers,

Malcolm

spydmobile’s picture

the files this patch affects have been removed from CVS so we are back to not having a solution here...

oadaeh’s picture

@spydmobile: no files have been removed from the project. You are probably applying it incorrectly.

@spydmobile and mbull: see the Applying patches Drupal Handbook page for information on how to apply a patch.

spydmobile’s picture

I was referring to the source code files that these patches are supposed to run on. They have been removed from CVS. why dont you release your patch for the current SMTP module instead. I read all about patching. For me,This is not about how to patch, but WHAT to patch. the patches fail on the current versions of the SMTP module, therefore, I am suggesting a new patch meant for the current version since the version you patched originally has been removed from CVS.
Thanks and keep up the good work.
Franco

mbull’s picture

I have applied the smtp and smtp info patches, but still get a red cross next to the module in 'modules' view.

I take it I can't apply settings with it like this?

randya’s picture

Assigned: Unassigned » randya
Status: Needs review » Patch (to be ported)

Since I am new, (brand new), to Drupal I am looking for directions, (detailed), on what and how to patch the latest version on Drupal on Windows 20003 Server, PHP 5+ and mySQL with the Mail Server. I don't see it in the manual and am a bit lost here on the postings, since there are several. Any direction or help would be appreciated. I am quite sure that the username and password are all that is lacking in the mail connection. I hate to start hacking code when I don't know quite how it is put together.

By the way, it does look a bit like something is missing in the PHP.INI since that is where the pointer for SMTP connection seems to be. However, when I look up mail in PHP they have no direct method for username and password, that I can see. So is all this discussion about how to bypass that limitation and use something else?

Thanks,
Randy

optalgin’s picture

I used the `already patched` files posted in comment #18
It works fine for me without any special configurations in php.ini
(I configured openssl for gmail though)

I have same configuration as you, win;drupal6;php5;mysql

You don't need to hack code, you just need to fill in the username
and password in the admin pages of this module..

spydmobile’s picture

I also used files posted to comment #18 as a temporary fix! Thanks Optalgin and deadmalc!
Franco

rboy’s picture

I don't know why, but I found that the patch which is attached in #18 doesn't work at drupal 6.2.
After installation of this patched module (installation itself seemed to be fine), I couldn't find "SMTP support" link anywhere, and also couldn't enter admin/settings/smtp (access denied), so there's nothing but uninstalling it...

I've not changed any other settings after installation of drupal 6.2 core system.
All I did after installation of core system was installing this patched SMTP module.

In case of 6.0/6.1, there was no problem.

preventingchaos’s picture

Drupal 6.2 has two API changes, one of them related to hook_menu(), which is probably causing the problem with Patch #18. Adding an 'access arguments' key/value to the associative array in the smtp_menu() function will likely fix the problem.

preventingchaos’s picture

StatusFileSize
new16.24 KB

Here's an updated smtp.module based on Patch #18 with the new changes to work with Drupal 6.2. You'll need the core = 6.x line in the smtp.info file for Drupal to allow you to enable it.

rboy’s picture

Many thanks!
I tried the #30's patch , and found it worked fine not only with normal SMTP (port 25) but also over SSL (via gmail) on Drupal 6.2!

lucacerone’s picture

Assigned: randya » lucacerone
Category: feature » support
Priority: Normal » Critical
Status: Patch (to be ported) » Closed (won't fix)

Hi rboy, I'm new to Drupal, I followed the guide about applying patches but I couldn't succed in using Smtp with Drupal 6.2.
I tried to make it works this way:
1) downloaded the tar archive in post #18 and unzipped it in DrupalRoot/modules/
2) downloaded the patch files in post #30 and saved it in DrupalRoot/modules/smtp
3) gone by terminal in smtp dir and tried to apply the patch with the following command:
patch -b < smtp.module_2.patch

I get the following messages:
patching file smtp.module
Hunk #1 FAILED at 18.
Hunk #2 FAILED at 38.
Hunk #3 FAILED at 76.
Hunk #4 FAILED at 90.
Hunk #5 FAILED at 106.
Hunk #6 FAILED at 121.
Hunk #7 FAILED at 136.
Hunk #8 FAILED at 332.
Hunk #9 FAILED at 533.
Hunk #10 FAILED at 986.
Hunk #11 succeeded at 1192 with fuzz 2 (offset 92 lines).
Hunk #12 FAILED at 1259.
Hunk #13 succeeded at 1305 with fuzz 2 (offset 107 lines).
Hunk #14 FAILED at 1376.
Hunk #15 FAILED at 1419.
Hunk #16 FAILED at 3013.
14 out of 16 hunks FAILED -- saving rejects to file smtp.module.rej

Can you, or anybody else tell me where I'm wrong?
Thank you very much in advance to all of you!
Cheers -Luca

preventingchaos’s picture

Assigned: lucacerone » Unassigned
Category: support » feature
Priority: Critical » Normal
Status: Closed (won't fix) » Needs work

The patch that I submitted in #30 was against the HEAD branch of the smtp module. In order to make the patch work correctly, you first need to either download smtp-5.x-1.x-dev.tar.gz or if using CVS:

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout contributions/modules/smtp

(assuming no other changes have been committed since I created the patch...check here for changes)

lucacerone’s picture

Thanks for your help, I'm in office and I can't try your advices now!
Just to be sure I can quickly install it tonight: is it so easy as to download the v5 smtp Module and Apply the patch in the same way I already tried?
If so It's great!
Thank you very much again!

dkreviews’s picture

StatusFileSize
new19.86 KB

EDIT: NM, none of the options above have worked for me using Drupal 6.2 until I downloaded this

https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle&kb...

Problem solved!

Hey,

This doesn't seem to work. I am running patch with the files from your link http://ftp.drupal.org/files/projects/smtp-5.x-1.x-dev.tar.gz and post #30 and I get bunch of HUnk Failed. Can you please tell me what the instructions are?

Here is what I did:
1. Downloaded from #30
2. Downloaded http://ftp.drupal.org/files/projects/smtp-5.x-1.x-dev.tar.gz
3. Saved them in the same folder
4. run patch {file} {patch} --verbose --binary (XP environment)

or am I doing something wrong?

Hunk #1 FAILED at 18.
Hunk #2 succeeded at 35 (offset -3 lines).
Hunk #3 FAILED at 73.
Hunk #4 FAILED at 87.
Hunk #5 FAILED at 103.
Hunk #6 FAILED at 118.
Hunk #7 FAILED at 133.
Hunk #8 FAILED at 329.
Hunk #9 FAILED at 530.
Hunk #10 FAILED at 983.
Hunk #11 succeeded at 1189 with fuzz 2 (offset 89 lines).
Hunk #12 FAILED at 1256.
Hunk #13 succeeded at 1290 with fuzz 2 (offset 92 lines).
Hunk #14 FAILED at 1361.
Hunk #15 FAILED at 1404.
Hunk #16 succeeded at 3004 (offset 98 lines).
12 out of 16 hunks FAILED -- saving rejects to file smtp.module.rej
done

optalgin’s picture

StatusFileSize
new92.17 KB

This patching thing is not working so well
gcopenhaver , I think it is time to open a "Drupal 6.x" branch for this module
It works very well for me for more then a month

Anyway, attached the module file that works for me on my 6.2 site

Cheers

kgelner’s picture

Category: feature » support

I had done my own simple edits to smtp.module (and info), that worked in 6.1 but broke in 6.2.

So instead I tried downloading the patch as per above in message #30 and applying that to the code from smtp-5.x-1.x-dev.tar.gz (I've used patch a lot in the past) - no luck, I get a number of hunks that fail to update.

I tried downloading the smtp.module file from message #36, and using that directly - no luck there either.

I get the same results as with my own edits in 6.2, when I add a user and it tries to send a registration email or I just try a test email from the smtp configuration screen, I always get a message that says:

"Unable to send e-mail. Please contact the site admin, if the problem persists."

.. An Hour Passes ...

Edit - I now have this working... I actually had two problems:

1) I had in fact, at some point, changed my gmail server password. But also,
2) There does seem to be a slight bug in the pacthed code, outbound email From address is tied to the value set for the general site contact email, not the value entered in the SMTP configuration screen. I got an error message saying it did not like the From address I was using, with an old email address I had left in the site config screen.

Thanks everyone for the patching effort, works better than my dodgy attempts.

hafizul’s picture

StatusFileSize
new19.53 KB

Everyone.. just use this files for Drupal 6.2 and you will run your SMTP just fine. No need to patch anything. I have tested it and it worked flawlessly.

Thanks a lot to #36 Optalgin.

sotiris’s picture

+1 at comment #38

Thank you guys!!!

I have only one problem.
New user registration mails are treated as spam mails...
I am using the smtp module, and the from address is in the same domain with the mail server.
But something i have noticed is that every time i am sending the test email through the smtp configuration at administer->settings->smtp mails doesn't treated as spam, it goes in the inbox normally.
So what is the difference between these 2, that makes the first one to be treated as a spam???
I'll try to find out a solution, but if anyone can help me, i will appreciate it.

I found that drupal.org/node/164567, and everything now is ok!
When i deleted the links in the message section the email went to inbox. (anti-phising filters)

magnus’s picture

When I translated this I found a small bug
In smtp.module on row 67
'#options' => array(1 => 'On', 0 => 'Off'),
should be
'#options' => array(1 => t('On'), 0 => t('Off')),

Cyber-Jay’s picture

Hello, the module does not run with the guestbook module.
Error: Error Sending e-mail from: info@ITextreme.de to: New guestbook entry - SMTP Error: The following recipients failed: New guestbook entry

What to do???

davedelong’s picture

+1 @ #38

Worked perfectly for me using Drupal 6.2

intropedro’s picture

The zip of the commentary 38 did not work in my drupal 6.2. In the drupal 5 with module version 5 work, therefore not my problem host.

optalgin’s picture

I got this running for couple of months on 6.2 site, I use gmail and it works great
Do you get any errors in the logs?

Passionate_Lass’s picture

subscribe

modctek’s picture

The patched module in #38 is working just fine on my website using Gmail and SSL.

pablokenfold’s picture

Another +1 to #38.
Thank you!

jhujsak’s picture

StatusFileSize
new19.52 KB

All,

We had a problem at Webfaction where the SMTP hostname is of form smtpX.webfaction.com, X being some number such as 9. The script, on line 1979, forms the hostname by apparently concatenating the protocol (i.e. "smtp") to the provided hostname. If this is changed to:

#connect to the smtp server
$this->smtp_conn = fsockopen($host, # the host of the server
$port, # the port to use
$errno, # error number if any
$errstr, # error message if any
$tval); # give up after ? secs

where $host is used instead of $this->protocol . $host it will handle hostnames such as the ones Webfaction uses. Just enter the complete hostname in the configuration panel and it works just fine.

Revised module is attached.

eblues’s picture

Thanks to #'s 36, 38 and 48 for providing this module!

Excuse my newbie-ness.... just wondering out loud here.... with many hosting services disabling php mail() to combat spammers, isn't it time the Drupal core allow for authenticated smtp configuration?

This functionality seems pretty critical.

oadaeh’s picture

After a couple of weeks of works, I've finally created an official port to Drupal 6. Please read the release node and the documentation, as there have been quite a few changes, including the removal of the LGPL class code.

Here is the release node: http://drupal.org/node/279095. The file may not yet be there, but will be within about 12 hours.

Because of the extensive changes I made to the base structure of this module, I did not use any of the patches included in this issue, nor did I even look at them. I thank all of you who committed patches and kept this module alive. I very much appreciate your efforts.

oadaeh’s picture

@eblues: To address your question:

...with many hosting services disabling php mail() to combat spammers, isn't it time the Drupal core allow for authenticated smtp configuration?

The thing that makes this module's functionality possible are two external classes called PHPMailer and SMTP. It is entirely unlikely that they will ever be included in Drupal's core. Also, due to the size and complexity of that functionality, it is unlikely that anything like them will ever be developed for Drupal core, but that would be the way to get it in.

engelmicha’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Component: Code » Miscellaneous
Category: support » bug

the installation of the module worked without problems.
test-emails were sent without problems.
contact forms were sent without any errors in the debug output, but neither in the debug- nor in the normal mode a success message was displayed. the contact form was "replaced" by a blank browser

oadaeh’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Component: Miscellaneous » Code
Category: bug » support

@engelmicha: if you are using the patches in this issue to patch a 5.x copy of this module, then please download a copy of the 6.x module and use that instead. If you are using a copy of the 6.x module, then please open a new issue for your problem. Thank you.

engelmicha’s picture

@oadaeh
Sorry I'm using a copy of the 6.x module
I'm new here and did not notice being wrong here
sorry for that

oadaeh’s picture

@engelmicha: Try working through the items on this page to see if they help with your situation. If they don't, open a new issue, and try to give as much detail as possible.

himtuna’s picture

Please can anybody tell me where to start with?

l error: require_once() [function.require]: Failed opening required 'sites/all/modules/smtp/phpmailer/class.phpmailer.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/himanshu/sites/gamersden.in/sites/all/modules/smtp/smtp.module on line 245

spydmobile’s picture

I am not an expert, but it looks like you might be missing the class file in the phpmailer folder in the smtp folder.

himtuna’s picture

thanks the i uploaded the files in wrong directory (root of the module)
everything works fine.

Gamers' Den

oadaeh’s picture

Status: Needs work » Fixed

With my changes here and here on September 23, I'm going to mark this as fixed. If anyone has any problems, please open a new issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.