Jump to content

PHPMailer Module


Harmster
 Share

Recommended Posts

Hey,

[NOTE] I have no idea if there's a better way, already a module that does the same or slightly different I just made this and I love to share this in case someone needs it!

Onto the intro:

every time I use the PHP Mail() function I find myself frustrated in the way I receive these e-mails so I found a library PHPMailer that lets you use SMTP fairly simple and because I love processwire I made this into a module

Get it here:  Github

Basicly you use it almost the same as the PHP mail function, but this time you setup your SMTP (I've tested it with gmail) and call a method called send() on $phpmailer.

Here's settings for gmail:

- security:  tls

- port:        587

here's a example of usage:

$subject = 'test';
$message = "Test message";
$r = $phpmailer->send($subject, $message, array($user->email => $user->first_name. " " .$user->last_name));

Arguments:

- Subject: string

- Message: string(html or whatever)

- Recipient: array(email:string => name:string)

- Attachment: array(path:string) !OPTIONAL

It returns a 1 on success and an error string on failure.

Use it, or don't.

See you all around

  • Like 4
Link to comment
Share on other sites

Thanks for this Harmster.

There has been a great deal going on regarding a mailing class, etc. Have a look at this thread: 

http://processwire.com/talk/topic/5693-new-module-type-wiremail/

ProcessWire now has a new mail base class that you can use with other mail classes. See Horst (WireMailSmtp) and Teppo's (WireMailSwiftMailer) for instance...You might want to make use of the new base class in your module.. :)

  • Like 2
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...