Drupal 6 patches for SMTP module

gcopenhaver - January 28, 2008 - 06:51
Project:SMTP Authentication Support
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:patch (code needs work)
Description

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!

AttachmentSize
smtp.info_.patch416 bytes
smtp.module.patch10.95 KB

#1

gcopenhaver - January 28, 2008 - 06:54
Title:Here are some patches for updating module for Drupal 6» Drupal 6 patches for SMTP module

changing issue title

#2

Starbuck - February 11, 2008 - 19:35

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!!!!

#3

lilou - February 14, 2008 - 02:43

subscribe

#4

Starbuck - February 15, 2008 - 09:22

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

#5

realistknight - February 19, 2008 - 03:41

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

#6

gcopenhaver - February 19, 2008 - 03:56

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

#7

wildtang3nt - February 24, 2008 - 19:47

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

#8

oadaeh - February 27, 2008 - 15:40

@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)

#9

gcopenhaver - February 27, 2008 - 15:50

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.

#10

Optalgin - March 10, 2008 - 14:42

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

#11

creativepragmatic - March 13, 2008 - 00:25

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?

#12

oadaeh - March 13, 2008 - 22:09

@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.

#13

creativepragmatic - March 14, 2008 - 19:13

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

#14

lilou - March 15, 2008 - 17:25

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

AttachmentSize
smtp-d5-to-d6.patch17.95 KB

#15

intropedro - March 16, 2008 - 13:50

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

#16

sammorgan - March 17, 2008 - 21:24

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

THanks in advance

Sam

#17

deadmalc - March 18, 2008 - 22:48

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

#18

deadmalc - March 19, 2008 - 11:10

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

AttachmentSize
smtp.tar_.gz19.75 KB

#19

mbull - March 20, 2008 - 13:12

Hi

Can anyone tell me how to apply the patch?

#20

deadmalc - March 20, 2008 - 16:40

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

#21

spydmobile - March 20, 2008 - 16:49

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

#22

oadaeh - March 20, 2008 - 17:02

@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.

#23

spydmobile - March 24, 2008 - 21:37

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

#24

mbull - March 25, 2008 - 17:54

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?

#25

randya - March 31, 2008 - 15:12
Assigned to:Anonymous» randya
Status:patch (code 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

#26

Optalgin - March 31, 2008 - 16:41

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..

#27

spydmobile - April 1, 2008 - 21:38

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

#28

rboy - April 14, 2008 - 07:43

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.

#29

gcopenhaver - April 14, 2008 - 13:05

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.

#30

gcopenhaver - April 14, 2008 - 14:07

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.

AttachmentSize
smtp.module.patch16.24 KB

#31

rboy - April 14, 2008 - 16:36

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!

#32

lucacerone - April 16, 2008 - 00:33
Category:feature request» support request
Priority:normal» critical
Assigned to:randya» lucacerone
Status:patch (to be ported)» 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

#33

gcopenhaver - April 16, 2008 - 01:21
Category:support request» feature request
Priority:critical» normal
Assigned to:lucacerone» Anonymous
Status:won't fix» patch (code 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)

#34

lucacerone - April 16, 2008 - 10:38

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!

#35

dkreviews - April 17, 2008 - 22:50

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

AttachmentSize
smtp-6.1.zip19.86 KB

#36

Optalgin - April 18, 2008 - 20:21

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

AttachmentSize
smtp.module.txt92.17 KB

#37

kgelner - April 24, 2008 - 00:25
Category:feature request» support request

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.

#38

hafizul - May 3, 2008 - 23:15

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.

AttachmentSize
SMTP_modules_6.2.zip19.53 KB

#39

sotiris - May 4, 2008 - 06:31

+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)

#40

seals - May 12, 2008 - 02:13

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')),

#41

Cyber-Jay - May 19, 2008 - 17:41

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???

#42

davedelong - May 20, 2008 - 21:17

+1 @ #38

Worked perfectly for me using Drupal 6.2

#43

intropedro - June 12, 2008 - 18:48

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.

#44

Optalgin - June 15, 2008 - 19:53

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?

#45

Passionate_Lass - June 17, 2008 - 16:59

subscribe

#46

modctek - June 20, 2008 - 17:04

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

#47

pruizw - June 23, 2008 - 17:49

Another +1 to #38.
Thank you!

#48

jhujsak - July 5, 2008 - 00:51

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.

AttachmentSize
SMTP_modules_6.2_rev1.zip19.52 KB

#49

eblues - July 5, 2008 - 18:41

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.

#50

oadaeh - July 6, 2008 - 14:52

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.

#51

oadaeh - July 6, 2008 - 14:57

@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.

#52

engelmicha - July 24, 2008 - 01:12
Version:5.x-1.x-dev» 6.x-1.x-dev
Component:Code» Miscellaneous
Category:support request» bug report

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

#53

oadaeh - July 24, 2008 - 01:36
Version:6.x-1.x-dev» 5.x-1.x-dev
Component:Miscellaneous» Code
Category:bug report» support request

@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.

#54

engelmicha - July 29, 2008 - 21:23

@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

#55

oadaeh - July 30, 2008 - 00:53

@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.

 
 

Drupal is a registered trademark of Dries Buytaert.