This topic is locked
[SOLVED]

 Send mail with runner mail

11/25/2010 5:34:45 PM
PHPRunner General questions
T
tedwilder author

hello
I have 2 questions:

1/ I need to send an email whitin phprunner, so I found in help file a description of how to do it ..BUT The phprunner is installed on the intranet.however mail has to be send to the "real world" and so I have a pop account on a mail serveur dedicated to that. Because of annoying spam system I cant send mail directly from this server. So I need to send mail the same way it's now possible to send registration mail : Providing smtp mail server adresse and account. So how can I use mailrunner to use a specific mail server?
2/ in the mail I want to send I need html : so it's ok there is an example in help file.. but my boss want me to put the compagny logo in the mail ( not as attachment, but in the body of the mail). Any idea how I can do that? I can't put an absolute url to some picture on some host file, no, I need that the file is embedded in the html : like when sending mail with outlook : the picture use in the body mail is embedded..
thnak you for your suggestions.

kujox 11/26/2010



hello
I have 2 questions:

1/ I need to send an email whitin phprunner, so I found in help file a description of how to do it ..BUT The phprunner is installed on the intranet.however mail has to be send to the "real world" and so I have a pop account on a mail serveur dedicated to that. Because of annoying spam system I cant send mail directly from this server. So I need to send mail the same way it's now possible to send registration mail : Providing smtp mail server adresse and account. So how can I use mailrunner to use a specific mail server?
2/ in the mail I want to send I need html : so it's ok there is an example in help file.. but my boss want me to put the compagny logo in the mail ( not as attachment, but in the body of the mail). Any idea how I can do that? I can't put an absolute url to some picture on some host file, no, I need that the file is embedded in the html : like when sending mail with outlook : the picture use in the body mail is embedded..
thnak you for your suggestions.


On your first question you'll need to install an smtp server on the machine that is sending the email, this will allow you to send it from a local machine, I use XAMPP on my local machine for developing which has mercury bundled with it (http://www.danieltmurphy.com/setting-up-mercury-smtp/) but there are plently of other free servers out there try.
http://www.softstack.com/freesmtp.html
When I want to include an image in an email I store the image on the website/intranet and then have a absolute url to the image(https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=54717&image=1&table=forumreplies) as the image SRC in the html.
hope that helps

T
tedwilder author 11/26/2010

Hello
thank you for taking time to answer me.

however there is already a mail server on the intranet server on whch phprunner is. But I cant use it to send mail. it's a big compagny and I'm not admin. Admin wants to centralized all mail on one server dedicated to that. But I saw phpmail is installed somewhere in phprunner because the registration process use it. I just like to know how I can call the phpmail to define my own smtp server in string.
concerning image, yeah well thats exactly what I cant do. The server on which phprunner is , is a virtual server dedicated to one task for internal hotline purpose. I have no access to other extranet server and admin want everything to be on one unit : no dispatching ressources everywhere.. so I'd like to embededd the image inside the mail.. If phpmail is installed I know this php class can do that .. but dont know exactly how to do it.
thank you anyway.

T
tedwilder author 11/29/2010

ok for those interested phpmailer is installed on any phprunner project under /libs/phpmailer
so you can use :
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

05.
06.$mail->IsSMTP(); // telling the class to use SMTP

07.
08.try {

09.

$mail->Host = "mail.yourdomain.com"; // SMTP server

10.

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)

11.

$mail->SMTPAuth = true; // enable SMTP authentication

12.

$mail->Host = "mail.yourdomain.com"; // sets the SMTP server

13.

$mail->Port = 26; // set the SMTP port for the GMAIL server

14.

$mail->Username = "yourname@yourdomain"; // SMTP account username

15.

$mail->Password = "yourpassword"; // SMTP account password

16.

$mail->AddReplyTo('name@yourdomain.com', 'First Last');

17.

$mail->AddAddress('whoto@otherdomain.com', 'John Doe');

18.

$mail->SetFrom('name@yourdomain.com', 'First Last');

19.

$mail->AddReplyTo('name@yourdomain.com', 'First Last');

20.

$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';

21.

$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically

22.

$mail->MsgHTML(file_get_contents('contents.html'));

23.

$mail->AddAttachment('images/phpmailer.gif'); // attachment

24.

$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment

25.

$mail->Send();

26.

echo "Message Sent OK<P></P>\n";

27.} catch (phpmailerException $e) {

28.

echo $e->errorMessage(); //Pretty error messages from PHPMailer

29.} catch (Exception $e) {

30.

echo $e->getMessage(); //Boring error messages from anything else!

31.}
( code from phpmailer home page)

this way both my question are answered : It can use smtp server that requires identification and it can embedded images ( inline html).

just add a : require ("/libs/phpmailer/class.phpmailer.php"); at the biginning of the event.

Sergey Kornilov admin 11/29/2010

I'm afraid you overthinking it a bit. Once you entered SMTP server address in PHPRunner mail settings PHPRunner switches to PHPMailer automatically. No manual coding required.