www.webdeveloper.com
Results 1 to 5 of 5

Thread: Help with Swift Mailer for Beginner

  1. #1
    Join Date
    Dec 2008
    Posts
    132

    Help with Swift Mailer for Beginner

    Hi, I have done some research and reading and it sounds like swiftmailer is what I need. However, I can't understand the documentation that is provided in the swiftmailer website. Can someone please give an example of a simple for with a few fields such as name, email, and attachments in the swiftmailer 4.3.0 so I can take it from there? I don't need the form page just the processing page will be great. If not please point me to a site that will have tutorial/sample that have complete from beginning to end code. Thx.

  2. #2
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,503
    PHP Code:
    require_once 'lib/swift_required.php';

    // Create the Transport
    $transport Swift_SmtpTransport::newInstance('smtp.example.org'25)
      ->
    setUsername('your username')
      ->
    setPassword('your password')
      ;

    /*
    You could alternatively use a different transport such as Sendmail or Mail:

    // Sendmail
    $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

    // Mail
    $transport = Swift_MailTransport::newInstance();
    */

    // Create the Mailer using your created Transport
    $mailer Swift_Mailer::newInstance($transport);

    // Create a message
    $message Swift_Message::newInstance('Wonderful Subject')
      ->
    setFrom(array('john@doe.com' => 'John Doe'))
      ->
    setTo(array('receiver@domain.org''other@domain.org' => 'A name'))
      ->
    setBody('Here is the message itself')

      
    // Optionally add any attachments
      
    ->attach(Swift_Attachment::fromPath('my-document.pdf'))
      ;

    // Send the message
    $result $mailer->send($message); 
    Copy-pasted from the documentation. Just FYI.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  3. #3
    Join Date
    Dec 2008
    Posts
    132
    Hi Jeff,

    Thanks for the response. The attachment in the document looks like a document that is on my server. What I need is a uploaded file from the user and email it to me and needs to have multiple files. How is that done?

  4. #4
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,503
    If the file has been uploaded, then it will in fact be on your server. It will be saved at $_FILES['form_control_name']['tmp_name']. (See http://www.php.net/manual/en/feature...ost-method.php)

    You can attach as many files as you like by invoking ->attach() as many times as needed.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  5. #5
    Join Date
    Dec 2008
    Posts
    132
    I think I get it now. But how do I validate those files are images before using swiftmailer to send it? I seen some php script to validate one file but how to validate multiple files? thx.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles